Skip to content

feat: render subagent delegation events in chat UI#31

Open
rdwj wants to merge 2 commits into
mainfrom
feat/subagent-delegation-rendering
Open

feat: render subagent delegation events in chat UI#31
rdwj wants to merge 2 commits into
mainfrom
feat/subagent-delegation-rendering

Conversation

@rdwj
Copy link
Copy Markdown
Contributor

@rdwj rdwj commented May 8, 2026

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

  • Invoked: a delegation card unfolds inline showing the target agent
    name, status ("delegating…"), and the task (truncated to 120 chars
    with a `
    Details` toggle for the full string).
  • Completed: card transitions to "done" state. Footer shows total
    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.
  • Failed: card transitions to "error" state showing `error_type` and
    `error_message`.

What changed

File LOC Shape
`static/app.js` +106 Three new helpers (`startSubagentCard`, `completeSubagentCard`, `failSubagentCard`) + a 12-line `if (delta.subagent)` dispatch in `handleDelta()`
`static/style.css` +117 New `.subagent-delegation` ruleset mirroring `.tool-call` (per-state border colors, reusing the existing `pulse` keyframe)

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

  • `make build` succeeds (Go server embeds the new static files)
  • Visual check against a deployed coordinator/specialist pair on
    OpenShift (target: `subagent-demo` namespace on `mcp-rhoai` cluster
    with a calculus-coordinator delegating to calculus-agent)
  • Delegation card renders in three states (invoked / completed / failed)
  • Concurrent delegations don't stomp each other (multiple span_ids)

Related

  • agent-template PR #173 — subagent-as-tool v1
  • agent-template #179 — v2 streaming nested deltas (will reuse the same card)

rdwj added 2 commits May 7, 2026 21:11
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)
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.

1 participant