feat(session_context): reference previous sessions as context#3320
Merged
Conversation
…context Add a read-only session_context toolset with two tools: - list_sessions: list previous sessions (most recent first; the current session is never included) - read_session: return a previous session's transcript by id or by a relative reference like -1, truncated from the oldest messages to fit the context budget This removes the manual export-to-HTML and re-attach workaround for reusing earlier sessions as context. The toolset is wired like session_plan: it advertises tool metadata only, and the runtime owns the handlers so they can reach the live session store and exclude the running session. Only the latest config schema is updated; older versions stay frozen. Refs #1675
- use t.Context() instead of context.Background() in the test - iterate with slices.Backward when trimming the transcript to budget
dgageot
approved these changes
Jun 30, 2026
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.
Summary
Adds a read-only
session_contexttoolset that lets an agent reference a previous session as context, removing the manual export-to-HTML and re-attach workaround described in #1675.Two tools:
list_sessionslimit(default 20, capped at 100).read_session-1. Returns an error for the current session or an unresolved/missing one.Long transcripts are truncated from the oldest messages (the most recent are usually the most useful for continuing work), with a note recording how many were omitted, so a large history cannot overflow the context window.
Issue expectations mapping
read_sessionlist_sessionsDesign notes
session_plantoolset: the toolset advertises tool metadata only, and the runtime owns the handlers (pkg/runtime/sessioncontext_handlers.go) so they can reach the live session store and exclude the running session.agent-schema.json, both toolset-type enums). Olderpkg/config/vNversions stay frozen.session.Store(GetSessionSummaries,GetSession) andsession.ResolveSessionID(relative refs).Open design questions for maintainers
@sessionmention syntax in the editor. This PR takes the tool route as it is less invasive and agent-driven.Tests / verification
pkg/tools/builtin/sessioncontextgo vet/gofmton new filestask build/task test/task lintFiles: new
sessioncontexttoolset package and runtime handlers, registry + schema wiring, an example (examples/session_context.yaml), and docs.Refs #1675