feat(agent): add bounded auto and cold fast modes - #64786
Conversation
|
@copilot review Please review the latest head, with particular attention to turn-boundary timing, provider-specific request overrides, prompt-cache stability, and CLI/gateway/TUI state propagation. |
|
@copilot review Please review the current integrated head (48f707d), especially logical-session cold eligibility, dispatch-time expiry after middleware, Anthropic fast beta preservation, and CLI/gateway/TUI state transitions. |
|
@copilot review Please review current head f6e4c1d. In addition to the bounded auto/cold policy, this head corrects the touched TUI test mock so browser-connect retry coverage cannot launch a real Chrome process. Please focus on session eligibility, dispatch-time expiry, provider metadata preservation, and test isolation. |
|
Thanks for the careful cross-surface implementation and the explicit prompt-cache constraints. Problems
Suggested changes
Automated hermes-sweeper review. |
|
Addressed the Hermes Sweeper finding in
@copilot review Please review current head |
Resolve the /fast handler conflict by integrating the bounded auto/cold service tiers (this PR) with main's new interactive fast/normal choice picker. Typed `/fast auto` and `/fast cold` now route through the extended _apply_fast_selection helper and are reflected in the 4-way status line; the interactive picker keeps the fast/normal quick-toggle (auto/cold stay typed-only, so no new choice_* i18n keys are required). Config writes go through main's _save_gateway_config_key (the local _save_config_key closure is dropped). Also mirror the auto/cold fast-mode i18n keys (label_auto, label_cold, status_auto, status_cold) across all non-en locales so the catalog parity test (tests/agent/test_i18n.py::test_catalog_keys_match_english) passes — they were previously only added to en.yaml.
|
Superseded by #74730, which ports the bounded auto/cold policy onto current main and covers the current Relay, summary, gateway, TUI, and Desktop paths. The replacement is at exact head |
What does this PR do?
Adds bounded
autoandcoldpolicies to Hermes's existing fast mode.normalcoldautofastThe opening window defaults to 60 seconds and is configurable with
agent.fast_auto_on_seconds. Later tool-loop calls, retries, continuations,and fallback calls start in normal mode after the window expires.
coldis based on prior logical-session transcript activity, not processuptime. A fresh process resuming a persisted session therefore does not receive
another cold window. System-only setup history still counts as a first turn;
prior user, assistant, or tool activity does not.
The policy is resolved at the model-request boundary using an ephemeral copy of
request_overrides. It does not mutate conversation messages, system prompts,tool schemas, or persisted overrides, preserving prompt-cache inputs.
Existing
normalandfastbehavior is unchanged.How it works
flowchart LR A["User turn enters"] --> B{"Configured /fast mode"} B -->|normal| N["No fast metadata"] B -->|fast| F["Fast on every request"] B -->|auto| W["Open a turn-local window"] B -->|cold| C{"Prior logical-session activity?"} C -->|Yes| N C -->|No| W W --> I["Resolve request policy at ingress"] I --> H["Build request, middleware, and hooks"] H --> R{"Still inside cutoff at dispatch?"} R -->|Yes| P["Apply provider fast metadata"] R -->|No| S["Strip fast-only metadata"] F --> P N --> D["Dispatch model request"] P --> D S --> D D --> T{"Tool call, retry, or summary?"} T -->|Yes| I T -->|No| O["Return response"] classDef decision fill:#fff4cc,stroke:#a16207,color:#422006,stroke-width:2px; classDef fast fill:#dcfce7,stroke:#15803d,color:#052e16,stroke-width:2px; classDef normal fill:#f1f5f9,stroke:#64748b,color:#0f172a; classDef lifecycle fill:#e0f2fe,stroke:#0369a1,color:#082f49; classDef output fill:#ede9fe,stroke:#7c3aed,color:#2e1065,stroke-width:2px; class B,C,R,T decision; class F,W,P fast; class N,S normal; class A,I,H,D lifecycle; class O output;coldderives eligibility from the persisted logical-session transcript.Explicitly empty or system-only history is eligible; prior user, assistant,
or tool activity is not.
TLDR- auto but only if cold so fast warmup.
autoopens the same bounded window for every user turn. This concentratesfast-tier spend on the user-visible opening, where latency is felt most,
without applying it indefinitely to long tool loops.
TLDR - User sends message > agent processing initial response is in fast mode and by the time it is finished and sent to user before tool callings, fast mode is turned back off for that turn and until all tool calls and final response is sent from agent (ie rapid initial response but not expensive "fast" mode turn).
provider dispatch. Slow middleware or hooks cannot accidentally carry an
expired fast decision into the network call.
prompts, tool schemas, and persisted overrides remain stable for prompt
caching.
Related Issue
Fixes #64785
Type of Change
Changes Made
and preflight work consume the same window as provider requests.
and later tool-loop calls.
construction so an expired window cannot retain
service_tier=priority.auto,cold, andfast_auto_on_secondsthroughAIAgent, CLI,messaging gateway, TUI/desktop construction, reuse, resume, and config paths.
/fast autoand/fast coldselection, persistence, status, commandmetadata, and English fallback messaging.
system-only and partial transcripts, cutoff timing, OpenAI/Anthropic request
overrides, unsupported models, override preservation, and CLI/gateway/TUI
persistence/readback.
subprocess.Popenguard so a failing test cannot open a real Chrome window.How to Test
Expected: 953 tests pass.
ruff check . python3 scripts/check-windows-footguns.py --all git diff --checkExpected: all checks pass.
Manual examples:
/fast statusshould report the selected policy. Forcold, starting a newlogical session opens one bounded fast window; resuming an existing session
does not.
Checklist
Code
Documentation & Housekeeping
cli-config.yaml.exampleand the dashboard config schemaCONTRIBUTING.md/AGENTS.mdchanges are N/Atime.monotonic()and introduces no OS-specific I/O or process behaviorValidation