The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(data-use): MoA max-iterations summary keeps the connector requirement
Siddharth Balyand17d7f6fed70
diff --git a/agent/chat_completion_helpers.py b/agent/chat_completion_helpers.pyindex 8eca017fc1b..a9349654010 100644--- a/agent/chat_completion_helpers.py+++ b/agent/chat_completion_helpers.py@@ -2260,6 +2260,9 @@ def _chat_summary_attempt(agent, api_messages: list, api_request_id: str):# The summary now carries ``tools``; on cache-planned routes the main loop scrubbed a deep# copy, so ``agent.tools`` may still hold bytes the provider 400s on.sanitize_outbound_kwargs(agent, summary_kwargs)+ from agent.conversation_loop import _moa_client_consumes_prepared_request+ if agent.provider == "moa" and _moa_client_consumes_prepared_request(agent.client): # transport strips data_use+ summary_kwargs["_moa_prepared_request"] = agent.client.chat.completions.prepare(api_messages)def _attempt(retry_count: int) -> str:# Use the ordinary request-local lifecycle: a summary can be interrupted@@ -2279,9 +2282,7 @@ def handle_max_iterations(agent, messages: list, api_call_count: int) -> str:warning = f"⚠️ Reached maximum iterations ({agent.max_iterations}). Requesting summary..."if getattr(agent, "suppress_status_output", False):# Strict machine-readable mode (-Q, oneshot): keep diagnostics off stdout. quiet_mode is- # NOT the gate — the interactive CLI runs quiet_mode=True by default and must see this.- # Strict machine-readable mode (hermes chat -Q, oneshot, background review): keep diagnostics out of- # stdout so wrappers receive only the final assistant content (#93220 class).+ # NOT the gate — the interactive CLI runs quiet_mode=True by default and must see this (#93220 class).logger.warning(warning)else:agent._safe_print(warning, diagnostic=True)diff --git a/tests/agent/test_moa_loop_mode.py b/tests/agent/test_moa_loop_mode.pyindex 860232d7a0b..e06d55bed43 100644--- a/tests/agent/test_moa_loop_mode.py+++ b/tests/agent/test_moa_loop_mode.py@@ -467,6 +467,41 @@ def test_reference_view_keeps_the_data_use_requirement_of_a_folded_tool_result()assert data_use_requirement(_reference_messages(messages)) == {"no_training"}+def test_max_iterations_summary_keeps_the_data_use_requirement_on_every_moa_slot(monkeypatch, tmp_path):+ from agent.chat_completion_helpers import handle_max_iterations+ from agent.message_metadata import data_use_requirement++ home = tmp_path / ".hermes"+ home.mkdir()+ (home / "config.yaml").write_text(+ "moa:\n default_preset: review\n presets:\n review:\n"+ " reference_models:\n - provider: nous\n model: ref-model\n"+ " aggregator:\n provider: nous\n model: agg-model\n",+ encoding="utf-8",+ )+ monkeypatch.setenv("HERMES_HOME", str(home))+ calls = []++ def fake_call_llm(**kwargs):+ calls.append((kwargs["task"], data_use_requirement(kwargs["messages"])))+ return _response("summary")++ monkeypatch.setattr("agent.moa_loop.call_llm", fake_call_llm)+ agent = AIAgent(+ api_key="moa-virtual-provider", base_url="moa://local", model="review", provider="moa",+ quiet_mode=True, skip_context_files=True, skip_memory=True, enabled_toolsets=["file"], max_iterations=1,+ )+ messages = [+ {"role": "user", "content": "read my mail"},+ {"role": "assistant", "content": "", "tool_calls": [+ {"id": "c1", "type": "function", "function": {"name": "read_file", "arguments": "{}"}}]},+ {"role": "tool", "tool_call_id": "c1", "content": "inbox", "data_use": ["no_training"]},+ ]++ assert handle_max_iterations(agent, messages, 1) == "summary"+ assert calls == [("moa_reference", {"no_training"}), ("moa_aggregator", {"no_training"})]++def test_reference_messages_ends_with_user_not_assistant_prefill():"""Advisory reference views must never end on an assistant turn.