Repository navigation
fix: Support Agent Skills (ignore code execution results, merge custom tools) - #26
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
saarnilauri
left a comment
There was a problem hiding this comment.
Thanks for picking this up. Skills support would be useful.
I rebased the change onto current trunk locally and ran it against the live API. The live tests revealed drift in the beta status and secondly as the PR stands, it doesn't make Skills usable:
- Skills need the code execution tool. Without it the API returns 400, so the example in the description fails.
- The response parser is the real blocker. With the tool added, the API returns 200, but the provider throws on the code-execution result blocks. Adding those block types to the ignored cases in
parseResponseContentMessagePart()fixed it for both an Anthropic skill and a custom skill, with no beta headers. The Skills API is generally available and needs no beta header. - Adding the tool collides with other tools. Passing it through
customOptions['tools']throws "conflicts with an existing parameter" whenever the prompt also has function declarations or web search. Since the example hook runs for every prompt, that would break tool-using features site-wide. It should also only act on the Anthropic provider.
Could you rescope the PR to the parser fix, plus a way to add the code execution tool alongside the other tools, and drop the beta headers? The branch also needs a rebase (it conflicts after #32).
| $headers['anthropic-beta'] = 'structured-outputs-2025-11-13'; | ||
| } | ||
|
|
||
| // Add beta headers required for Skills (container parameter) if present in custom options. |
There was a problem hiding this comment.
Tested against the live API (2026-10-09). These headers aren't what blocks Skills. The Skills guide now says "The Skills API is out of beta and needs no beta header." With Anthropic's xlsx skill and a throwaway custom skill:
- Without the
code_executiontool, the request is rejected with 400 "container: skills can only be used when a code execution tool is enabled", with or without these headers. That's the PR description's example as written. - With
tools: [{type: code_execution_20250825, name: code_execution}]and noanthropic-betaheader at all, the request returns 200. That held forxlsxon Haiku 4.5 and Sonnet 5, and for an uploaded custom skill. - Through this model class, that 200 then fails in the provider with
ResponseException: … Part has an unexpected type.That happens with or without this PR. The response containsbash_code_execution_tool_resultand, for the custom skill,text_editor_code_execution_tool_resultblocks, andparseResponseContentMessagePart()rejects both.
I added bash_code_execution_tool_result, code_execution_tool_result and text_editor_code_execution_tool_result to the existing "ignore" cases next to web_search_tool_result. With that change, both calls worked end to end with no beta headers. The custom skill's answer came through correctly.
|
@drywall thanks for the contribution! Any chance you can respond to the code review feedback here to unblock getting this into the provider plugin? |
…m tools) Agent Skills need a `container` with `skills` and the code execution tool. - Ignore `code_execution_tool_result`, `bash_code_execution_tool_result` and `text_editor_code_execution_tool_result` blocks when parsing the response, as already done for `web_search_tool_result`. - Append a `tools` list from custom options to the generated tools instead of throwing a conflict when function declarations or web search are also set. - When continuing a `pause_turn`, add the container ID to an array `container` option instead of replacing it, so the skills are kept. The Skills API is GA, so no beta headers are needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9016e9b to
e339409
Compare
|
@jeffpaul Thanks for the nudge! @saarnilauri Thanks for testing this against the live API. I've rescoped the PR as you suggested and rebuilt it on current |
saarnilauri
left a comment
There was a problem hiding this comment.
Thanks for rebuilding this. It now covers everything from my earlier review.
On the pause_turn change, I checked it live (Haiku 4.5, xlsx skill, no beta header). I couldn't trigger a real pause_turn, even with 15 tool calls in one turn, so I reused a container across two calls instead:
- With
container: {skills, id}, the same container came back with its files and the skill still attached. - With the bare ID, which is what trunk sends, the files were still there, but the response no longer listed the skill and the input was ~1,200 tokens smaller. So the continuation ran without the skill.
That matches Anthropic's Skills guide, which sends {id, skills} on each pause_turn continuation, so this change is needed.
End to end through the model with a function declaration plus the code execution tool, the request went out with both tools and no beta header, and the result came back fine.
Checked locally: the full suite passes, PHPCS and PHPStan are clean, and reverting each of the three source changes fails its new test.
@jeffpaul One note for the release changelog: a list-shaped tools custom option is now added to the generated tools instead of throwing a conflict error. Nothing that worked before changes, but it's worth mentioning alongside the Skills support.
|
@saarnilauri want to confirm what those changelog entries would be an include them in the squash merge commit description then? |
@jeffpaul I will check again tomorrow and include them into the squash merge commit description. |
Problem
Agent Skills need a
containerwithskillsand the code execution tool. Neither could be used through this provider:bash_code_execution_tool_result/text_editor_code_execution_tool_resultblocks, which made parsing fail with "Part has an unexpected type".customOptions['tools']threw "conflicts with an existing parameter" whenever the prompt also had function declarations or web search.Changes
parseResponseContentMessagePart(), as already done forweb_search_tool_result.toolslist from custom options to the generated tools instead of rejecting it.pause_turn, add the container ID to an arraycontaineroption instead of replacing it, so the skills are kept.The Skills API is GA, so no beta headers are needed.
Usage
🤖 Generated with Claude Code