Skip to content

fix: export ToolContext, MCPToolChoice, and RequestUsage from agents#3579

Closed
jawwad-ali wants to merge 1 commit into
openai:mainfrom
jawwad-ali:fix/export-public-types
Closed

fix: export ToolContext, MCPToolChoice, and RequestUsage from agents#3579
jawwad-ali wants to merge 1 commit into
openai:mainfrom
jawwad-ali:fix/export-public-types

Conversation

@jawwad-ali
Copy link
Copy Markdown
Contributor

Summary

ToolContext, MCPToolChoice, and RequestUsage are user-facing types that currently require submodule imports. ToolContext is the documented context type for function tools (docs/context.md — even the repo's own examples import it from agents.tool_context), MCPToolChoice is the ModelSettings.tool_choice value for forcing a specific hosted MCP tool, and RequestUsage is the element type of Usage.request_usage_entries. This re-exports them from the top-level agents package, following the same pattern as #3489 and #3490. Existing submodule import paths keep working, so no docs changes are needed.

Test plan

  • Added tests/test_public_type_exports.py: test_tool_context_is_exported_at_top_level, test_mcp_tool_choice_is_exported_at_top_level, test_request_usage_is_exported_at_top_level, and test_exported_names_resolve_to_attributes (asserts every name in agents.__all__ resolves via getattr).
  • make format, make lint, and pyright pass; mypy reports only pre-existing errors also present on clean main.
  • Full test suite run locally; the new tests pass and the only failures are pre-existing on clean main (local environment-related, unrelated to this change).

Issue number

None — follow-up to the export gaps addressed in #3489/#3490.

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

These are user-facing types that previously required submodule
imports: ToolContext is the documented context type for function
tools, MCPToolChoice is the ModelSettings.tool_choice value for
forcing a hosted MCP tool, and RequestUsage is the element type of
Usage.request_usage_entries. Re-export them from the top-level
package and add a regression test covering the public export surface.
@seratch
Copy link
Copy Markdown
Member

seratch commented Jun 4, 2026

Thanks for the suggestion, but we don't intend to export everything from the top level module.

@seratch seratch closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants