Skip to content

Backport 2153 to 0.10.x release - #2373

Merged
EItanya merged 1 commit into
kagent-dev:release/v0.10.xfrom
supreme-gg-gg:backport/isolate-agent-sessions
Jul 31, 2026
Merged

Backport 2153 to 0.10.x release#2373
EItanya merged 1 commit into
kagent-dev:release/v0.10.xfrom
supreme-gg-gg:backport/isolate-agent-sessions

Conversation

@supreme-gg-gg

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings July 31, 2026 15:42
@supreme-gg-gg
supreme-gg-gg requested review from a team, Charlesthebird and peterj as code owners July 31, 2026 15:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…ev#2153)

## Summary

Fixes kagent-dev#2137

The bug : every call a parent agent makes to a sub-agent (Agent tool)
reuses the same A2A **context_id** since it's minted once when the tool
is built. worker just uses that **context_id** as its session id
directly ( **executor.go: sessionID := reqCtx.ContextID** ) so if a
coordinator fires off N parallel calls to the same sub-agent in one turn
, they all pile into a single shared session instead of getting their
own.

Fix is an opt-in **IsolateSessions** flag on Agent-type tools :

```yaml
spec:
  declarative:
    tools:
      - type: Agent
        agent:
          name: worker
        isolateSessions: true   # each call to worker gets its own session
```

Default behavior (flag unset/false) doesn't change
one **context_id** for the tool's whole lifetime so stateful sub-agents
keep their session continuity. with the flag on we mint a fresh
**context_id** on every call so each invocation is isolated.

Doesn't touch the **x-kagent-root-context-id** header stuff. that's
still what carries cross-turn continuity and it stays stable either way.

## What changed

- `agent_types.go`: added `Tool.IsolateSessions *bool` plus a CEL rule
so it can only be set when `type: Agent`
- `adk/types.go`: `RemoteAgentConfig.IsolateSessions bool`
- `compiler.go`: passes the flag through into `RemoteAgentConfig`
- `agent.go`: forwards the flag to `NewKAgentRemoteA2ATool`. also skips
adding an entry to `subagentSessionIDs` when isolated since there's no
single session id to pre-stamp function_call parts with anymore
- `remote_a2a_tool.go`: added `isolateSessions` plus a small
`nextContextID()` helper that either returns the stable id or mints a
new one. This gets reported back as `subagent_session_id`
- Python `types.py`: added `isolate_sessions` for schema parity only, it
doesn't do anything on that side yet (matches what the issue scoped out)
- Regenerated CRDs/deepcopy with `make controller-manifests`
- Added a test for the new context-id logic and a golden fixture
(`agent_with_isolated_session_tool`) to check it flows through the whole
translation pipeline

## About the UI

Isolated tools don't have one fixed session id, so the executor can't
pre-populate the stamp map for them at startup. Instead the UI grabs the
session id per call from `subagent_session_id` in the function_response.
`AgentCallDisplay` already reads that field, so nothing new needed
there.

## Not doing in this PR

- Not a concurrency limiter, that's separate (`max-concurrency.md`)
- HITL resume is unaffected, it still uses the context_id from the
confirmation payload
- Only the Go runtime respects this flag right now. Python accepts it
for config parity but the low-level tool doesn't use it yet

## Tests

Ran `go test ./adk/pkg/tools/... ./adk/pkg/agent/... ./api/...` and the
golden translator tests. Everything passes.
Confirmed `isolate_sessions: true` shows up correctly in the generated
`config.json` for the new fixture.

## One small thing I noticed

In `handleResume`, `processResult` now sets `subagent_session_id` from
the contextID I pass in, but there's older code right after it that sets
the same key again with a fallback to `lastContextID`. Not wrong, just a
bit redundant now since it writes the same value twice in the normal
case. Left it as is since it's harmless but flagging it in case someone
wants it cleaned up.

---------

Signed-off-by: Yashraj Shukla <shuklayashraj68@gmail.com>
Co-authored-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
@supreme-gg-gg
supreme-gg-gg force-pushed the backport/isolate-agent-sessions branch from 30b1c7b to 4ecfca8 Compare July 31, 2026 15:43
@EItanya
EItanya merged commit db11ad7 into kagent-dev:release/v0.10.x Jul 31, 2026
32 checks passed
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.

4 participants