Commit graph

3 commits

Author SHA1 Message Date
Teknium
c2559b80fa
fix(tests): pass base_url explicitly in AIAgent constructor calls
Tests that construct AIAgent(api_key=..., ...) without base_url were
relying on provider-resolver fallback state from other tests in the
same xdist worker. When matrix-split distributed them to different
shards, the resolver found no env vars and no config and raised
'No LLM provider configured'.

Fix: add base_url='https://openrouter.ai/api/v1' to every AIAgent
construction that passes api_key. AIAgent.__init__ with both args set
takes the direct-construction path (line 960 in run_agent.py) and
skips resolver fallback entirely, making these tests self-contained.

7 files, 16 call sites updated via AST-based fixup. One call site
(test_none_base_url_passed_as_none) left alone — that test's
intent is to verify base_url=None behavior, so adding base_url
defeats the test.

Validation:
- tests/run_agent/ full run: 760 passed, 0 failed (was 1 failure
  under the AST script's over-application, now clean)
- Matrix shard 3 local run: 3083 passed, 0 failed, 1m44s
2026-04-17 06:59:35 -07:00
Teknium
c5688e7c8b fix(gateway): break compression-exhaustion infinite loop and auto-reset session (#9893)
When compression fails after max attempts, the agent returns
{completed: False, partial: True} but was missing the 'failed' flag.
The gateway's agent_failed_early guard checked for 'failed' AND
'not final_response', but _run_agent_blocking always converts errors
to final_response — making the guard dead code.  This caused the
oversized session to persist, creating an infinite fail loop where
every subsequent message hits the same compression failure.

Changes:
- run_agent.py: add 'failed: True' and 'compression_exhausted: True'
  to all 5 compression-exhaustion return paths
- gateway/run.py (_run_agent_blocking): forward 'failed' and
  'compression_exhausted' flags through to the caller
- gateway/run.py (_handle_message_with_agent): fix agent_failed_early
  to check bool(failed) without the broken 'not final_response' clause;
  auto-reset the session when compression is exhausted so the next
  message starts fresh
- Update tests to match new guard logic and add
  TestCompressionExhaustedFlag test class

Closes #9893
2026-04-14 21:18:17 -07:00
Siddharth Balyan
f3006ebef9
refactor(tests): re-architect tests + fix CI failures (#5946)
* refactor: re-architect tests to mirror the codebase

* Update tests.yml

* fix: add missing tool_error imports after registry refactor

* fix(tests): replace patch.dict with monkeypatch to prevent env var leaks under xdist

patch.dict(os.environ) can leak TERMINAL_ENV across xdist workers,
causing test_code_execution tests to hit the Modal remote path.

* fix(tests): fix update_check and telegram xdist failures

- test_update_check: replace patch("hermes_cli.banner.os.getenv") with
  monkeypatch.setenv("HERMES_HOME") — banner.py no longer imports os
  directly, it uses get_hermes_home() from hermes_constants.

- test_telegram_conflict/approval_buttons: provide real exception classes
  for telegram.error mock (NetworkError, TimedOut, BadRequest) so the
  except clause in connect() doesn't fail with "catching classes that do
  not inherit from BaseException" when xdist pollutes sys.modules.

* fix(tests): accept unavailable_models kwarg in _prompt_model_selection mock
2026-04-07 17:19:07 -07:00
Renamed from tests/test_1630_context_overflow_loop.py (Browse further)