fix(tests): align run_agent expectations with current routing - #4554
Closed
kshitijk4poor wants to merge 1 commit into
Closed
fix(tests): align run_agent expectations with current routing#4554kshitijk4poor wants to merge 1 commit into
kshitijk4poor wants to merge 1 commit into
Conversation
Contributor
|
Thanks for the contribution, @kshitijk4poor! Closing this as stale. The test tree was rearchitected in #5946 — tests are now under If you want to revisit this for the refactored code on current main, please open a new PR rebased on main targeting the current file layout. Your authorship will be preserved through cherry-pick if we salvage any of your work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestBuildApiKwargsexplicitly target the current OpenRouter route/model combinations required forextra_bodyassertionsrun_agent.pypathProblem
While validating #4552, the broader
tests/test_run_agent.py tests/test_run_agent_codex_responses.py -qrun hit unrelated failures on currentmainintests/test_run_agent.py:TestBuildApiKwargs::*expectedextra_bodyon a fixture that no longer explicitly targeted an OpenRouter-compatible route/modelTestInit.test_prompt_caching_claude_openrouterexpected Claude-via-OpenRouter prompt caching without explicitly setting the OpenRouter base URLTestStreamingApiCall.test_api_exception_falls_back_to_non_streamingonly patchedagent.client, but the current implementation now creates request-scoped clients through_create_request_openai_clientThese were test-drift issues, not production regressions in
run_agent.py.Fix
1. Make routing assumptions explicit in
TestBuildApiKwargsThe
extra_bodyassertions now set:agent.base_url = "https://openrouter.ai/api/v1"This matches the current
_build_api_kwargs()gates instead of relying on fixture defaults.2. Make the Claude prompt-caching test explicitly OpenRouter
test_prompt_caching_claude_openrouternow passes the OpenRouter base URL directly, so it tests the intended path instead of an implicit default that has drifted.3. Patch request-scoped client creation in the streaming fallback test
test_api_exception_falls_back_to_non_streamingnow mocks_create_request_openai_clientso both the streaming path and the non-streaming fallback use the same mocked client and raise the expectedConnectionError.Test Results
Passed:
python -m pytest tests/test_run_agent.py -q -k "TestBuildApiKwargs or test_prompt_caching_claude_openrouter or test_api_exception_falls_back_to_non_streaming"python -m pytest tests/test_run_agent.py tests/test_run_agent_codex_responses.py -qThis follow-up is intentionally test-only and separate from #4552.