hermes-agent/agent
Teknium 1cec910b6a
fix: improve context compaction to prevent model answering stale questions (#8107)
After compression, models (especially Kimi 2.5) would sometimes respond
to questions from the summary instead of the latest user message. This
happened ~30% of the time on Telegram.

Root cause: the summary's 'Next Steps' section read as active instructions,
and the SUMMARY_PREFIX didn't explicitly tell the model to ignore questions
in the summary. When the summary merged into the first tail message, there
was no clear separator between historical context and the actual user message.

Changes inspired by competitor analysis (Claude Code, OpenCode, Codex):

1. SUMMARY_PREFIX rewritten with explicit 'Do NOT answer questions from
   this summary — respond ONLY to the latest user message AFTER it'

2. Summarizer preamble (shared by both prompts) adds:
   - 'Do NOT respond to any questions' (from OpenCode's approach)
   - 'Different assistant' framing (from Codex) to create psychological
     distance between summary content and active conversation

3. New summary sections:
   - '## Resolved Questions' — tracks already-answered questions with
     their answers, preventing re-answering (from Claude Code's
     'Pending user asks' pattern)
   - '## Pending User Asks' — explicitly marks unanswered questions
   - '## Remaining Work' replaces '## Next Steps' — passive framing
     avoids reading as active instructions

4. merge-summary-into-tail path now inserts a clear separator:
   '--- END OF CONTEXT SUMMARY — respond to the message below ---'

5. Iterative update prompt now instructs: 'Move answered questions to
   Resolved Questions' to maintain the resolved/pending distinction
   across multiple compactions.
2026-04-11 19:43:58 -07:00
..
__init__.py Refactor Terminal and AIAgent cleanup 2026-02-21 22:31:43 -08:00
anthropic_adapter.py fix: align MiniMax provider with official API docs 2026-04-11 01:04:41 -07:00
auxiliary_client.py refactor(auxiliary): config.yaml takes priority over env vars for aux task settings (#7889) 2026-04-11 11:21:59 -07:00
context_compressor.py fix: improve context compaction to prevent model answering stale questions (#8107) 2026-04-11 19:43:58 -07:00
context_engine.py fix: robust context engine interface — config selection, plugin discovery, ABC completeness 2026-04-10 19:15:50 -07:00
context_references.py fix(agent): preserve quoted @file references with spaces 2026-04-10 13:05:01 -07:00
copilot_acp_client.py fix: bridge tool-calls in copilot-acp adapter 2026-04-06 01:47:57 -07:00
credential_pool.py fix(auth): make 'auth remove' for claude_code prevent re-seeding 2026-04-10 05:19:21 -07:00
display.py refactor: extract shared helpers to deduplicate repeated code patterns (#7917) 2026-04-11 13:59:52 -07:00
error_classifier.py fix: add Alibaba/DashScope rate-limit pattern to error classifier 2026-04-10 05:52:45 -07:00
insights.py fix: remove 115 verified dead code symbols across 46 production files 2026-04-10 03:44:43 -07:00
manual_compression_feedback.py fix(gateway): make manual compression feedback truthful 2026-04-10 21:16:53 -07:00
memory_manager.py fix: remove 115 verified dead code symbols across 46 production files 2026-04-10 03:44:43 -07:00
memory_provider.py refactor: codebase-wide lint cleanup — unused imports, dead code, and inefficient patterns (#5821) 2026-04-07 10:25:31 -07:00
model_metadata.py fix: use ceiling division for token estimation, deduplicate inline formula 2026-04-11 16:33:40 -07:00
models_dev.py feat(xiaomi): add Xiaomi MiMo as first-class provider 2026-04-11 11:17:52 -07:00
prompt_builder.py refactor: extract shared helpers to deduplicate repeated code patterns (#7917) 2026-04-11 13:59:52 -07:00
prompt_caching.py fix(prompt-caching): skip top-level cache_control on role:tool for OpenRouter 2026-03-21 16:54:43 -07:00
rate_limit_tracker.py fix: UTF-8 config encoding, pairing hint, credential_pool key, header normalization (#7174) 2026-04-10 05:33:48 -07:00
redact.py fix: mem0 API v2 compat, prefetch context fencing, secret redaction (#5423) 2026-04-05 22:43:33 -07:00
retry_utils.py feat(agent): add jittered retry backoff 2026-04-08 00:41:36 -07:00
skill_commands.py fix: prevent zombie processes, redact cron stderr, skip symlinks in skill enumeration 2026-04-11 02:03:20 -07:00
skill_utils.py refactor: extract shared helpers to deduplicate repeated code patterns (#7917) 2026-04-11 13:59:52 -07:00
smart_model_routing.py fix: UTF-8 config encoding, pairing hint, credential_pool key, header normalization (#7174) 2026-04-10 05:33:48 -07:00
subdirectory_hints.py fix(agent): catch PermissionError in subdirectory hint discovery 2026-04-09 03:10:30 -07:00
title_generator.py feat(agent): configurable timeouts for auxiliary LLM calls via config.yaml (#3597) 2026-03-28 14:35:28 -07:00
trajectory.py Refactor Terminal and AIAgent cleanup 2026-02-21 22:31:43 -08:00
usage_pricing.py fix: remove 115 verified dead code symbols across 46 production files 2026-04-10 03:44:43 -07:00