Skip to content

Conversation

@Griffon-Weglot
Copy link

Q A
Bug fix? yes
New feature? no
Docs? no
Issues Fix #791
License MIT

$messages = $input->getMessageBag();
$options = $input->getOptions();

if (isset($options['output_structure'])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC we had some kind of check before, right @chr-hertel ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The way it was checked before is directly in the AgentProcessor
https://github.com/symfony/ai/pull/728/files#diff-212a36313084d7a7912d6ed09c262e978715148ce2d045aee724cfc3ec9b342cL77-L79

I think it would be better like it was before @Griffon-Weglot

Copy link
Contributor

Choose a reason for hiding this comment

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

The only issue is that it requires to call $this->platform->getModelCatalog()->getModel($input->getModel()); in the OutputProcessor (and therefor inject the platform inside the OutputProcessor).

I don't know if it's was a good win to change $input->getModel from the object to the string.

Copy link
Author

Choose a reason for hiding this comment

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

Ok i've made the changes, i agree with @VincentLanglet, injecting platform is maybe a problem

Comment on lines +83 to +85
$modelObject = $this->platform->getModelCatalog()->getModel($input->getModel());
if (!\in_array(Capability::OUTPUT_STRUCTURED, $modelObject->getCapabilities(), true)) {
throw MissingModelSupportException::forStructuredOutput($modelObject->getName());
Copy link
Member

Choose a reason for hiding this comment

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

this would be enough for me

Suggested change
$modelObject = $this->platform->getModelCatalog()->getModel($input->getModel());
if (!\in_array(Capability::OUTPUT_STRUCTURED, $modelObject->getCapabilities(), true)) {
throw MissingModelSupportException::forStructuredOutput($modelObject->getName());
$model = $this->platform->getModelCatalog()->getModel($input->getModel());
if (!\in_array(Capability::OUTPUT_STRUCTURED, $model->getCapabilities(), true)) {
throw MissingModelSupportException::forStructuredOutput($model->getName());

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with the new pattern.

Is it ok to inject the platform every time we need the capabilities ; or would it be better to have the model instance directly in the input like it was before @chr-hertel ?

Comment on lines +41 to +46
if (!class_exists(__NAMESPACE__.'\ConfigurableResponseFormatFactory')) {
class ConfigurableResponseFormatFactory implements ResponseFormatFactoryInterface {
public function __construct(private array $format = []) {}
public function create(string $structure): array { return $this->format; }
}
}
Copy link
Member

Choose a reason for hiding this comment

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

do we need this? there is already Symfony\AI\Agent\Tests\StructuredOutput\ConfigurableResponseFormatFactory

@chr-hertel
Copy link
Member

Let's please put this to hold - most likely gonna be replaced with #802

Thanks anyways @Griffon-Weglot - also for second the necessity to bring back the validation!

@VincentLanglet
Copy link
Contributor

Let's please put this to hold - most likely gonna be replaced with #802

Thanks anyways @Griffon-Weglot - also for second the necessity to bring back the validation!

Am I wrong or @Griffon-Weglot could/should still open a PR after #802 in order to update/fix the supported capabilities of Gemini ? (And this can be done already since it shouldn't conflict with your work @chr-hertel)

@chr-hertel
Copy link
Member

@VincentLanglet that is correct

@chr-hertel chr-hertel changed the title Fix structured output capability check for unsupported models [Platform] Fix structured output capability check for unsupported models Oct 23, 2025
@chr-hertel chr-hertel added the Platform Issues & PRs about the AI Platform component label Oct 23, 2025
chr-hertel added a commit that referenced this pull request Oct 24, 2025
…Platform component (chr-hertel)

This PR was merged into the main branch.

Discussion
----------

[Agent][Platform] Shift structured output from Agent to Platform component

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Docs?         | no
| Issues        |
| License       | MIT

The main differentiator between the Agent and the Platform component is that the Agent is designed for multi-step model interaction and this is not the case for structured output. In the beginning the feature was also a bit more heavy than the light platform, since it was using the Serializer, and the Platform not having extension points for it.

Nowadays the Platform uses the Serializer anyways for the contract handling, and relies on a optional EventDispatcher, that now also can provide the needed extension points.

Secondary goals where to introduce a `ResultEvent` and bring back user-land validation for structured output capability of model.

Fixes #791, replaces #794

<img width="1765" height="359" alt="image" src="https://github.com/user-attachments/assets/df9fc29f-fc90-4094-8c2f-10f01535dbfa" />

Commits
-------

8110d13 Shift structured output from Agent to Platform component
Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

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

Hey @Griffon-Weglot, i just merged #802 - can you please rebase and reduce the scope of this PR to fix the capabilities in the Gemini and VertexAI model catalog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform Issues & PRs about the AI Platform component Status: Needs Work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Capability::OUTPUT_STRUCTURED is incorrectly listed for Gemini < 2.5 and lacks a proper exception

5 participants