feat(fase3): additive meter= seam on run_project (SC3 detach hook)

This commit is contained in:
Kjell Tore Guttormsen 2026-06-26 11:51:25 +02:00
commit 8b64c7f8de
2 changed files with 39 additions and 1 deletions

View file

@ -124,6 +124,7 @@ async def run_project(
top_k: int = 3,
enable_layer1_hitl: bool = False,
notify: Callable[[Verdict], None] | None = None,
meter: TokenMeter | None = None,
) -> RunResult:
"""Run the vertical slice for ONE project. ``client_factory`` is the test-injection seam
(defaults to the real backend). ``verdict_input`` carries the expert decision/rationale
@ -148,7 +149,11 @@ async def run_project(
# The shared meter is driven on the debate's chat calls by the BudgetMiddleware
# (the brief's named short-circuit mechanism); the retrieval tool exposes the
# citation-bearing data source to the agents (no longer string-stuffed out-of-band).
meter = TokenMeter(Budget(max_tokens=max_tokens, max_rounds=max(max_rounds * 4, 4)))
meter = (
meter
if meter is not None
else TokenMeter(Budget(max_tokens=max_tokens, max_rounds=max(max_rounds * 4, 4)))
)
factory = client_factory if client_factory is not None else _default_factory(profile)
budget_mw = BudgetMiddleware(meter)
retrieval_tool = make_retrieval_tool(docs_dir, top_k=top_k)