feat(core): compaction-as-memory sink, <untrusted-data> injection framing, tool-description quality (narrow per #200) - #204
Merged
Conversation
…ming, tool-description quality Narrow subset of the GenAI-for-Beginners borrowings, rebuilt on upstream/main (c0a6a3c) per the scope the maintainer accepted on HKUDS#200. Nothing else from the superseded P1+P2+P3 bundle is included (no CLAUDE.md, no .gitleaksignore edits, no P2/P3 modules). - compaction-as-memory: AgentRunSpec.compaction_summary_sink field + AgentSession._make_compaction_summary_sink() deposit compaction summaries into the memory vault on a daemon thread (best-effort, never blocks the turn). New: tests/test_compaction_memory.py. - injection regression framing: memory_index() frames injected memory with an <untrusted-data> data boundary (system-reminder reserved for instructions); core/loop/injection_regression.py is the regression corpus/surface-checker module, exercised by tests/test_injection_regression.py. test_memory.py asserts the new framing. (Module's only production consumer is the excluded P1 memory_retrieval module; memory.py deliberately does not import the loop package — flagging for maintainer.) - tool-description quality: base.description_quality_issues()/sanitize_description() + McpToolAdapter applies sanitize (remote description cap 2000). New: tests/test_tool_description_quality.py. Local verification: 53 tests in the new/changed files pass; 76 upstream regression tests pass (session compaction, manual compact, agent session, mcp runtime/server, plugins). The 4 remaining failures (plugins symlink WinError 1314, two agent/mcp-server cases) reproduce identically on pristine upstream/main and are pre-existing Windows-only environment issues. ruff: no new violations versus baseline (diff is ruff 0.16 vs CI-pinned 0.15 drift). Note: emit_event() in the sink is a best-effort no-op — core/observability/events does not exist upstream. Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Sep 5, 2026
Zongwei9888
added a commit
that referenced
this pull request
Sep 6, 2026
Review repairs on top of #204: - escape closing/opening boundary and system-reminder tags inside memory content so a poisoned MEMORY.md cannot end the data boundary early or forge a reminder block, and restore the one-closing-tag assertion the PR had dropped from test_memory.py - drop core/loop/injection_regression.py: nothing in the runtime called it and memory.py carried its own copy of the constants; its two memory assertions move into test_memory.py - remove the import of the non-existent core.observability.events module from the compaction sink, make the sink a no-op without a workspace, and fix its docstring - keep the 8,000-character allowance for remote MCP tool descriptions (sanitize_description gains max_chars) instead of silently cutting to 2,000
Zongwei9888
added a commit
that referenced
this pull request
Sep 6, 2026
…ming, tool-description quality
Collaborator
|
Merged today as bf52080 ("Merge repaired PR #204") with your commit intact. The repair commit on top (803690b) does four things worth knowing about:
Two follow-ups that would each make a good small PR if you are interested: pass a real Thanks for the narrow resubmission; it is exactly the shape that makes review fast. |
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.
TL;DR
Narrow resubmission addressing the scope feedback on #200: only the three pieces you called out, rebased on current
main(c0a6a3c), nothing outside their own files. No CLAUDE.md, no .gitleaksignore edits, no P2/P3 modules.Summary
Three independent, merge-order-independent changes:
1. Compaction-as-memory (
compaction_summary_sink)AgentRunSpec.compaction_summary_sinkfield +AgentSession._make_compaction_summary_sink(): compacted sessions deposit their summary into the memory vault on a daemon thread (best-effort, never blocks the turn; both the manual/compactand auto-compaction paths pass the sink).tests/test_compaction_memory.pycore/agent_runtime/runner.py,core/events/session.py,core/harness/memory.py(compaction writer block)2. Injection-regression framing (
<untrusted-data>)memory_index()now frames injected memory content with an<untrusted-data>data boundary, keeping<system-reminder>reserved for instructions.core/loop/injection_regression.pyis the regression corpus/surface-checker module (pure, stdlib-only).tests/test_injection_regression.py,core/loop/injection_regression.pytests/test_memory.py(asserts the new framing)core/harness/memory.pymemory_retrievalmodule;memory.pydeliberately does not import the loop package (layering), so the module is exercised by its regression tests. If you prefer a real runtime call site I can wire it — flagging rather than guessing.3. Tool-description quality checks
base.description_quality_issues()/sanitize_description()static quality checks;McpToolAdapternow appliessanitize_description(remote MCP description cap 2000).tests/test_tool_description_quality.pycore/agent_runtime/tools/base.py,core/mcp/tools.pyTest Plan
Local (CPython 3.14, editable install):
Dependency note
Merge-order independent of sibling splits #188/#189.
emit_event()inside the sink is a best-effort no-op —core/observability/eventsdoes not exist upstream.Related
Closes the intent behind the #200 closure feedback (narrowed to the accepted scope).