Add Claude Code provider plugin#197
Conversation
Status: blocked on WP Codebox Claude Code runtime supportThis PR is not done by the Homeboy Codebox cooking gate yet. What is proven:
Failing canary evidence:
Additional probe:
Diagnosis: The PHP provider approach cannot power Codebox cooking until WP Codebox/Homeboy exposes a first-class Claude Code execution surface to the sandbox or runs Claude Code as the outer Codebox agent. The current Playground runtime cannot execute the host-authenticated Upstream tracker: Automattic/wp-codebox#807 |
Status update: CLI blocker removedThe provider implementation has been rewritten in commit Current shape:
Verification after rewrite:
Live model-backed Homeboy Codebox canary is still pending because |
Status update: Homeboy Codebox canary passingThe Claude Code OAuth provider now passes the read-only Homeboy Codebox canary. Canary evidence:
What changed after the earlier OAuth rewrite:
Verification:
|
Status update: Opus 4.8 canary passingAdded Canary evidence:
Provider now declares models: |
The provider previously did text-only generation, so the agent's tools were never declared to Anthropic and the model improvised tool calls as freeform text that the runtime could not reliably parse. Declare the agent's function declarations as Anthropic `tools` with an `input_schema`, serialize FunctionCall/FunctionResponse message parts as `tool_use`/`tool_result` content blocks, and parse Anthropic `tool_use` response blocks back into FunctionCall message parts so the runtime's preferred structured tool-call path executes deterministically. Maps `stop_reason: tool_use` to FinishReasonEnum::toolCalls() and declares the functionDeclarations supported option. Adds a headless smoke test that mocks the HTTP transporter to assert the request carries structured tools and the response tool_use parses into a FunctionCall part.
Update: structured tool calling addedThe provider now implements Anthropic structured tool calling, replacing the prior text-only generation that forced the model to improvise tool calls as freeform text. Commit
VerificationNew headless smoke test (
Also passing: Related upstream fixes from this work
|
Anthropic rejects a Messages request with `tool_use.input: Input should be
an object` when a serialized assistant tool call carried empty or
list-shaped arguments, because an empty PHP array encodes as `[]` rather
than `{}`. Coerce function-call arguments to an object so no-argument tool
calls round-trip correctly, and cover the case in the structured-tools
smoke test.
Update: empty tool_use input fix + full chain verifiedCommit End-to-end status across the full chainWith the synced runtime (data-machine main + agents-api dev-main + the writable-tools and projection fixes), the structured tool-calling path now reaches Anthropic and the model emits real Related fixes that make Codebox coding agents work end-to-end:
Remaining noteOpus 4.8 is non-deterministic about emitting a structured |
Summary
ai-provider-for-claude-codeWP AI Client provider backed by Claude Code OAuth credentials and Anthropic Messages API requests.Testing
bash -n setup.sh upgrade.sh lib/carried-plugins.sh lib/homeboy.sh lib/agents-md-guidance.shphp -lon allcarried-plugins/ai-provider-for-claude-codePHP filesbash tests/carried-claude-code-plugin.sh && bash tests/homeboy-codebox-canary.sh && bash tests/agents-md-guidance.shgit diff --checkEXISTING_WP="/Users/chubes/Studio/intelligence-chubes4" ./setup.sh --local --runtime claude-code --dry-run --no-chat./upgrade.sh --local --wp-path "/Users/chubes/Studio/intelligence-chubes4" --runtime claude-code --dry-run --plugins-onlyphp -r 'define("ABSPATH", __DIR__ . "/"); function add_action($hook, $callback, $priority = 10) { call_user_func($callback); } require "carried-plugins/ai-provider-for-claude-code/ai-provider-for-claude-code.php"; echo "loaded\n";'Live canary
claude-code-provider-oauth-canary-20260608-007claude-codeclaude-sonnet-4-6/var/folders/lr/c_cmmt7s0592m4njz99v5yb40000gn/T/tmp.vUFYw5hhK3/status.json/var/folders/lr/c_cmmt7s0592m4njz99v5yb40000gn/T/tmp.vUFYw5hhK3/logs.json/var/folders/lr/c_cmmt7s0592m4njz99v5yb40000gn/T/tmp.vUFYw5hhK3/artifacts.jsonAI assistance