Skip to content

Ability to open sub-agent sessions in chat#1466

Open
dobesv wants to merge 2 commits intokagent-dev:mainfrom
dobesv:sub-agent-session-view
Open

Ability to open sub-agent sessions in chat#1466
dobesv wants to merge 2 commits intokagent-dev:mainfrom
dobesv:sub-agent-session-view

Conversation

@dobesv
Copy link
Contributor

@dobesv dobesv commented Mar 9, 2026

When viewing a chat session with sub-agent calls, a new "open in tab" icon button will show.

Clicking the button looks up the session ID of the sub-agent session and opens it in a new tab.

To support this:

  • the python agent was updated to propagate the parent user ID, session ID, and tool call ID into the child task information as metadata field kagent_user_id, kagent_caller_session_id, and kagent_caller_tool_call_id
  • parent user_id is also used in child session so that the user has permission to see those sessions
  • an endpoint was added to the go server to lookup a child session ID by finding the task with the matching parent session ID and tool call and using the session ID from that task to identify the session

A side-effect of this change is that if you click an agent you can now see the sub-agent sessions listed there as if they were your own chats. Personally I prefer it, but if this is a problem we could look for a way to hide those, maybe filter out sub-agent sessions on that list based on the metadata fields we use to find sub-agent sessions.

Signed-off-by: Dobes Vandermeer dobes.vandermeer@newsela.com

Copilot AI review requested due to automatic review settings March 9, 2026 20:39
@dobesv dobesv force-pushed the sub-agent-session-view branch 2 times, most recently from a261d04 to 115b9c0 Compare March 9, 2026 20:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds end-to-end support for opening sub-agent chat sessions from a parent chat by correlating agent tool calls to the spawned child session, using propagated metadata and a new backend lookup endpoint.

Changes:

  • UI: Passes parent sessionId down to agent tool call rendering and adds an “open in tab” button that looks up and opens the sub-agent session.
  • Python (kagent-adk/core): Propagates caller metadata (session/tool-call identifiers + user identity) across A2A boundaries and injects it into child task metadata via a new plugin + request metadata provider.
  • Go (core): Adds GET /sessions/{session_id}/subagentsessions/{tool_call_id} and database lookup logic to resolve a child session ID from task metadata; includes tests.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
ui/src/components/chat/ToolCallDisplay.tsx Threads sessionId into AgentCallDisplay.
ui/src/components/chat/ChatMessage.tsx Adds sessionId prop and passes it to tool-call rendering.
ui/src/components/chat/ChatInterface.tsx Provides the active session id down to message rendering.
ui/src/components/chat/AgentCallDisplay.tsx Adds “open in tab” button that fetches sub-agent session ID and opens it.
ui/src/app/actions/sessions.ts Adds getSubAgentSession action calling the new backend endpoint.
python/packages/kagent-core/src/kagent/core/a2a/_consts.py Introduces constants for caller metadata keys/prefix.
python/packages/kagent-core/src/kagent/core/a2a/init.py Exposes new caller metadata constants via module imports.
python/packages/kagent-adk/src/kagent/adk/types.py Adds A2A request metadata provider and wires it into RemoteA2aAgent.
python/packages/kagent-adk/src/kagent/adk/converters/event_converter.py Includes kagent_* state metadata in emitted event metadata.
python/packages/kagent-adk/src/kagent/adk/_agent_executor.py Applies propagated user_id and persists kagent_* metadata into task metadata.
python/packages/kagent-adk/src/kagent/adk/_session_linking_plugin.py New plugin that injects parent session/tool-call metadata into session state before AgentTool runs.
python/packages/kagent-adk/src/kagent/adk/cli.py Registers SessionLinkingPlugin alongside STS integration.
python/packages/kagent-adk/tests/unittests/converters/test_event_converter.py Updates mock invocation context to include session.state.
go/core/internal/httpserver/server.go Registers new sub-agent session lookup route.
go/core/internal/httpserver/handlers/sessions.go Adds handler to resolve child session and return session info.
go/core/internal/httpserver/handlers/sessions_test.go Adds handler tests for the new endpoint.
go/api/database/client.go Extends DB client interface with GetSubAgentSession.
go/core/internal/database/client.go Implements DB query to find child session via task metadata.
go/core/internal/database/fake/client.go Implements in-memory GetSubAgentSession for handler tests.
go/core/internal/database/client_test.go Adds DB-level test for GetSubAgentSession.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dobesv dobesv force-pushed the sub-agent-session-view branch 3 times, most recently from 44f0858 to 0013634 Compare March 9, 2026 22:06
When viewing a chat session with sub-agent calls, a new "open in tab" icon button will show.

Clicking the button looks up the session ID of the sub-agent session and opens it in a new tab.

To support this:

- the python agent was updated to propagate the parent session ID and tool call ID into the child task information as metadata field `kagent_caller_session_id` and `kagent_caller_tool_call_id`
- an endpoint was added to the go server to lookup a child session ID by finding the task with the matching parent session ID and tool call and using the session ID from that task to identify the session

Signed-off-by: Dobes Vandermeer <dobes.vandermeer@newsela.com>
@dobesv dobesv force-pushed the sub-agent-session-view branch from 0013634 to fdb0e35 Compare March 9, 2026 22:47
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.

3 participants