The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
simplify(compat): livetest scripts spy normalize_usage where the loop calls it (agent.turn_usage), not the old facade
Tekniumb8905c7d62b1
diff --git a/scripts/tool_search_livetest2.py b/scripts/tool_search_livetest2.pyindex dd9b9dd0faa..eb9d7971332 100644--- a/scripts/tool_search_livetest2.py+++ b/scripts/tool_search_livetest2.py@@ -107,10 +107,10 @@ def run_one(scenario: Dict[str, Any], mode: str, rep: int, out_dir: Path) -> Dicdiscover_plugins() # idempotent; ensures no later clear wipes our hookpm = get_plugin_manager()pm._hooks.setdefault("post_api_request", []).append(usage_hook)- # Belt-and-braces: normalize_usage in the conversation loop is called+ # Belt-and-braces: normalize_usage in agent.turn_usage (the conversation loop's usage recorder) is called# exactly once per API response (streaming AND non-streaming). Wrap it# to capture canonical usage the hook path may miss.- import agent.conversation_loop as _cl+ import agent.turn_usage as _cl_orig_norm = _cl.normalize_usagedef _norm_spy(raw, **kw):cu = _orig_norm(raw, **kw)@@ -140,7 +140,7 @@ def run_one(scenario: Dict[str, Any], mode: str, rep: int, out_dir: Path) -> Dicfinally:registry.dispatch = original_dispatchtry:- import agent.conversation_loop as _cl2+ import agent.turn_usage as _cl2if "_orig_norm" in dir() or True:try:_cl2.normalize_usage = _orig_norm # type: ignore[name-defined]diff --git a/scripts/tool_search_livetest_ue.py b/scripts/tool_search_livetest_ue.pyindex 37940d7ad25..5f9f54e29b2 100644--- a/scripts/tool_search_livetest_ue.py+++ b/scripts/tool_search_livetest_ue.py@@ -194,7 +194,7 @@ def run_one(scenario, mode, scale, rep, out_dir: Path):skip_context_files=True, skip_memory=True,platform="cli", max_iterations=15,)- import agent.conversation_loop as _cl+ import agent.turn_usage as _cl_orig_norm = _cl.normalize_usagedef _norm_spy(raw, **kw):cu = _orig_norm(raw, **kw)@@ -224,7 +224,7 @@ def run_one(scenario, mode, scale, rep, out_dir: Path):registry.dispatch = original_dispatchif _orig_norm is not None:try:- import agent.conversation_loop as _cl2+ import agent.turn_usage as _cl2_cl2.normalize_usage = _orig_normexcept Exception:passdiff --git a/scripts/tool_search_livetest_ue_disc.py b/scripts/tool_search_livetest_ue_disc.pyindex 615a662326d..6a89a862744 100644--- a/scripts/tool_search_livetest_ue_disc.py+++ b/scripts/tool_search_livetest_ue_disc.py@@ -154,7 +154,7 @@ def run_one(scenario, mode, rep, out_dir: Path):agent = AIAgent(provider="openrouter", model=model, quiet_mode=True,save_trajectories=False, skip_context_files=True,skip_memory=True, platform="cli", max_iterations=15)- import agent.conversation_loop as _cl+ import agent.turn_usage as _cl_orig_norm = _cl.normalize_usagedef _norm_spy(raw, **kw):cu = _orig_norm(raw, **kw)@@ -180,7 +180,7 @@ def run_one(scenario, mode, rep, out_dir: Path):registry.dispatch = original_dispatchif _orig_norm is not None:try:- import agent.conversation_loop as _cl2+ import agent.turn_usage as _cl2_cl2.normalize_usage = _orig_normexcept Exception:passdiff --git a/scripts/tool_search_livetest_ue_hard.py b/scripts/tool_search_livetest_ue_hard.pyindex c2f8950975b..cb930aa2771 100644--- a/scripts/tool_search_livetest_ue_hard.py+++ b/scripts/tool_search_livetest_ue_hard.py@@ -234,7 +234,7 @@ def run_one(scenario, mode, rep, out_dir: Path):agent = AIAgent(provider="openrouter", model=model, quiet_mode=True,save_trajectories=False, skip_context_files=True,skip_memory=True, platform="cli", max_iterations=15)- import agent.conversation_loop as _cl+ import agent.turn_usage as _cl_orig_norm = _cl.normalize_usagedef _norm_spy(raw, **kw):cu = _orig_norm(raw, **kw)@@ -261,7 +261,7 @@ def run_one(scenario, mode, rep, out_dir: Path):registry.dispatch = original_dispatchif _orig_norm is not None:try:- import agent.conversation_loop as _cl2+ import agent.turn_usage as _cl2_cl2.normalize_usage = _orig_normexcept Exception:pass