Skip to content

ACP session initialization fails with third-party models (DashScope/bailian) — "Invalid input: expected object, received undefined" #491

@wattshen

Description

@wattshen

Bug Description

ACP session initialization fails when using third-party models like DashScope (bailian) via ANTHROPIC_BASE_URL. The SDK Zod schema validation throws Invalid input: expected object, received undefined during session initialization.

Steps to Reproduce

  1. Set environment variables for DashScope:
    export ANTHROPIC_API_KEY="your-api-key"
    export ANTHROPIC_BASE_URL="https://coding.dashscope.aliyuncs.com/apps/anthropic/v1"
  2. Run: acpx claude exec "echo hello"
  3. Error occurs during session initialization

Expected Behavior

The ACP agent should work with any Anthropic-compatible API provider, including DashScope/bailian models (qwen3.5-plus, glm-5, kimi-k2.5, etc.).

Actual Error

Invalid input: expected object, received undefined
{
  sessionUpdate: { _errors: [Array] },
  title: { _errors: [Array] },
  toolCallId: { _errors: [Array] },
  entries: { _errors: [Array] },
  availableCommands: { _errors: [Array] },
  currentModeId: { _errors: [Array] },
  configOptions: { _errors: [Array] },
  used: { _errors: [Array] }
}

The error repeats many times in a loop during SDK initialization.

Environment

  • @agentclientprotocol/claude-agent-acp: 0.24.2
  • @agentclientprotocol/sdk: 0.17.0
  • @anthropic-ai/claude-agent-sdk: 0.2.84
  • Node.js: v22.22.1
  • OS: Linux (WSL)
  • acpx: 0.3.1

Additional Context

The old package @zed-industries/claude-agent-acp (v0.23.1) had Bailian/DashScope workaround code in getAvailableModels() with a BAILIAN_MODELS array. This code is no longer present in the new @agentclientprotocol package. When ANTHROPIC_BASE_URL contains dashscope, isBailian was previously set to true to handle DashScope-specific model behavior. The new package removed this workaround, causing initialization to go through the standard (Anthropic-only) code path which expects fields that DashScope responses do not provide.

Possible Fix

  1. Restore the Bailian/DashScope detection and workaround code in getAvailableModels()
  2. Or add a more robust error handling layer that gracefully handles missing/undefined fields in ACP messages for non-Anthropic providers
  3. Or document officially supported providers and ensure compatibility

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