Repository navigation
fix(agent): strip loop-control notes echoed into user-visible answers - #383
Merged
Merged
Conversation
Text-only models echo context verbatim: live probing saw [sidekick-control] + the seeded text-only notice inside a fenced plan-test.txt hallucination. _strip_control_leak removes the tag and exact instruction sentences from every user-facing return (OpenAI + Anthropic paths, residue/peek/exhaustion); in-loop messages keep them. Intentional errors pass through untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Live probing on llama3.2:3b showed the seeded text-only notice plus [sidekick-control] echoed verbatim into answers (fenced plan-test.txt hallucination). Small models repeat context; control sentences in answers read as product behavior.
Change: _strip_control_leak (tag + exact instruction sentences) applied to every user-facing return in run_agent (final/peek/exhaustion/residue) and both anthropic_backend text returns. In-loop messages untouched. Intentional errors (residue failure, recap, denials) contain none of these fragments.
Tests: 2 new in tests/test_eval.py (unit + stubbed run_agent echo). Gates: 122 passed (eval/reasoning-leak/residue/budgets/anthropic/verify), ruff + format + mypy clean.