Ability to open sub-agent sessions in chat#1466
Open
dobesv wants to merge 2 commits intokagent-dev:mainfrom
Open
Ability to open sub-agent sessions in chat#1466dobesv wants to merge 2 commits intokagent-dev:mainfrom
dobesv wants to merge 2 commits intokagent-dev:mainfrom
Conversation
a261d04 to
115b9c0
Compare
Contributor
There was a problem hiding this comment.
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
sessionIddown 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.
python/packages/kagent-adk/src/kagent/adk/_session_linking_plugin.py
Outdated
Show resolved
Hide resolved
44f0858 to
0013634
Compare
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>
0013634 to
fdb0e35
Compare
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.
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:
kagent_user_id,kagent_caller_session_id, andkagent_caller_tool_call_idA 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