Repository navigation
Description
📋 Prerequisites
- I have searched the existing issues to avoid creating a duplicate
- By submitting this issue, you agree to follow our Code of Conduct
- I am using the latest version of the software
- I have tried to clear cache/cookies or used incognito mode (if ui-related)
- I can consistently reproduce this issue
🎯 Affected Service(s)
Not Sure
🚦 Impact/Severity
No impact (Default)
🐛 Bug Description
EP: Per-call session isolation for Agent tools (isolateSessions)
Goal
Let a declarative agent fan out parallel, isolated sub-agent calls. Today every
call the parent makes to a given sub-agent (Agent tool) reuses one A2A
context_id, so all calls land in a single sub-agent session and are processed
as one conversation instead of independent sessions.
Add an opt-in isolateSessions flag on Agent tools. When enabled, each call to that
sub-agent uses a fresh context_id, so every invocation runs in its own isolated
sub-agent session — the Go equivalent of ADK's AgentTool "fresh session/context per
invocation" (the pattern the Python coordinator/dispatcher uses for per-repository
context isolation).
Problem (root cause)
go/adk/pkg/tools/remote_a2a_tool.go generates lastContextID once, at tool
construction (pod startup), and stamps it on every outbound A2A message:
state := &remoteA2AState{ /* ... */ lastContextID: a2atype.NewContextID() }
// ...
message.ContextID = s.lastContextID // same id for every call, foreverThe worker derives its session id straight from that context id
(go/adk/pkg/a2a/executor.go: sessionID := reqCtx.ContextID). So N parallel calls
→ 1 shared worker session, serialized/interleaved rather than N parallel sessions.
Observed: a coordinator emitted 11 sub-agent calls in one model turn; all 11 collapsed
into a single worker session (11 A2A tasks in one context) instead of 11 isolated
sessions.
The Python low-level tool (_remote_a2a_tool.py) has the identical shared-context
behavior; the Python side only gets isolation because a custom dispatcher wraps the
worker in ADK AgentTool, which mints a fresh session per call. This EP brings the
same capability to the Go declarative runtime without a custom agent.
Design
isolateSessions is a per-Agent-tool boolean.
false(default): unchanged. One stablecontext_idper tool for its lifetime
→ session continuity for stateful sub-agents.true:context_idis minted per call viaa2atype.NewContextID()→ each call
is an isolated sub-agent session; parallel fan-out no longer shares state/history.
Cross-conversation/turn continuity that stateful workers need does not depend on
the message context_id: it rides the x-kagent-root-context-id header
(lineageHeadersInterceptor), which stays stable per conversation regardless of this
flag. So isolation only changes which sub-agent session a turn is recorded in.
UI linking
The executor pre-stamps outgoing function_call parts with a pre-known
subagent_session_id from a startup map (subagentSessionIDs, keyed by tool name).
With per-call ids there is no single pre-known id, so an isolated tool contributes
no map entry: the UI links each sub-agent card via the per-call
subagent_session_id returned in the tool's function_response (already consumed by
AgentCallDisplay).
Changes
| File | Change |
|---|---|
go/api/v1alpha2/agent_types.go |
Add IsolateSessions *bool to Tool (+ CEL validation: only for type=Agent) |
go/api/adk/types.go |
Add IsolateSessions bool (isolate_sessions) to RemoteAgentConfig |
go/core/internal/controller/translator/agent/compiler.go |
Copy tool.IsolateSessions → RemoteAgentConfig.IsolateSessions |
go/adk/pkg/agent/agent.go |
Pass flag to NewKAgentRemoteA2ATool; skip stamp-map entry when isolated |
go/adk/pkg/tools/remote_a2a_tool.go |
isolateSessions field; per-call context_id; thread it into processResult |
python/packages/kagent-adk/src/kagent/adk/types.py |
Add isolate_sessions field for config-schema parity (Go runtime honors it) |
| generated | CRD YAML + DeepCopy via make controller-manifests; golden files via UPDATE_GOLDEN=true make -C go test |
Deployment / configuration
apiVersion: kagent.dev/v1alpha2
kind: Agent
metadata:
name: coordinator
spec:
declarative:
runtime: go
tools:
- type: Agent
agent:
name: worker
isolateSessions: true # each worker call = its own isolated session- Unset /
false→ current behavior (one shared sub-agent session). true→ fresh sub-agent session per call; enables parallel isolated fan-out.
Scope / non-goals
- Runtime: honored by the Go declarative runtime. The field is accepted by the
Python config model (schema parity) but the Python low-level tool is unchanged. - Not a concurrency limiter — see
max-concurrency.mdfor capping parallel
invocations per pod. Isolation and concurrency limiting are complementary. - No change to HITL resume: resume still targets the original sub-agent session via
thecontext_idstored in the confirmation payload.
Behavior notes & caveats
- Stateful sub-agents that rely on reused session history across calls must keep
isolateSessions: false(or key state onx-kagent-root-context-id). - With isolation on, a sub-agent's per-call sessions have
source='agent'and are
hidden from the worker's sidebar by design; they render inline in the parent chat. - Parallelism is bounded by how many tool calls the parent LLM emits in a turn and by
anyKAGENT_MAX_CONCURRENCYon the worker pod.
🔄 Steps To Reproduce
- Create WorkerAgent
- Create Coordinator Agent with WorkerAgent as Tool
- Ask coordinator agent to call Worker with 3 tasks in parallel
🤔 Expected Behavior
No response
📱 Actual Behavior
No response
💻 Environment
No response
🔧 CLI Bug Report
No response
🔍 Additional Context
No response
📋 Logs
📷 Screenshots
No response
🙋 Are you willing to contribute?
- I am willing to submit a PR to fix this issue
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog
Activity
dimetron commentedon Jul 2, 2026
In addition child sessions, when Coordinator Agent -> Worker Agent
on worker we do not see sessions from A2A in ListSessionsForAgent filter source != 'agent'
dimetron commentedon Jul 10, 2026
EP 2153: Per-call session isolation + robust sub-agent session reporting
Status: implemented
Upstream: #2153
(
fix(go-adk): add per-call session isolation for Agent tools)Goal
Let a declarative agent fan out parallel, isolated sub-agent calls, and make
each of those calls observable in the UI by always reporting the sub-agent
session it ran in.
Two capabilities, delivered together:
isolateSessions) — mint a fresh A2Acontext_idper sub-agent call so parallel fan-out no longer collapses intoone shared sub-agent session.
(success,
input_required, failure) returns the per-callcontext_idassubagent_session_id, so the UI can always link a sub-agent card to thesession that produced it.
Problem
Shared sub-agent session (isolation)
go/adk/pkg/tools/remote_a2a_tool.goused to generate onecontext_idonce,at tool construction (pod startup), and stamp it on every outbound A2A
message:
The worker derives its session id straight from that context id
(
go/adk/pkg/a2a/executor.go:sessionID := reqCtx.ContextID). So N parallelcalls → 1 shared worker session, serialized/interleaved rather than N parallel
sessions.
Observed: a coordinator emitted 11 sub-agent calls in one model turn; all 11
collapsed into a single worker session (11 A2A tasks in one context) instead of
11 isolated sessions.
Session id silently dropped on some branches (reporting)
The tool returned each outcome as an ad-hoc
map[string]anyliteral, builtindependently per branch. Nothing forced a branch to include
subagent_session_id, and several omitted it (direct-message result,input_required, and the no-result fallback). With isolation on there is nostable, pre-known session id to fall back to, so any branch that drops the
per-call id leaves the UI unable to link that sub-agent card to a session.
Design
isolateSessionsflagA per-Agent-tool boolean.
false(default): one stablecontext_idper tool for its lifetime →session continuity for stateful sub-agents. Unchanged behavior.
true:context_idis minted per call viaa2atype.NewContextID()→each call is an isolated sub-agent session; parallel fan-out no longer shares
state/history.
Cross-conversation/turn continuity that stateful workers need does not
depend on the message
context_id: it rides thex-kagent-root-context-idheader (
lineageHeadersInterceptor), which stays stable per conversationregardless of this flag. So isolation only changes which sub-agent session a
turn is recorded in.
UI linking
The executor can pre-stamp outgoing
function_callparts with a pre-knownsubagent_session_idfrom a startup map (subagentSessionIDs, keyed by toolname). That model only works when a tool has exactly one session for its whole
lifetime — it breaks down under
isolateSessions, where the real session isper call. So an isolated tool contributes no map entry (its constructor
returns an empty stamp id), and the UI links each sub-agent card via the
per-call
subagent_session_idreturned in the tool'sfunction_response(consumed by
AgentCallDisplay).For this to hold, that response field must be present on every branch — see
below.
Typed response contract (the reporting fix)
Every outcome returns one shared struct instead of a per-branch map literal, so
SubagentSessionID(the per-callcontext_id) is a field every path sets andcannot be forgotten in one branch while present in another:
subagent_session_idreporting per branch:context_id*Messageresult (unary and streaming)context_idinput_required(incl. nil-task guard)context_id, else per-callcontext_id, else per-callcontext_idcontext_idcontext_idRetryableis a*boolsosubagent_timeoutcan report an explicitfalsethat survives JSON
omitempty(a plainfalsewould be dropped). Child-providedstructured failure fields (
error_type,error_step,error_message,remediation_hint) are overlaid onto the struct, with the child's value winningover the generic
subagent_<state>default.Relationship to PR #2153 and local divergences
PR #2153 is the upstream origin of both ideas. This repo had already implemented
a superset of the PR's isolation feature (adding streaming relay, per-call
timeout +
tasks/cancel, and a per-invocation concurrency limiter), so the PRcould not be cherry-picked as-is. Only the PR's response-contract idea was
missing here, and it was adopted — but adapted, keeping the local implementation
where it is superior:
remoteA2AResponse+ always reportsubagent_session_idNewKAgentRemoteA2ATool(RemoteA2AToolConfig)subagentSessionIDsstamp-map plumbingNet: the typed response is the one place the PR was ahead, and it is now in; the
rest of the PR would have been a regression against the local code.
Changes
go/api/v1alpha2/agent_types.goIsolateSessions *boolonTool(CEL:type=Agentonly)go/api/adk/types.goIsolateSessions bool(isolate_sessions) onRemoteAgentConfiggo/core/internal/controller/translator/agent/compiler.gotool.IsolateSessions→RemoteAgentConfig.IsolateSessionsgo/adk/pkg/agent/agent.goRemoteA2AToolConfig; skip stamp-map entry when isolatedgo/adk/pkg/tools/remote_a2a_tool.goisolateSessionsfield +contextIDForCall; typedremoteA2AResponseon every branch, always settingsubagent_session_idpython/packages/kagent-adk/src/kagent/adk/types.pyisolate_sessionsfield for config-schema parity (Go runtime honors it)make controller-manifests; golden files viaUPDATE_GOLDEN=true make -C go testDeployment / configuration
false→ current behavior (one shared sub-agent session).true→ fresh sub-agent session per call; enables parallel isolated fan-out.Scope / non-goals
by the Python config model (schema parity) but the Python low-level tool is
unchanged.
separate mechanism. Isolation and concurrency limiting are complementary.
via the
context_idstored in the confirmation payload.Behavior notes & caveats
keep
isolateSessions: false(or key state onx-kagent-root-context-id).source='agent'andare hidden from the worker's sidebar by design; they render inline in the
parent chat.
subagent_session_idin thefunction_responseis now thesingle source of truth for UI linkage on both isolated and non-isolated tools.
Testing
contextIDForCall— shared reuses one id, isolated mints a freshnon-empty id per call.
processResultbranch (message, completed, input_required,failed/canceled/rejected, non-terminal, no-result) returns a non-empty
subagent_session_id;sendStreamingterminal-message path reports it too.plain text default, synthesized empty text);
timeoutResultreports explicitretryable=falseplus linkage fields.isolateSessionstests stay green.fix(go-adk): add per-call session isolation for Agent tools (kagent-d…
fix(go-adk): add per-call session isolation for Agent tools (kagent-d…