Repository navigation
AI: Use Core's tool names, schema preparation and ability queries - #1073
Open
AllTerrainDeveloper wants to merge 4 commits into
Open
AllTerrainDeveloper wants to merge 4 commits into
AllTerrainDeveloper wants to merge 4 commits into
Conversation
The assistant and agents kept their own recursive walk to strip WordPress-only keys from tool schemas. wp_prepare_json_schema_for_client(), new in 7.1, does that and also lifts draft-03 per-property `required` flags into a list. AI features now switch off below 7.1 through openstation_ai_is_available(). The rest of the plugin still runs from 6.0. The top-level reshaping stays, because Core's helper keeps top-level combinators and providers reject them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runner passed an empty array to abilities with no input schema, and Core refuses any non-null input to those, so an agent could never call one. The Copilot already handled this; both now share openstation_ai_execute_ability(). The runner also dropped a tool when two abilities shared a short name, which could lose OpenStation's own ability if a third-party one was listed first. It now uses the Copilot's openstation_ai_unique_ability_tool_names(), so both stay callable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An agent's model was saved, exposed over REST and exported for privacy, but the runner never read it, because its docblock was waiting for Core to offer model selection. Core does now, so pass it through as a preference. The AI Client falls back when no provider offers that model, and openstation_ai_model_config still has the last word. Agents that already have a stored model will start using it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agents and the Copilot invented their own tool names by stripping the namespace. They now use WP_AI_Client_Ability_Function_Resolver's `wpab__` names, and the Copilot asks Core's wp_get_abilities() for read-only abilities. Short names stay where they are a contract or stored data. Copilot hooks and its generation filter keep them, translated at the model boundary. Saved agent instructions name tools by short name, so a guide mapping them to full names travels with the prompt, and agents still accept a short name if a model uses it. The read-only check stays after Core's query, because it is what keeps write abilities from a model reading untrusted text and a filter can reshape the result. A name over 64 characters keeps its short name, since one over-long name would fail the whole request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
@claude can you review? |
|
Claude finished @AllTerrainDeveloper's task in 34s —— View job Review of #1073: Core tool names, schema preparation and ability queriesI read the full diff of What checks out
Nits and things to consider
Before merging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Makes OpenStation's AI layer use WordPress core's APIs wherever core has an equivalent:
wpab__desktop-mode__search-posts).wp_prepare_json_schema_for_client().wp_get_abilities()for them.using_model_preference().It also fixes two agent bugs: agents could never call an ability with no input schema, and OpenStation's own ability could be dropped when a third-party ability with the same short name was listed first.
Behavior changes to review:
Rationale
OpenStation already relies on core for providers, keys and the ability registry. What it still duplicated was tool naming, schema cleanup and ability filtering, and it stored a model setting while waiting for a core API that now exists.
Core has no agent registry, skills API, MCP server, conversation store or tool loop, so the agent runtime and both loops stay.
Core's higher-level helpers aren't adopted, for these reasons:
using_abilities(): it keeps top-leveloneOf/anyOf/allOf, and calling it alongsideusing_function_declarations()appears to replace the earlier declarations. The Copilot sends abilities and browser commands in one request.WP_AI_Client_Ability_Function_Resolver::execute_ability(): on 7.1.4, empty arguments reach an object-schema ability asnulland fail validation. It also sendsWP_Errordata to the model, and returns errors in a form callers can't reliably tell from a successful result.Implementation
Short names stay wherever they're a contract or stored data:
wpab__desktop-mode__search-postsopenstation_ai_tools,openstation_ai_search_generate,resumeToolsearch_posts, translated inopenstation_ai_search_generate()openstation_agent_runner_generate(Experimental)$tool_defscarry core names; a call may use either nameopenstation_agent_tool_resultDefault agent instructions are copied into user meta when an agent is created, so they say things like "get_post the source". A guide travels with the prompt so those and any custom instructions keep working, and agents still accept a short name if a model uses one:
Two guards stay on purpose:
openstation_ai_search_ability_names()rechecks the annotation after core's query. It's the only thing keeping write abilities away from a model reading untrusted text, andwp_get_abilities_resultcan reshape the query's result.Docs:
docs/hooks-reference.md.Testing instructions
Results on WordPress 7.1.4:
I also ran the real AI Client and
ai-provider-for-anthropicwith HTTP intercepted and a scripted model, for one Copilot search and one agent run:openstation_ai_tool_calledstill reportedsearch_posts.Not tested:
🤖 Generated with Claude Code