Skip to content

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

@knifeyspoony

Description

@knifeyspoony

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions