hermes-agent/agent
teknium1 c886333d32 feat: smart context length probing with persistent caching + banner display
Replaces the unsafe 128K fallback for unknown models with a descending
probe strategy (2M → 1M → 512K → 200K → 128K → 64K → 32K). When a
context-length error occurs, the agent steps down tiers and retries.
The discovered limit is cached per model+provider combo in
~/.hermes/context_length_cache.yaml so subsequent sessions skip probing.

Also parses API error messages to extract the actual context limit
(e.g. 'maximum context length is 32768 tokens') for instant resolution.

The CLI banner now displays the context window size next to the model
name (e.g. 'claude-opus-4 · 200K context · Nous Research').

Changes:
- agent/model_metadata.py: CONTEXT_PROBE_TIERS, persistent cache
  (save/load/get), parse_context_limit_from_error(), get_next_probe_tier()
- agent/context_compressor.py: accepts base_url, passes to metadata
- run_agent.py: step-down logic in context error handler, caches on success
- cli.py + hermes_cli/banner.py: context length in welcome banner
- tests: 22 new tests for probing, parsing, and caching

Addresses #132. PR #319's approach (8K default) rejected — too conservative.
2026-03-05 16:09:57 -08:00
..
__init__.py Refactor Terminal and AIAgent cleanup 2026-02-21 22:31:43 -08:00
auxiliary_client.py fix: handle None message content across codebase (fixes #276) 2026-03-02 02:23:53 -08:00
context_compressor.py feat: smart context length probing with persistent caching + banner display 2026-03-05 16:09:57 -08:00
display.py feat: show detailed tool call args in gateway based on config 2026-03-02 05:23:15 -08:00
model_metadata.py feat: smart context length probing with persistent caching + banner display 2026-03-05 16:09:57 -08:00
prompt_builder.py Merge PR #292: feat(whatsapp): native media attachments for images, videos and documents 2026-03-05 08:35:13 -08:00
prompt_caching.py Refactor Terminal and AIAgent cleanup 2026-02-21 22:31:43 -08:00
redact.py refactor(cli, auth): Add Codex/OpenAI OAuth Support - finalized 2026-02-28 21:56:27 -08:00
skill_commands.py fix: use Path.parts for hidden directory filter in skill listing 2026-03-04 18:34:16 +03:00
trajectory.py Refactor Terminal and AIAgent cleanup 2026-02-21 22:31:43 -08:00