diff options
| author | Adam Malczewski <[email protected]> | 2026-05-28 22:51:47 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-05-28 22:51:47 +0900 |
| commit | d6609efd4e14101e77fb35a98ce597a32816862d (patch) | |
| tree | 09ea404ce0a780ca6b8c380fdd93ad1ae9960986 /cc/README.md | |
| parent | 2eeabc95b78f6624c187e1e3892f9413266b4b9a (diff) | |
| download | dispatch-d6609efd4e14101e77fb35a98ce597a32816862d.tar.gz dispatch-d6609efd4e14101e77fb35a98ce597a32816862d.zip | |
fix(core): normalize tool schemas for Anthropic, add toolChoice=auto; feat(summon): agent definition support; docs: cc/ research findings
- registry.ts: add normalizeForAnthropic() to strip , additionalProperties, default, nullable from zodToJsonSchema output so Anthropic doesn't silently reject tool definitions
- agent.ts: add toolChoice=auto for Claude OAuth to prevent Opus thinking forever without calling tools
- summon.ts: add agentSlug parameter, build agents catalog in description, add toAvailableAgents helper
- agent-manager.ts: wire agent definition loading into spawnChildAgent, agent model fallback
- loader.ts: export loadAgent, expandAgentToolNames, getAgentDirPaths; add getAgentDirPaths for permission gate
- agent.ts: auto-allow read-only tools in agent definition directories
- packaging/PKGBUILD: exclude ARM64 prebuilds from x86_64 package
- cc/: research findings on Claude Opus tool calling issues
- tests: loader tests, summon tool tests
Diffstat (limited to 'cc/README.md')
| -rw-r--r-- | cc/README.md | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/cc/README.md b/cc/README.md new file mode 100644 index 0000000..a9c813d --- /dev/null +++ b/cc/README.md @@ -0,0 +1,38 @@ +# Claude Opus Tool Calling Investigation + +## Problem +Claude Opus "thinks forever" and doesn't call tools when used outside Claude Code's harness (in Dispatch's own agent harness). + +## Summary of Findings + +### 1. Tool Schema Format +Dispatch uses the AI SDK v6 (`@ai-sdk/anthropic@^3.x`) which should handle format conversion automatically. However, `zodToJsonSchema()` produces Draft 7 JSON Schema with fields (`$schema`, `additionalProperties`, `default`) that Anthropic's API doesn't support. Dispatch does **no schema normalization**. + +### 2. Anthropic's requirements +Anthropic's `input_schema` must be clean JSON Schema: +- Root `type: "object"` is mandatory +- No `$schema`, `additionalProperties`, `default`, `nullable` +- No combiners (`anyOf`, `oneOf`, etc.) +- Parameter `description` fields are strongly recommended + +### 3. Missing tool_choice +Dispatch doesn't set `tool_choice` in `streamText()` options. The default may cause Opus to not call tools. + +### 4. System prompt +The system prompt tells Opus what tools exist but may not be forceful enough about actually USING them instead of just talking about solutions. + +### 5. No Anthropic-specific schema normalization +Unlike opencode's `normalizeSchemaForCCA()`, dispatch passes raw JSON Schema to the AI SDK without stripping unsupported fields. + +## Key Files + +| File | Purpose | +|------|---------| +| `packages/core/src/tools/registry.ts` | Tool → AI SDK conversion | +| `packages/core/src/agent/agent.ts` | Agent loop, `streamText({tools})` | +| `packages/api/src/agent-manager.ts` | Provides tool config to agent | +| `packages/core/src/llm/provider.ts` | Provider creation | + +## Next Steps + +See `03-recommendations.md` for specific fixes to try. |
