fix(tests): pass base_url to 31 more AIAgent() calls across run_agent tests

Same root cause as previous commit — tests that construct AIAgent()
without base_url rely on provider-resolver fallback state that doesn't
exist in hermetic CI / shard-split runs. Previously hidden because
other tests in the same xdist worker happened to prime module state.

Covered by the previous fix: calls that passed api_key but not base_url.
This covers calls that pass NEITHER (model=... only) — test_streaming.py
especially (24 call sites). Plus test_860_dedup, test_compression_
persistence, test_create_openai_client_*, test_provider_parity.

One call site (test_none_base_url_passed_as_none) remains explicitly
unmodified — it asserts None/empty base_url behavior, so adding base_url
would defeat the test's intent.

Validation:
- tests/run_agent/: 760 passed, 0 failed (local)
- Matrix shard 3 subset: 3098 passed, 0 failed, 1m49s (local)
This commit is contained in:
Teknium 2026-04-17 07:17:54 -07:00
parent c2559b80fa
commit 5d179b9777
No known key found for this signature in database
6 changed files with 31 additions and 0 deletions

View file

@ -29,6 +29,7 @@ class TestFlushDeduplication:
with patch.dict(os.environ, {"OPENROUTER_API_KEY": "test-key"}):
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
session_db=session_db,
@ -271,6 +272,7 @@ class TestFlushIdxInit:
with patch.dict(os.environ, {"OPENROUTER_API_KEY": "test-key"}):
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -283,6 +285,7 @@ class TestFlushIdxInit:
with patch.dict(os.environ, {"OPENROUTER_API_KEY": "test-key"}):
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,

View file

@ -37,6 +37,7 @@ class TestFlushAfterCompression:
with patch.dict(os.environ, {"OPENROUTER_API_KEY": "test-key"}):
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
session_db=session_db,

View file

@ -19,6 +19,7 @@ from run_agent import AIAgent
def test_create_openai_client_does_not_mutate_input_kwargs(mock_openai):
mock_openai.return_value = MagicMock()
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,

View file

@ -23,6 +23,7 @@ from run_agent import AIAgent
def _make_agent():
return AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,

View file

@ -60,6 +60,7 @@ def _make_agent(monkeypatch, provider, api_mode="chat_completions", base_url="ht
)
if model:
kwargs["model"] = model
base_url="https://openrouter.ai/api/v1",
return AIAgent(**kwargs)

View file

@ -80,6 +80,7 @@ class TestStreamingAccumulator:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -120,6 +121,7 @@ class TestStreamingAccumulator:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -167,6 +169,7 @@ class TestStreamingAccumulator:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -205,6 +208,7 @@ class TestStreamingAccumulator:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -245,6 +249,7 @@ class TestStreamingCallbacks:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -277,6 +282,7 @@ class TestStreamingCallbacks:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -308,6 +314,7 @@ class TestStreamingCallbacks:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -346,6 +353,7 @@ class TestStreamingCallbacks:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -381,6 +389,7 @@ class TestStreamingCallbacks:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -428,6 +437,7 @@ class TestStreamingFallback:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -455,6 +465,7 @@ class TestStreamingFallback:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -477,6 +488,7 @@ class TestStreamingFallback:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -500,6 +512,7 @@ class TestStreamingFallback:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -542,6 +555,7 @@ class TestStreamingFallback:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -577,6 +591,7 @@ class TestStreamingFallback:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -619,6 +634,7 @@ class TestReasoningStreaming:
mock_create.return_value = mock_client
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -646,6 +662,7 @@ class TestHasStreamConsumers:
def test_no_consumers(self):
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -656,6 +673,7 @@ class TestHasStreamConsumers:
def test_delta_callback_set(self):
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -667,6 +685,7 @@ class TestHasStreamConsumers:
def test_stream_callback_set(self):
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -688,6 +707,7 @@ class TestCodexStreamCallbacks:
deltas = []
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -729,6 +749,7 @@ class TestCodexStreamCallbacks:
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -792,6 +813,7 @@ class TestCodexStreamCallbacks:
)
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -810,6 +832,7 @@ class TestCodexStreamCallbacks:
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,
@ -861,6 +884,7 @@ class TestAnthropicStreamCallbacks:
from run_agent import AIAgent
agent = AIAgent(
base_url="https://openrouter.ai/api/v1",
model="test/model",
quiet_mode=True,
skip_context_files=True,