Skip to content

fix(agent): avoid Codex stream for compression summaries - #23617

Closed
groksrc wants to merge 1 commit into
NousResearch:mainfrom
groksrc:fix/codex-compression-timeout
Closed

fix(agent): avoid Codex stream for compression summaries#23617
groksrc wants to merge 1 commit into
NousResearch:mainfrom
groksrc:fix/codex-compression-timeout

Conversation

@groksrc

@groksrc groksrc commented May 11, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes a compression-summary failure mode for sessions whose main provider is Codex. Compression uses the text auxiliary auto provider path; with Codex as the main provider, auto was main-first and routed compression through the Codex Responses stream. If that stream stays alive but emits too slowly, compression can exceed its total timeout and fall back to a context marker instead of a summary.

This PR keeps the existing main-model-first behavior for normal auxiliary tasks, but adds a targeted exception for task == "compression" on Codex main sessions: try the faster auxiliary fallback chain first, then fall back to Codex if no auxiliary backend is available. It also makes auto client caching task-aware only when a task is supplied, so compression and non-compression routes do not reuse the wrong cached client.

While validating the timeout path, this also tightens Codex stream total-timeout enforcement so blocking/slow stream iteration can be interrupted by the configured total timeout and still evicts the poisoned cached client.

Related Issue

No issue filed yet.

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

  • agent/auxiliary_client.py
    • Thread task through auxiliary provider resolution and cached-client construction.
    • Preserve explicit auxiliary provider overrides as highest priority.
    • Preserve main-first auto routing for non-compression tasks.
    • Prefer the non-Codex auxiliary fallback chain for compression when the main provider is Codex, with Codex fallback if no aux backend is available.
    • Keep cache keys task-aware only for provider == "auto" with a supplied task.
    • Enforce Codex auxiliary Responses stream total timeout even when stream iteration blocks between events.
  • tests/agent/test_auxiliary_main_first.py
    • Add regression coverage for the Codex/compression routing exception and non-compression main-first behavior.
  • tests/agent/test_auxiliary_client.py
    • Stabilize and cover Codex total timeout behavior while the stream keeps emitting slow progress events.

How to Test

  1. Configure Hermes with Codex as the main provider and a faster auxiliary backend available (for example OpenRouter/Nous).
  2. Trigger context compression, or call the text auxiliary path with task="compression" and provider="auto".
  3. Verify compression chooses the auxiliary fallback chain before Codex, while a non-compression task such as session_search still resolves to the Codex main provider.

Automated checks run locally on macOS 15.7.2:

python scripts/check-windows-footguns.py --diff HEAD~1
python -m pytest tests/agent/test_auxiliary_main_first.py tests/agent/test_auxiliary_client.py tests/run_agent/test_provider_parity.py::TestAuxiliaryClientProviderPriority tests/run_agent/test_async_httpx_del_neuter.py tests/run_agent/test_compression_feasibility.py -q -o 'addopts='
scripts/run_tests.sh tests/agent/test_auxiliary_main_first.py tests/agent/test_auxiliary_client.py tests/run_agent/test_provider_parity.py::TestAuxiliaryClientProviderPriority tests/run_agent/test_async_httpx_del_neuter.py tests/run_agent/test_compression_feasibility.py

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15.7.2

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Targeted CI-parity subset:

201 passed in 3.05s

Note: scripts/run_tests.sh without arguments currently exits early with ARGS[@]: unbound variable on this checkout. Running the full suite as scripts/run_tests.sh tests/ executed but failed broadly outside this change area in this local environment; the focused affected suites above pass under the wrapper.

@groksrc

groksrc commented May 11, 2026

Copy link
Copy Markdown
Author

Small follow-up on the scripts/run_tests.sh no-args note from the PR body: I checked this against current main, and the failure is pre-existing there as well, not introduced by this PR.

Root cause appears to be macOS Bash 3.2 + set -u expanding an empty array:

ARGS=("$@")
...
"${ARGS[@]}"

With no args, Bash 3.2 reports ARGS[@]: unbound variable. The targeted wrapper runs with explicit test paths still pass. I’m leaving the no-args wrapper issue out of this PR since it’s unrelated to the compression routing fix.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/copilot GitHub Copilot (ACP + Chat) P2 Medium — degraded but workaround exists labels May 11, 2026
@teknium1

teknium1 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closing — the compression-timeout problem this addressed was fixed via PR #59807 (salvage of #54943), which floors config-derived compression timeouts at 300s instead of rerouting away from the Codex stream. That approach keeps compression on the main model per the current auxiliary main-model-first design while honoring explicit per-call timeouts. Thanks for the early work on this — it correctly identified the failure mode.

@teknium1 teknium1 closed this Jul 6, 2026
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 provider/copilot GitHub Copilot (ACP + Chat) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants