Commit b12bc41
NGUYEN Duc Trung
feat: support custom tools in subagent sessions
Enable custom tools registered on a parent session to be dispatched when
called by subagent child sessions. The Copilot CLI creates separate child
sessions for subagents, and those sessions carry their own session IDs
that are not in the SDK's session registry.
Changes:
Go SDK (go/)
- Track child-to-parent session mappings via subagent.started events
- Implement resolveSession() to transparently route child session IDs
back to the parent session that owns the tool handlers
- Enforce per-agent tool allowlists (CustomAgentConfig.Tools) for both
Protocol v2 (tool.call RPC) and Protocol v3 (external_tool.requested
broadcast events)
- Auto-populate ToolDefinitions on CustomAgentConfig in the session.create
and session.resume wire payloads so the CLI can propagate custom tool
metadata to child sessions
- Preserve child mappings after subagent.completed/failed for in-flight
requests; clean up on parent session destroy or client stop
Design & Docs
- Add cross-SDK design spec (docs/design/subagent-tool-dispatch.md)
covering protocol contract, data model, allowlist enforcement, tool
advertisement, and language-specific implementation notes
- Document tool advertisement and v3 enforcement in go/README.md
Tests
- Unit tests for session resolution, tool allowlist enforcement,
v3 broadcast deny/allow, enrichAgentToolDefinitions, and instance
tracking (go/client_subagent_test.go)
- Integration test scaffolding for subagent custom tool invocation
and denied-tool scenarios (go/internal/e2e/subagent_tool_test.go)
- Placeholder E2E snapshots (test/snapshots/subagent_tool/)1 parent dd42d42 commit b12bc41
File tree
9 files changed
+1879
-24
lines changed- docs/design
- go
- internal/e2e
- test/snapshots/subagent_tool
9 files changed
+1879
-24
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
371 | 427 | | |
372 | 428 | | |
373 | 429 | | |
| |||
0 commit comments