fix(run_agent): gate iteration-limit provider routing to OpenRouter

This commit is contained in:
molvikar 2026-05-04 01:45:52 +03:00 committed by Teknium
parent 8a364df2c8
commit cb33c73418
2 changed files with 32 additions and 1 deletions

View file

@ -2230,6 +2230,34 @@ class TestHandleMaxIterations:
]
assert len(stub_ids) >= 1, f"No stub result for assistant tool_call: {stub_ids}"
def test_summary_omits_provider_preferences_for_non_openrouter(self, agent):
agent.base_url = "https://api.openai.com/v1"
agent._base_url_lower = agent.base_url.lower()
agent.provider = "openai"
agent.providers_allowed = ["Anthropic"]
agent.client.chat.completions.create.return_value = _mock_response(content="Summary")
agent._cached_system_prompt = "You are helpful."
result = agent._handle_max_iterations([{"role": "user", "content": "do stuff"}], 60)
assert result == "Summary"
kwargs = agent.client.chat.completions.create.call_args.kwargs
assert "provider" not in kwargs.get("extra_body", {})
def test_summary_keeps_provider_preferences_for_openrouter(self, agent):
agent.base_url = "https://openrouter.ai/api/v1"
agent._base_url_lower = agent.base_url.lower()
agent.provider = "openrouter"
agent.providers_allowed = ["Anthropic"]
agent.client.chat.completions.create.return_value = _mock_response(content="Summary")
agent._cached_system_prompt = "You are helpful."
result = agent._handle_max_iterations([{"role": "user", "content": "do stuff"}], 60)
assert result == "Summary"
kwargs = agent.client.chat.completions.create.call_args.kwargs
assert kwargs["extra_body"]["provider"]["only"] == ["Anthropic"]
def test_codex_summary_sanitizes_orphan_tool_results(self, agent):
agent.api_mode = "codex_responses"
agent.provider = "openai-codex"