Skip to content

fix(cost): block Codex GPT-5.5 auxiliary drain#48603

Open
stavmatis wants to merge 7 commits into
NousResearch:mainfrom
stavmatis:token-drain-fix-20260616
Open

fix(cost): block Codex GPT-5.5 auxiliary drain#48603
stavmatis wants to merge 7 commits into
NousResearch:mainfrom
stavmatis:token-drain-fix-20260616

Conversation

@stavmatis

@stavmatis stavmatis commented Jun 18, 2026

Copy link
Copy Markdown

Summary

  • stop replaying Codex GPT-5.5 encrypted reasoning blobs by default on the openai-codex path
  • add gateway Codex budget tripwires plus a Telegram foreground per-turn cap so low-visible loops cannot burn 90 API calls before hygiene re-checks usage
  • make explicitly configured Codex GPT-5.5 high-cost auxiliary tasks fail closed unless task-scoped opt-in is set, instead of silently falling through to unrelated auto providers
  • let high fresh-input pressure run gateway auto-compression once, while keeping low-visible/high-API sessions as hard stops

Evidence

Local state.db shows the regression starting Jun 14, immediately after Codex reasoning replay preservation:

Day API calls Accounted tokens Fresh input share Cache read
2026-06-11 650 81,995,519 4.7% 77,825,024
2026-06-12 700 93,178,493 5.8% 87,398,400
2026-06-13 1,008 118,814,466 4.5% 113,024,512
2026-06-14 1,079 123,003,211 46.8% 64,921,600
2026-06-15 1,965 220,674,635 62.6% 81,614,336
2026-06-18 1,162 108,312,428 69.9% 31,781,376

Relevant commits:

  • 069bfd654 fix(agent): keep Codex reasoning replay on Codex path — regression trigger candidate
  • c89b907ee fix(codex): stop replaying gpt55 reasoning blobs by default — cache-stability fix
  • this branch adds the gateway/auxiliary guardrails around that root fix

Tests

  • ./venv/bin/python -m pytest tests/agent/test_auxiliary_client.py tests/agent/test_codex_reasoning_replay_defaults.py tests/gateway/test_session_hygiene.py → 267 passed
  • ./venv/bin/python -m py_compile agent/auxiliary_client.py agent/context_compressor.py agent/agent_init.py gateway/run.py hermes_cli/config.py

Risk / rollback

  • Risk is limited to Codex GPT-5.5 high-cost auxiliary routing and gateway safety caps.
  • Operators can re-enable Codex reasoning replay via agent.codex_reasoning_replay_enabled: true or codex.reasoning_replay_enabled: true.
  • Operators can override gateway cap with gateway.codex_budget.max_turns or disable platform budgeting.

@alt-glitch alt-glitch added type/security Security vulnerability or hardening comp/agent Core agent loop, run_agent.py, prompt builder comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard platform/telegram Telegram bot adapter provider/openai OpenAI / Codex Responses API P1 High — major feature broken, no workaround labels Jun 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Triage note: this PR bundles two distinct concerns from the Jun 14 usage-drain incident branch (1546 additions across 21 files). Primary (matches the title): the _CODEX_HIGH_COST_AUX_TASKS circuit breaker in agent/auxiliary_client.py plus gateway session-hygiene budget breakers that block high-cost auxiliary tasks from openai-codex/gpt-5.5. Secondary and unrelated to cost: a new detect_outbound_email_send() consent guardrail in tools/approval.py making outbound email approval-critical even under /yolo or approvals.mode=off. Labeled type/security for the highest-severity facet (approval-bypass enforcement). Reviewers may want to split the email-consent guardrail out for independent review.

@stavmatis stavmatis force-pushed the token-drain-fix-20260616 branch from b654b8f to 3cea3a7 Compare June 18, 2026 20:14
@egilewski

Copy link
Copy Markdown
Contributor

merge conflicts

This PR does not merge cleanly with the base branch. Please rebase or merge current main and resolve the conflicts if it's still relevant.

Signed: GPT-5.5-low in Codex

@egilewski

Copy link
Copy Markdown
Contributor

merge conflicts

This PR still does not merge cleanly with current main after the latest push. I confirmed the conflict with:

git merge-tree --write-tree refs/remotes/origin/main refs/remotes/origin/pr/48603

Conflicting files reported by Git are agent/auxiliary_client.py, gateway/run.py, hermes_state.py, tests/run_agent/test_background_review.py, and tools/approval.py. Please rebase or merge current main and resolve those conflicts before detailed security review can continue.

Signed: GPT-5.5-medium in Codex

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

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround platform/telegram Telegram bot adapter provider/openai OpenAI / Codex Responses API type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants