refactor(evidence): make the session-transcript context capability lazy - #7797
Merged
Conversation
Every tool execution eagerly copied the full session transcript (a.session.Snapshot()) into the call context, though only complete_step ever reads it. WithSessionMessages now carries a snapshot function; the copy happens when SessionMessagesFromContext is resolved, so ordinary tool calls pay nothing and the context carries a capability rather than bulk data.
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.
Part of the core cleanup series (#7786-#7796). The most-flagged architecture violation from the August review:
executeOneeagerly copied the FULL session transcript (a.session.Snapshot()) into the call context on every tool execution, though onlycomplete_step's verification fallback ever reads it — bulk data smuggled through ctx, paid for by every tool call.What
evidence.WithSessionMessagesnow takes afunc() []provider.Messageinstead of the materialized slice;SessionMessagesFromContextresolves it at call time. The context carries the capability (matching the package's WithLedger/WithTodoState idiom), not the data.executeOnepassesa.session.Snapshotas the accessor — ordinary tool calls no longer copy the transcript at all;complete_stepsnapshots only when it actually verifies.Verification
gofmtclean,go vetclean on evidence/agent/toolgo testgreen for internal/evidence, internal/tool/builtin, internal/agentgo test ./...green (English locale)Cache-impact: none - host-side tool-context plumbing; no provider request or cache logic involved.
Cache-guard: existing coverage - completestep verification tests pass unchanged.
Documentation-impact: none - internal mechanism; complete_step behavior is identical.