Skip to content

feat: expose output schema to model input filters#3691

Closed
its-amann wants to merge 1 commit into
openai:mainfrom
its-amann:expose-output-schema-filter
Closed

feat: expose output schema to model input filters#3691
its-amann wants to merge 1 commit into
openai:mainfrom
its-amann:expose-output-schema-filter

Conversation

@its-amann

Copy link
Copy Markdown

Summary

  • Exposes the effective output_schema on ModelInputData for call_model_input_filter.
  • Lets filters replace the schema for streamed and non-streamed model calls, including final-output parsing after get_new_response.
  • Preserves the existing schema when filters only edit input or instructions, and keeps ToolOutputTrimmer from dropping schema metadata.
  • Documents switching a structured-output call back to plain text with AgentOutputSchema(str).

Closes #3563

Tests

  • uv run ruff check src/agents/run_config.py src/agents/run_internal/turn_preparation.py src/agents/run_internal/run_loop.py src/agents/extensions/tool_output_trimmer.py tests/test_call_model_input_filter_unit.py tests/extensions/test_tool_output_trimmer.py tests/test_agent_runner.py tests/test_server_conversation_tracker.py
  • uv run ruff format --check src/agents/run_config.py src/agents/run_internal/turn_preparation.py src/agents/run_internal/run_loop.py src/agents/extensions/tool_output_trimmer.py tests/test_call_model_input_filter_unit.py tests/extensions/test_tool_output_trimmer.py tests/test_agent_runner.py tests/test_server_conversation_tracker.py
  • uv run pyright --project pyrightconfig.json src/agents/run_config.py src/agents/run_internal/turn_preparation.py src/agents/run_internal/run_loop.py src/agents/extensions/tool_output_trimmer.py tests/test_call_model_input_filter_unit.py tests/extensions/test_tool_output_trimmer.py tests/test_agent_runner.py tests/test_server_conversation_tracker.py
  • uv run mypy src/agents/run_config.py src/agents/run_internal/turn_preparation.py src/agents/run_internal/run_loop.py src/agents/extensions/tool_output_trimmer.py tests/test_call_model_input_filter_unit.py tests/extensions/test_tool_output_trimmer.py tests/test_agent_runner.py tests/test_server_conversation_tracker.py --exclude site
  • uv run pytest tests/test_call_model_input_filter_unit.py tests/extensions/test_tool_output_trimmer.py tests/test_agent_runner.py::test_conversation_lock_rewind_skips_when_no_snapshot tests/test_agent_runner.py::test_get_new_response_uses_agent_retry_settings tests/test_server_conversation_tracker.py::test_get_new_response_marks_filtered_input_as_sent tests/test_server_conversation_tracker.py::test_run_single_turn_streamed_marks_filtered_input_as_sent -q

@its-amann

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Note

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@seratch

seratch commented Jun 25, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution. The implementation is thoughtful, but the linked issue does not currently demonstrate a concrete use case that requires changing the output schema inside call_model_input_filter. Most known cases can select Agent.output_type before the run or use a separately configured agent.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add custom ResponseFormat support in CallModelInputFilter callback

2 participants