sessions: add get_session_context tool + list_sessions single-session lookup - #325158
Merged
Sandeep Somavarapu (sandy081) merged 1 commit intoJul 9, 2026
Conversation
Adds a read-only get_session_context server tool that returns a compacted transcript of an existing session/chat's recent turns, read directly from live chat state. Three fidelity levels: summary (per-turn message + short reply gist), digest (full reply text + tool-call names), full (+ tool-call inputs); bounded by transcriptLimit (default 10, max 50) with hasMoreHistory/truncated flags and the in-progress turn included. Deterministic only, no plan/todo heuristics. Targets a session's default chat, or a specific peer chat via a create_chat open link. Also extends list_sessions with an optional session argument for a direct single-session lookup by URI / open link (bypassing the other filters), so session metadata stays with list_sessions while get_session_context focuses purely on conversation data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sandeep Somavarapu (sandy081)
merged commit Jul 9, 2026
2e82e4d
into
agents/send-message-tool
6 checks passed
Sandeep Somavarapu (sandy081)
added a commit
that referenced
this pull request
Jul 9, 2026
* Add send_message server tool Adds a send_message tool that starts a new turn on an existing session or chat, reusing the same startPrompt path create_session/create_chat use to deliver their first message. Accepts a list_sessions URI or an agent-host-session:// link; a create_chat link (with ?chat=) targets that specific peer chat, otherwise the session's default chat. Requires confirmation, refuses messaging the current chat channel (self-loop guard), and has a process-wide fan-out backstop. Renders the same 'Open Session' pill (conversation icon when chat-scoped) and is unpinned from the thinking group like the other session tools. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add isSendMessageTool unit test for prefix matching Addresses PR review: cover the bare and mcp__server__-prefixed name paths for isSendMessageTool, mirroring the existing isCreateSessionTool/isCreateChatTool tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * sessions: add get_session_context tool + list_sessions single-session lookup (#325158) Add get_session_context tool and list_sessions single-session lookup Adds a read-only get_session_context server tool that returns a compacted transcript of an existing session/chat's recent turns, read directly from live chat state. Three fidelity levels: summary (per-turn message + short reply gist), digest (full reply text + tool-call names), full (+ tool-call inputs); bounded by transcriptLimit (default 10, max 50) with hasMoreHistory/truncated flags and the in-progress turn included. Deterministic only, no plan/todo heuristics. Targets a session's default chat, or a specific peer chat via a create_chat open link. Also extends list_sessions with an optional session argument for a direct single-session lookup by URI / open link (bypassing the other filters), so session metadata stays with list_sessions while get_session_context focuses purely on conversation data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Overview
Follow-up in the session-management tool series (after #325051 and #325139). Adds a read-only
get_session_contexttool so an agent can inspect an existing session/chat's recent conversation — e.g. to see what a session it created is doing, or to gather context beforesend_message. Also extendslist_sessionswith a single-session lookup so the two tools stay cleanly separated.get_session_contextReads a compacted transcript directly from live chat state (
ChatState.turns+ the in-progress turn). Deterministic only — no plan/todo heuristics.Input:
session(alist_sessionsURI oragent-host-session://link; acreate_chatlink targets that specific peer chat),detail,transcriptLimit.detaillevels (per-turn fidelity; compaction is structural, no model call, tool outputs never included):summary(default): per-turnusermessage + shortassistantreply gist +state.digest: full assistant reply text + tool-call names.full: + tool-call inputs (truncated).Output:
session,openLink,detail,transcript[],hasMoreHistory(fromturnsNextCursor),truncated. Bounded bytranscriptLimit(default 10, max 50). Cold/unsubscribed sessions return identity + empty transcript. Read-only, no confirmation.list_sessionssingle-session lookupAdds an optional
sessionargument: a direct lookup returning just that one session's metadata by URI / open link, bypassing the other filters (including the default archived exclusion).Clean separation
list_sessions→ session metadata (breadth, or one session by URI).get_session_context→ one session's conversation (depth).No overlapping surface; flow is
list_sessions→get_session_context→send_message.Notes for reviewers
get_session_contextreads via a newIChatContextSnapshotaccessor (agentService._getChatContext→getChatState/getDefaultChatState); all compaction is pure/testable insessionServerTools.ts.rpc.plan.read().sessionServerTools.test.ts(25) +serverToolGroups.test.ts(6).typecheck-client+valid-layers-checkclean.