docs: clarify ToolContext availability in function-tool lifecycle hooks#2687
Open
HuxleyHu98 wants to merge 1 commit intoopenai:mainfrom
Open
docs: clarify ToolContext availability in function-tool lifecycle hooks#2687HuxleyHu98 wants to merge 1 commit intoopenai:mainfrom
HuxleyHu98 wants to merge 1 commit intoopenai:mainfrom
Conversation
seratch
approved these changes
Mar 17, 2026
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
Clarify and test that function-tool lifecycle hooks receive
ToolContext, making tool-call metadata such astool_call_idavailable from hook callbacks.What changed
ToolContextavailability in function-tool lifecycle hooks for:ToolContextRunContextWrappersubclasses, includingToolContextWhy
Issue #1849 asks for access to tool-call identifiers from lifecycle hooks. While the runtime already passes
ToolContextfor function-tool invocations, that behavior was not clearly documented or covered by tests. This change formalizes the current behavior without introducing a breaking API change.Scope
This PR intentionally limits itself to function-tool lifecycle hooks.
It does not change hook signatures and does not attempt to unify all local tool families under
ToolContext.Validation
uv run pytest tests/test_agent_hooks.py tests/test_global_hooks.py tests/test_run_hooks.py -quv run pytest tests/test_agent_llm_hooks.py tests/test_computer_action.py tests/test_run_step_execution.py -q