.agents/references/function-and-output-schema.md
Use this reference for changes to function-tool signature inspection, parameter metadata, strict JSON schema conversion, tool argument reconstruction, or structured agent output schemas.
Schema behavior is a compatibility boundary shared by Python callables, Pydantic, model providers, and runtime validation. Keep schema generation and invocation aligned rather than fixing one representation in isolation.
Annotated. Preserve Field constraints, aliases, and defaults when merging Annotated metadata.to_call_args() reconstruction consistent. Cover positional-only parameters, keyword-only parameters, *args, and **kwargs when changing this path.additionalProperties: false and marks their declared properties required. Reject an explicit additionalProperties: true instead of silently changing its meaning.oneOf where required, process allOf, retain chained references, and merge a referenced schema with sibling keys without discarding the siblings.None; a nullable type must remain represented by its type schema rather than by an unsupported default.ensure_strict_json_schema() may mutate a non-empty input dictionary. Copy caller-owned schemas at public boundaries before conversion. Empty-schema conversion must return a fresh object rather than shared mutable state.str output and no declared output type use the plain-text path. Pydantic models and dictionary-shaped outputs expose their object schema directly; other Python types use the SDK's wrapper object with the response key.Literal types. These names are observable in provider requests and diagnostics.Annotated, and Field values.src/agents/function_schema.pysrc/agents/strict_schema.pysrc/agents/tool.pysrc/agents/agent_output.pysrc/agents/models/tests/test_function_schema.pytests/test_function_tool_decorator.pytests/test_strict_schema.pytests/test_strict_schema_oneof.pytests/test_output_tool.pytests/models/