Skip to content

Add method to get an agent's output JSON schema #3225

@DouweM

Description

@DouweM

Description

It'd be useful to have a new output_json_schema property on AbstractAgent.

In the case of the concrete Agent, it would depend on agent._output_schema:

  • if StructuredTextOutputSchema (superclass of NativeOutputSchema and PromptedOutputSchema), get it from .object_def.json_schema
  • if it's OutputSchemaWithoutMode, get it from .processor.object_def.json_schema
  • if it's PlainTextOutputSchema, it's just {'type': 'string'}
  • if it's ToolOutputSchema, we need to create a union schema of all .toolset.processors using UnionOutputProcessor, which currently takes a sequence of output types and creates ObjectOutputProcessors for them on the fly, but could also take a sequence of ObjectOutputProcessors (the ones we get from .toolset.processors) directly. Once we have that UnionOutputProcessor, the schema is on .object_def.json_schema
  • if it's ToolOrTextOutputSchema, it's the above or {'type': 'string'}

(This is slightly outdated as I did some refactoring here recently, but it's directionally correct)

Needed for:

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions