feat: render subagent delegation events in chat UI#31
Open
rdwj wants to merge 2 commits into
Open
Conversation
The agent's SSE stream may now include `delta.subagent` events (`type: "invoked" | "completed" | "failed"`) emitted by the framework's subagent-as-tool feature. This commit adds rendering for those events: - A delegation card appears inline in the assistant message when a delegation begins, showing the target agent name and the truncated task with a `<details>` toggle for the full task string. - The card transitions to a "done" state on `completed` events, showing rolled-up token totals and cost in a small footer line. The specialist's content is NOT rendered as part of the card — it gets folded into the assistant's message via the parent's normal `content` deltas (so the answer reads naturally). - The card transitions to an "error" state on `failed` events, showing `error_type` and `error_message`. Cards are correlated by `span_id` so concurrent delegations render in parallel without stomping each other. Pure additive change (~110 LOC JS + ~110 LOC CSS). The CSS mirrors the existing `.tool-call` ruleset's pattern (border per state, subtle background fill) so the visual language is consistent. No changes to the SSE parser, the Go server, or the message accumulator — the new branch in `handleDelta()` sits alongside the existing `tool_calls` / `reasoning_content` / `content` branches. Assisted-by: Claude Code (Opus 4.7)
The static-frontend section now mentions the delegation card flow landed in this PR, mirroring the existing tool-call visualization description. Drives readers to the `.subagent-delegation` ↔ `.tool-call` parallel so the styling intent is obvious from the docs. Assisted-by: Claude Code (Opus 4.7)
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.
Summary
Renders the three new `delta.subagent` SSE events emitted by fipsagents
0.22.0+ agents that use subagent-as-tool. Without this, the UI sees the
final assistant message but the delegation is invisible.
The wire format (verified against a deployed coordinator/specialist pair):
```json
{ "choices": [{ "delta": {
"subagent": {
"type": "invoked" | "completed" | "failed",
"agent_name": "...",
"span_id": "...",
...
}
}}] }
```
Span IDs correlate `completed` / `failed` events back to the originating
`invoked` event, so concurrent delegations render in parallel.
Behavior
name, status ("delegating…"), and the task (truncated to 120 chars
with a `
Details
` toggle for the full string).tokens and cost. The subagent's `content` is not rendered in the
card — it folds into the parent assistant message via normal `content`
deltas so the answer reads naturally.
`error_message`.
What changed
Pure additive change. No edits to existing branches in the SSE dispatch,
the message accumulator, or the Go server (which is a verbatim SSE proxy).
Test plan
OpenShift (target: `subagent-demo` namespace on `mcp-rhoai` cluster
with a calculus-coordinator delegating to calculus-agent)
Related