Skip to content

Only declare function support if a model declares tools support - #94

Merged
dkotter merged 6 commits into
developfrom
fix/tools-capability
Sep 11, 2026
Merged

dkotter merged 6 commits into
developfrom
fix/tools-capability

Conversation

@dkotter

@dkotter dkotter commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description of the Change

As reported in #93, we currently declare support for function calling on every text generation model. There are some models (like gemma3) that support text generation but don't support calling functions (or tools). This can lead to the PHP AI Client assuming the model is supported for a specific request even though it won't actually work.

This PR updates that to ensure we only declare function calling support if the model itself declares tool support. Also introduced some slight refactoring in a new getModelCapabilities method. And we also ensure we show Tools as a supported option on our settings page.

Before After
Screenshot 2026-09-09 at 1 52 03â€ŊPM Screenshot 2026-09-09 at 2 01 56â€ŊPM

Closes #93

How to test the Change

Please see the detailed steps in #93

Changelog Entry

Fixed - Ensure we only declare function calling support on models that advertise support for tools

Credits

Props @saarnilauri, @dkotter

Checklist:

Open WordPress Playground Preview

@dkotter dkotter added this to the 1.3.0 milestone Sep 9, 2026
@dkotter dkotter self-assigned this Sep 9, 2026
@dkotter

dkotter commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

Note tests that run on PHP 7.4 and 8.0 are currently failing due to an upstream issue with those environments that has been fixed but not released yet: WordPress/gutenberg#82478

@saarnilauri saarnilauri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested the fix in the setup I encountered the bug and the fix is verified. I left few comments while I reviewd the code changes.

Comment thread src/admin/settings/style.scss Resolved
Comment thread src/admin/settings/index.ts Resolved
@dkotter
dkotter requested a review from saarnilauri September 10, 2026 16:13

@saarnilauri saarnilauri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

( option ) =>
option.name === 'inputModalities' ||
option.name === 'input_modalities'
( option ) => option.name === 'inputModalities'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Even I noticed this in the PHP AI client PR, did not realize that input_modalities existed in the plugin as well.

@dkotter
dkotter merged commit dccf75d into develop Sep 11, 2026
26 checks passed
@dkotter
dkotter deleted the fix/tools-capability branch September 11, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

function_declarations is declared for every completion model, so tool-incapable models pass tool-support filtering and fail late with a 400 from Ollama

2 participants