summaryrefslogtreecommitdiffhomepage
path: root/cc/04-schema-debug.md
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-05-28 22:51:47 +0900
committerAdam Malczewski <[email protected]>2026-05-28 22:51:47 +0900
commitd6609efd4e14101e77fb35a98ce597a32816862d (patch)
tree09ea404ce0a780ca6b8c380fdd93ad1ae9960986 /cc/04-schema-debug.md
parent2eeabc95b78f6624c187e1e3892f9413266b4b9a (diff)
downloaddispatch-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/04-schema-debug.md')
-rw-r--r--cc/04-schema-debug.md40
1 files changed, 40 insertions, 0 deletions
diff --git a/cc/04-schema-debug.md b/cc/04-schema-debug.md
new file mode 100644
index 0000000..5889862
--- /dev/null
+++ b/cc/04-schema-debug.md
@@ -0,0 +1,40 @@
+# Schema Debug — What zodToJsonSchema Actually Produces
+
+Run this to see what the AI SDK actually sends to Anthropic:
+
+```bash
+node --experimental-strip-types -e "
+import { z } from 'zod';
+import { zodToJsonSchema } from 'zod-to-json-schema';
+
+const schema = z.object({
+ path: z.string().describe('Path to the file, relative to the working directory'),
+ offset: z.number().int().min(1).optional().describe('1-indexed start line. Default: 1.'),
+ limit: z.number().int().min(1).optional().describe('Max lines to return. Default: 500. Hard cap: 5000.'),
+});
+
+console.log(JSON.stringify(zodToJsonSchema(schema), null, 2));
+"
+```
+
+## Check the @ai-sdk/anthropic adapter's tool serialization
+
+```bash
+grep -n 'input_schema\|tools\|jsonSchema\|convertTools' node_modules/@ai-sdk/anthropic/dist/index.mjs | head -30
+```
+
+## Check if streamText is receiving the tools correctly
+
+Look at how streamText processes tool options in the AI SDK:
+
+```bash
+grep -n 'tools\|toolChoice\|toolCall' node_modules/ai/dist/index.mjs | head -40
+```
+
+## Key questions to answer
+
+1. Does `zodToJsonSchema` output `$schema`? If yes, Anthropic may silently reject the tool definition.
+2. Does it output `additionalProperties`? Same concern.
+3. Does the `@ai-sdk/anthropic` adapter strip these before sending to the API?
+4. Does the adapter forward parameter `description` fields from JSON Schema to Anthropic's wire format?
+5. Is `tool_choice` being set or defaulting to something suboptimal?