ECC/tests
AlbertChiu777 c7720d41bb
fix(hooks): context-monitor noise — loop-detection false positives + per-call cost-warning spam (#2486)
* fix(hooks): context-monitor noise — loop-detection false positives and per-call cost-warning spam

Two independent noise sources in the PostToolUse context monitor injected
agent-facing warnings on nearly every tool call:

1. LOOP WARNING false positives. hashToolCall() hashed only the first 160
   chars of a Bash command, so distinct long commands sharing a prefix
   (heredocs, long one-liners) collided and consecutive DIFFERENT calls
   looked like a stuck loop. Additionally LOOP_THRESHOLD=3 against a
   5-entry ring buffer fired on legitimate repetition (retries, polling).
   Fix: hash the full command (digest truncated, not the input — same
   treatment the Edit/Write branch already got), and require all 5 of the
   last 5 calls to be identical before warning.

2. COST NOTICE spam. run() deduped warnings on exact message text, but the
   cost figure embedded in the text moves on nearly every call, so once a
   session crossed $5 a 'new' COST NOTICE was injected per tool call for
   the rest of the session. Context warnings had the same defect via the
   remaining-% figure. Fix: dedupe on a stable per-tier key
   (cost:notice/warning/critical, context:warning/critical, scope) so each
   tier fires exactly once and re-fires only on genuine escalation. The
   existing ECC_CONTEXT_MONITOR_COST_WARNINGS opt-out is unchanged.

Tests: loop threshold updated (5-of-5 fires, 4-of-5 does not), long
shared-prefix Bash hash regression, and a run()-level tier-dedupe test
(notice fires once, silent on cost tick, re-emits on escalation).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: keep context warning state immutable

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: haelyra <49814733+haelyra@users.noreply.github.com>
2026-08-10 22:33:10 -04:00
..
ci fix: deliver announcements through a scoped Discord webhook (#2737) 2026-08-09 16:41:27 -04:00
commands fix(commands): generate discoverable skills from learning workflows (#2653) 2026-08-02 14:39:29 -04:00
docker feat(docker): add hardened CLI test harness (#2625) 2026-08-06 16:52:39 -04:00
docs feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
fixtures feat(docker): add hardened CLI test harness (#2625) 2026-08-06 16:52:39 -04:00
hooks fix(hooks): context-monitor noise — loop-detection false positives + per-call cost-warning spam (#2486) 2026-08-10 22:33:10 -04:00
integration refactor(hooks): consolidate PostToolUse hooks into sync/async dispatchers (#2494) 2026-07-19 15:47:10 -04:00
lib feat(session-start): rank injected instincts by project/stack relevance (#2466) 2026-08-10 21:46:24 -04:00
scripts fix(plan-canvas): deliver browser chat to the agent every time (#2739) 2026-08-09 18:15:25 -04:00
skills feat(skills): add secure terminal opener (#2650) 2026-08-06 17:24:34 -04:00
__init__.py
codex-config.test.js
codex-native-hooks.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
conftest.py docs: salvage focused stale PR contributions 2026-05-11 05:31:12 -04:00
opencode-config.test.js test(opencode): reject any namespace-scoped command agent id, not just the legacy prefix (#2477) 2026-07-10 09:58:03 +05:30
opencode-plugin-hooks.test.js fix(opencode): don't crash the whole session when plugins/lib is missing (#2538) 2026-07-28 21:37:41 -04:00
opencode-tools.test.js fix(opencode): don't crash the whole session when plugins/lib is missing (#2538) 2026-07-28 21:37:41 -04:00
plugin-manifest.test.js feat(install): add guided multi-harness installer (#2649) 2026-08-06 15:39:49 -04:00
run-all.js feat: worktree-lifecycle service (deterministic conflict prediction + safe GC) (#2164) 2026-06-07 13:00:08 +08:00
test_astraflow_provider.py feat: add Astraflow provider support 2026-05-11 23:21:46 -04:00
test_atlas_provider.py feat: add Atlas Cloud as LLM/AI provider (#2279) 2026-06-18 16:29:11 -04:00
test_builder.py fix: docs/COMMAND-REGISTRY.json check fails on fresh Windows clone (missing .gitattributes) (#2437) 2026-07-03 20:14:55 -07:00
test_claude_provider.py fix(llm/providers/claude): attach cache_control to system block, not top-level (#2515) 2026-07-17 16:04:32 -04:00
test_executor.py
test_invariant_runner.py fix: sanitize subprocess call in runner.py (#2149) 2026-06-15 13:49:45 -04:00
test_provider_tools.py fix: harden openai-compatible provider responses 2026-05-18 01:04:28 -04:00
test_resolver.py feat: add Atlas Cloud as LLM/AI provider (#2279) 2026-06-18 16:29:11 -04:00
test_selector.py feat: connect ECC to canonical Ito compute CLI (#2558) 2026-07-23 19:28:55 -07:00
test_templates.py docs: salvage focused stale PR contributions 2026-05-11 05:31:12 -04:00
test_types.py feat: add Astraflow provider support 2026-05-11 23:21:46 -04:00