Skip to content

sessions: add get_session_context tool + list_sessions single-session lookup - #325158

Merged
Sandeep Somavarapu (sandy081) merged 1 commit into
agents/send-message-toolfrom
agents/get-session-context-tool
Jul 9, 2026
Merged

sessions: add get_session_context tool + list_sessions single-session lookup#325158
Sandeep Somavarapu (sandy081) merged 1 commit into
agents/send-message-toolfrom
agents/get-session-context-tool

Conversation

@sandy081

Copy link
Copy Markdown
Member

Overview

Follow-up in the session-management tool series (after #325051 and #325139). Adds a read-only get_session_context tool 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 before send_message. Also extends list_sessions with a single-session lookup so the two tools stay cleanly separated.

Stacked on #325139 (send_message) — get_session_context reuses that tool's link helpers. GitHub will retarget this PR's base to main once #325139 merges.

get_session_context

Reads a compacted transcript directly from live chat state (ChatState.turns + the in-progress turn). Deterministic only — no plan/todo heuristics.

Input: session (a list_sessions URI or agent-host-session:// link; a create_chat link targets that specific peer chat), detail, transcriptLimit.

detail levels (per-turn fidelity; compaction is structural, no model call, tool outputs never included):

  • summary (default): per-turn user message + short assistant reply gist + state.
  • digest: full assistant reply text + tool-call names.
  • full: + tool-call inputs (truncated).

Output: session, openLink, detail, transcript[], hasMoreHistory (from turnsNextCursor), truncated. Bounded by transcriptLimit (default 10, max 50). Cold/unsubscribed sessions return identity + empty transcript. Read-only, no confirmation.

list_sessions single-session lookup

Adds an optional session argument: 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_sessionsget_session_contextsend_message.

Notes for reviewers

  • get_session_context reads via a new IChatContextSnapshot accessor (agentService._getChatContextgetChatState/getDefaultChatState); all compaction is pure/testable in sessionServerTools.ts.
  • Plan/todo surfacing was intentionally dropped (heuristic/unreliable); a future authoritative option would be Copilot's rpc.plan.read().
  • Tests: sessionServerTools.test.ts (25) + serverToolGroups.test.ts (6). typecheck-client + valid-layers-check clean.

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>
@sandy081
Sandeep Somavarapu (sandy081) merged commit 2e82e4d into agents/send-message-tool Jul 9, 2026
6 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the agents/get-session-context-tool branch July 9, 2026 16:17
@vs-code-engineering vs-code-engineering Bot added this to the 1.129.0 milestone Jul 9, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant