Skip to content

refactor(evidence): make the session-transcript context capability lazy - #7797

Merged
esengine merged 1 commit into
main-v2from
refactor/evidence-ctx-injection
Aug 7, 2026
Merged

refactor(evidence): make the session-transcript context capability lazy#7797
esengine merged 1 commit into
main-v2from
refactor/evidence-ctx-injection

Conversation

@esengine

@esengine esengine commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Part of the core cleanup series (#7786-#7796). The most-flagged architecture violation from the August review: executeOne eagerly copied the FULL session transcript (a.session.Snapshot()) into the call context on every tool execution, though only complete_step's verification fallback ever reads it — bulk data smuggled through ctx, paid for by every tool call.

What

  • evidence.WithSessionMessages now takes a func() []provider.Message instead of the materialized slice; SessionMessagesFromContext resolves it at call time. The context carries the capability (matching the package's WithLedger/WithTodoState idiom), not the data.
  • executeOne passes a.session.Snapshot as the accessor — ordinary tool calls no longer copy the transcript at all; complete_step snapshots only when it actually verifies.
  • Consumer call sites in completestep.go are unchanged.

Verification

  • gofmt clean, go vet clean on evidence/agent/tool
  • go test green for internal/evidence, internal/tool/builtin, internal/agent
  • Full go 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.

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.
@esengine
esengine requested a review from SivanCola as a code owner August 7, 2026 00:43
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development skills Skill system (internal/skill, internal/tool) agent Core agent loop (internal/agent, internal/control) labels Aug 7, 2026
@esengine
esengine merged commit 1be7027 into main-v2 Aug 7, 2026
23 checks passed
@esengine
esengine deleted the refactor/evidence-ctx-injection branch August 7, 2026 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) skills Skill system (internal/skill, internal/tool) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant