[#281] Add generic metadata to function declarations - #282
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #282 +/- ##
============================================
+ Coverage 86.54% 86.58% +0.03%
- Complexity 1381 1383 +2
============================================
Files 69 69
Lines 4438 4449 +11
============================================
+ Hits 3841 3852 +11
Misses 597 597
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
|
Updated this PR to follow the function-annotations direction: the only production change is now generic metadata on All The OpenAI provider experiment (#50) now consumes Verification: client 1,202 tests / 4,366 assertions and lint passed; provider 93 tests / 604 assertions (one existing skip) and lint passed. No live usefulness/cost benchmark has been claimed. aidevops.sh v3.32.317 plugin for OpenCode v1.18.30 with gpt-6-astra spent 1h 10m and 559,833 tokens on this with the user in an interactive session. |
JasonTheAdams
left a comment
There was a problem hiding this comment.
Thank you, @superdav42 ! A few small suggstions.
There was a problem hiding this comment.
Please update ARCHITECTURE.md instead of adding this.
| * description: string, | ||
| * parameters?: array<string, mixed> | ||
| * parameters?: array<string, mixed>, | ||
| * metadata?: array<string, mixed> |
There was a problem hiding this comment.
I like the word annotations and like that it's consistent with the AI SDK. Let's go with that as our word.
There was a problem hiding this comment.
The descriptions throughout this are inconsistent. Let's clean that up.
Summary
Revised following stakeholder feedback to add only generic function metadata, while tool-search behavior is explored in provider plugins.
The SDK stores annotations but does not interpret their names or values. The motivating provider experiment can combine function metadata with existing
ModelConfig::setCustomOptions(['deferredLoading' => true]); no feature-specific core option is introduced.Scope
One production file:
src/Tools/DTO/FunctionDeclaration.php.array $metadata = []constructor argument.getMetadata()accessor and optionalmetadataarray/JSON representation.The previous proposal's
ProviderDataclass, message type, serialization changes, and tests have been removed. There are no changes to messages,PromptBuilder,ModelConfig, model requirements, or enums. There is nousingToolSearch()method or dedicated deferred-loading property.Provider experiment and limitations
Companion implementation: WordPress/ai-provider-for-openai #50.
The provider owns annotation semantics, automatic activation above 10 functions, model eligibility, and request-level overrides. It translates recognized annotations into native wire fields rather than blindly forwarding metadata. Automatic/request-level behavior also works with released SDK 1.3.1; only per-function annotations need this extension.
The experiment uses OpenAI-managed state via the existing
previous_response_idcustom option, with only new input/function results on subsequent turns. Stateless replay of search output is explicitly outside this proposal. This avoids adding any new message representation before the feature has demonstrated value.For #281. This is an extension point, not a claim to complete provider adoption or establish tool-search utility.
Reference and review map
src/Tools/DTO/FunctionDeclaration.php: follows its existing constructor/accessor/schema/array transformation pattern.tests/unit/Tools/DTO/FunctionDeclarationTest.php: legacy serialization shape, arbitrary nested annotations, boolean false/null preservation, array/JSON round trips, model-config round trips, and clone/getter independence for array metadata.docs/FUNCTION_METADATA.md: generic contract, naming guidance, provider interpretation, and experiment boundaries.providerOptionsfor comparable provider-owned settings. Its documented deferred-loading API is explicit rather than count-triggered.Verification
composer test:unit: 1,202 tests, 4,366 assertions passed.composer lint: PHPCS and PHPStan passed.trunkremains undersrc/Messages/ortests/unit/Messages/.aidevops.sh v3.32.317 plugin for OpenCode v1.18.30 with gpt-6-astra spent 1h 10m and 556,600 tokens on this with the user in an interactive session.