Skip to content

fix(auxiliary): rebuild closed cached sync clients - #39023

Closed
alex107ivanov wants to merge 1 commit into
NousResearch:mainfrom
alex107ivanov:fix/auxiliary-evict-closed-sync-client
Closed

alex107ivanov wants to merge 1 commit into
NousResearch:mainfrom
alex107ivanov:fix/auxiliary-evict-closed-sync-client

Conversation

@alex107ivanov

@alex107ivanov alex107ivanov commented Jun 4, 2026 •

Copy link
Copy Markdown

What does this PR do?

Evicts cached auxiliary clients whose underlying sync HTTP transport is already closed before reusing them. Without this guard, a closed cached sync client can be returned from _get_cached_client, causing follow-up auxiliary calls to keep failing until process restart instead of rebuilding the provider client.

Related Issue

Related to auxiliary client cache/transport lifecycle fixes; no dedicated issue found for this exact closed-sync-cache-hit path.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added _client_is_closed() in agent/auxiliary_client.py to detect cached clients or wrapped clients whose transport exposes is_closed is True.
  • Updated _get_cached_client() to evict closed cached clients and rebuild them instead of returning them.
  • Added regression coverage in tests/agent/test_auxiliary_client.py proving a closed cached sync client is replaced with a fresh client.

How to Test

  1. PYTHONPATH=$PWD /workspace/repos/hermes-agent/.venv/bin/python -m pytest tests/agent/test_auxiliary_client.py::TestAuxiliaryClientPoisonedCacheEviction -q -o 'addopts='
  2. PYTHONPATH=$PWD /workspace/repos/hermes-agent/.venv/bin/python -m pytest tests/agent/test_auxiliary_client.py -q -o 'addopts='
  3. ln -sfn /workspace/repos/hermes-agent/.venv .venv && scripts/run_tests.sh tests/agent/test_auxiliary_client.py && rm -f .venv
  4. PYTHONPATH=$PWD /workspace/repos/hermes-agent/.venv/bin/python -m py_compile agent/auxiliary_client.py tests/agent/test_auxiliary_client.py
  5. Full scripts/run_tests.sh was attempted in this environment but timed out after 10 minutes, with failures observed in unrelated CLI/gateway systemd tests before timeout.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(auxiliary): ...)
  • I searched for existing PRs to make sure this isn't a duplicate (related poisoned-cache/transport lifecycle fixes reviewed; no duplicate closed-sync-cache-hit fix found)
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass (full suite attempted; blocked/timed out as noted above)
  • I've added tests for my changes (closed cached sync client rebuild regression coverage)
  • I've tested on my platform: Linux 5.15 container

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A, internal cache lifecycle fix with no user-facing behavior/config change
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A, no config keys changed
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A, no contributor workflow changes
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — platform-agnostic Python cache handling; no OS-specific paths/subprocesses
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A, no tool schemas changed

Screenshots / Logs

Targeted regression failed before the fix on upstream main:

FAILED tests/agent/test_auxiliary_client.py::TestAuxiliaryClientPoisonedCacheEviction::test_get_cached_client_rebuilds_closed_sync_client
AssertionError: assert closed_client is fresh_client

After the fix:

8 passed, 1 warning in 6.90s
208 passed, 1 warning in 20.96s
scripts/run_tests.sh tests/agent/test_auxiliary_client.py: 208 tests passed

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels Jun 4, 2026
@alex107ivanov
alex107ivanov force-pushed the fix/auxiliary-evict-closed-sync-client branch from 879f9c9 to e390bd2 Compare June 6, 2026 10:28
@alex107ivanov

Copy link
Copy Markdown
Author

Closing this PR as superseded by #39790. The replacement PR has been rebased onto current upstream main, force-pushed with lease, and has fresh focused validation evidence posted there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants