Skip to content

feat(providers): add claude-agent-sdk provider#104

Open
lesandiz wants to merge 2 commits intomicrosoft:mainfrom
lesandiz:feat/claude-agent-sdk-provider
Open

feat(providers): add claude-agent-sdk provider#104
lesandiz wants to merge 2 commits intomicrosoft:mainfrom
lesandiz:feat/claude-agent-sdk-provider

Conversation

@lesandiz
Copy link
Copy Markdown

@lesandiz lesandiz commented Apr 21, 2026

Summary

  • Adds a new claude-agent-sdk provider that delegates the agentic loop, tool execution, retry logic, and structured output extraction to the Claude Code CLI via the claude-agent-sdk package
  • Unlike the raw claude provider (~1900 lines), this provider is ~250 lines — the SDK handles the heavy lifting
  • Tools and MCP servers are managed by the CLI's own configuration, not workflow YAML fields

What's included

New files:

  • src/conductor/providers/claude_agent_sdk.pyClaudeAgentSdkProvider implementation
  • tests/test_providers/test_claude_agent_sdk.py — 22 tests using real SDK types
  • examples/test-claude-agent-sdk.yaml — example workflow

Modified files:

  • src/conductor/config/schema.py — added "claude-agent-sdk" to provider Literal types
  • src/conductor/providers/factory.py — added factory case for the new provider
  • src/conductor/providers/__init__.py — exported ClaudeAgentSdkProvider
  • pyproject.toml — added claude-agent-sdk dependency
  • Docs: AGENTS.md, README.md, docs/cli-reference.md, docs/configuration.md, docs/providers/comparison.md, .claude/skills/conductor/SKILL.md, .claude/skills/conductor/references/yaml-schema.md

Key design decisions

  • Message dispatch uses type(message).__name__ — the Python SDK classes don't set a .type attribute (unlike the TypeScript SDK)
  • Tool results paired via pending_tools dict — tracks tool_use_id → tool_name from AssistantMessage ToolUseBlocks, then matches them to ToolResultBlocks in subsequent UserMessages
  • Tests use real SDK types (not fakes) — imports AssistantMessage, TextBlock, etc. directly from claude_agent_sdk to catch API contract drift
  • Tools/MCP servers not passed through — the CLI manages its own toolset; workflow-level tools and runtime.mcp_servers are ignored (documented in comparison.md and yaml-schema.md)
  • Provider parity — achieves event and output parity with copilot/claude providers; retry and tool execution are delegated to the SDK (documented in AGENTS.md)

Test plan

  • uv run ruff check src tests — lint passes
  • uv run ruff format --check src tests — format passes
  • uv run pytest tests/test_providers/test_claude_agent_sdk.py -v — 22 tests pass
  • uv run pytest -m "not real_api and not performance" — full suite passes
  • uv run conductor validate examples/test-claude-agent-sdk.yaml — validates
  • uv run conductor run examples/test-claude-agent-sdk.yaml --input question="What is Claude Design?" — executes successfully with web search

🤖 Generated with Claude Code

lesandiz and others added 2 commits April 21, 2026 16:14
Add a new provider that uses the claude-agent-sdk package to delegate
the agentic loop, tool execution, and structured output extraction to
the Claude Code CLI. Unlike the raw claude provider, this provider does
not manage its own retry logic, MCP servers, or tool wiring — these are
handled by the SDK runtime.

- New provider: ClaudeAgentSdkProvider with execute(), validate_connection(), close()
- Message dispatch via type(message).__name__ matching real SDK class names
- Tool result pairing: tracks pending tool_use IDs to emit agent_tool_complete
  with actual results from ToolResultBlock (not fake nulls)
- Structured output via ClaudeAgentOptions.output_format (json_schema)
- Event callback parity: agent_turn_start, agent_message, agent_reasoning,
  agent_tool_start, agent_tool_complete
- 22 tests using real SDK types (AssistantMessage, TextBlock, etc.)
- Updated schema, factory, __init__, docs, and example workflow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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