fix: export ToolContext, MCPToolChoice, and RequestUsage from agents#3579
Closed
jawwad-ali wants to merge 1 commit into
Closed
fix: export ToolContext, MCPToolChoice, and RequestUsage from agents#3579jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
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.
Member
|
Thanks for the suggestion, but we don't intend to export everything from the top level module. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ToolContext,MCPToolChoice, andRequestUsageare user-facing types that currently require submodule imports.ToolContextis the documented context type for function tools (docs/context.md— even the repo's own examples import it fromagents.tool_context),MCPToolChoiceis theModelSettings.tool_choicevalue for forcing a specific hosted MCP tool, andRequestUsageis the element type ofUsage.request_usage_entries. This re-exports them from the top-levelagentspackage, following the same pattern as #3489 and #3490. Existing submodule import paths keep working, so no docs changes are needed.Test plan
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, andtest_exported_names_resolve_to_attributes(asserts every name inagents.__all__resolves viagetattr).make format,make lint, and pyright pass; mypy reports only pre-existing errors also present on cleanmain.main(local environment-related, unrelated to this change).Issue number
None — follow-up to the export gaps addressed in #3489/#3490.
Checks
make lintandmake format