Skip to content

Conversation

@g-eoj
Copy link
Contributor

@g-eoj g-eoj commented Nov 17, 2025

Closes #3225

Note: there is still some discussion whether output_json_schema should be a property or method: #3225 (comment)

Need help with:

  • AutoOutputSchema expected output schema?
  • ImageOutputSchema expected output schema?
  • In ToolOutputSchema, toolset can be None... how to handle?

@g-eoj
Copy link
Contributor Author

g-eoj commented Nov 17, 2025

@DouweM is there a source of truth I can reference for what the schema output should be for tests? I think I will get stuck figuring this out so any guidance will be appreciated.

Edit: I added snapshots of expected output to the tests. Please review them carefully as I'm guessing what they are supposed to be.

@g-eoj g-eoj marked this pull request as ready for review November 17, 2025 21:23
@g-eoj g-eoj changed the title Add output_json_schema property to Agents Add output_json_schema method to Agent class Nov 19, 2025
return self.text_processor is not None

@abstractmethod
def dump(self) -> JsonSchema:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we call the method json_schema()?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If allows_deferred_tools is True, we should add the schema of DeferredToolRequests to the output union

Same for allows_image and BinaryImage.

So we may have to implement that here, and then have the subclass methods call super() and combine that with the union somehow.

return 'image'

def dump(self) -> JsonSchema:
raise NotImplementedError()
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use the schema of BinaryImage

processors.append(processor)
return UnionOutputProcessor(processors).object_def.json_schema

return self.processor.object_def.json_schema
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need the toolset logic; this one should always be present

processor.object_def.name = tool_def.name
processor.object_def.description = tool_def.description
processors.append(processor)
return UnionOutputProcessor(processors).object_def.json_schema
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm this is a bit ugly :) Can we add a new json_schema property to OutputToolset, and then generate this inside OutputToolset.build, where we already have the processors etc?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If self.allows_text is enabled, we should add {type: string} to the union. (similar to what I said above). We may need some logic to take a UnionOutputProcessor and basically add a new branch to it, (instead of ending up with nested unions that could be flattened)

if isinstance(output, ObjectOutputProcessor):
processor = output
else:
processor = ObjectOutputProcessor(output=output, strict=strict)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did we need to change this?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add method to get an agent's output JSON schema

2 participants