copilot-sdk icon indicating copy to clipboard operation
copilot-sdk copied to clipboard

Bug: Custom agents via task tool broken with Anthropic BYOK provider

Open knifeyspoony opened this issue 8 months ago • 1 comments

Summary

When using the Copilot SDK with the Anthropic BYOK provider (sweagent-anthropic), invoking a custom agent via the Task tool crashes with:

Error: message on turn 0 event missing callId

Custom agents work correctly with the Copilot API provider (sweagent-capi).

Root Cause

The Anthropic provider's agentic loop calls tool callbacks with only the input argument:

// Anthropic provider (sweagent-anthropic) — tool_use handling:
const result = await toolCallback(toolUseBlock.input);

The Copilot API provider passes a second context argument containing toolCallId:

// Copilot API provider (sweagent-capi) — tool execution:
const result = await toolCallback(input, { toolCallId: "..." });

The custom agent tool implementation reads toolCallId from this second argument to set the subagent's agentId. That agentId becomes the callId on the first progress event (turn 0, kind: "message"). When toolCallId is undefined (Anthropic path), agentId is undefined, and the SDK's own validation throws.

Reproduction

  1. Configure a session with the Anthropic provider (BYOK API key, model e.g. claude-sonnet-4-5)
  2. Have the agent invoke a subagent via the Task tool
  3. Error: message on turn 0 event missing callId

Confirmed still broken on latest.

knifeyspoony avatar Mar 06 '26 15:03 knifeyspoony

Fixed in Runtime PR #4218 — the Anthropic BYOK client now passes toolCallId via ToolCallbackOptions to tool callbacks, which resolves the subagent/task tool missing callId error. Shipped in @github/copilot CLI v1.0.2 and SDK v0.1.32.

patniko avatar Mar 08 '26 04:03 patniko