Spill cleared tool results to disk and pin the cache-stability contract (N2 WP1) #25

Merged
weichen merged 1 commits from feature/n2-context-wp1 into main 2026-10-07 13:05:02 +00:00
Owner

Why: the completion doc N2 requires old tool results to become file paths (ZCode compact pattern) and cache-friendly prefix rules; today the micro-compactor only left a transcript pointer, nothing pinned prefix stability, and alignToolTail had no direct edge tests.

What:

  • session.ClearOldToolResultsTo: spill cleared results to /.txt with a path placeholder; write failure or empty dir falls back to the legacy transcript pointer byte-identically.
  • loop Config.ResultsDir plumbed; the native adapter wires it to /.agentx/results.
  • Direct alignToolTail edge tests (multi-call assistant tail, boundary, all-tool degenerate).
  • Cache-stability contract test: identical build sequence → byte-identical system text; direct tools in registration order; deferred tools excluded; meta-tools present.

Evidence: GOWORK=off go vet + go test -count=1 ./... green; legacy behavior pinned by TestClearOldToolResultsEmptyDirKeepsLegacyPlaceholder.

Impact: opt-in via ResultsDir; no behavior change for hosts that do not set it.

Refs: Agent-System-Documents#42 (N2 plan WP1)

Why: the completion doc N2 requires old tool results to become file paths (ZCode compact pattern) and cache-friendly prefix rules; today the micro-compactor only left a transcript pointer, nothing pinned prefix stability, and alignToolTail had no direct edge tests. What: - session.ClearOldToolResultsTo: spill cleared results to <dir>/<toolCallID>.txt with a path placeholder; write failure or empty dir falls back to the legacy transcript pointer byte-identically. - loop Config.ResultsDir plumbed; the native adapter wires it to <workDir>/.agentx/results. - Direct alignToolTail edge tests (multi-call assistant tail, boundary, all-tool degenerate). - Cache-stability contract test: identical build sequence → byte-identical system text; direct tools in registration order; deferred tools excluded; meta-tools present. Evidence: GOWORK=off go vet + go test -count=1 ./... green; legacy behavior pinned by TestClearOldToolResultsEmptyDirKeepsLegacyPlaceholder. Impact: opt-in via ResultsDir; no behavior change for hosts that do not set it. Refs: Agent-System-Documents#42 (N2 plan WP1)
weichen added 1 commit 2026-10-07 12:59:19 +00:00
Spill cleared tool results to disk and pin the cache-stability contract (N2 WP1)
ci / vet-and-test (pull_request) Successful in 52s
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
ae42c9402d
Why: the completion doc's N2 requires old tool results to become file
paths (ZCode compact pattern) and cache-friendly prefix rules; today the
micro-compactor only left a transcript pointer and nothing pinned prefix
stability. alignToolTail had no direct edge tests.
Evidence: GOWORK=off go vet + go test -count=1 ./... green; new
TestClearOldToolResultsSpillsToDisk / TestSpillResultSanitizesCallID /
TestAlignToolTailEdges / TestSystemTextDeterministicAcrossIdenticalBuilds;
legacy placeholder bytes unchanged when ResultsDir is empty
(TestClearOldToolResultsEmptyDirKeepsLegacyPlaceholder).
Impact: opt-in via Config.ResultsDir; the native adapter wires it to
<workDir>/.agentx/results. No behavior change for other hosts.
Refs: 2026-10-07-agent-stack-n2-plan WP1
weichen merged commit 64b8bd4c98 into main 2026-10-07 13:05:02 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-Native#25