Skip to content

docs: clarify ToolContext availability in function-tool lifecycle hooks#2687

Open
HuxleyHu98 wants to merge 1 commit intoopenai:mainfrom
HuxleyHu98:clarify-toolcontext-lifecycle-hooks
Open

docs: clarify ToolContext availability in function-tool lifecycle hooks#2687
HuxleyHu98 wants to merge 1 commit intoopenai:mainfrom
HuxleyHu98:clarify-toolcontext-lifecycle-hooks

Conversation

@HuxleyHu98
Copy link

Summary

Clarify and test that function-tool lifecycle hooks receive ToolContext, making tool-call metadata such as tool_call_id available from hook callbacks.

What changed

  • Added tests covering ToolContext availability in function-tool lifecycle hooks for:
    • agent-scoped hooks
    • run/global hooks
  • Updated lifecycle hook docstrings to clarify that function-tool invocations typically receive ToolContext
  • Updated docs to note that some runtime-specific callbacks receive specialized RunContextWrapper subclasses, including ToolContext

Why

Issue #1849 asks for access to tool-call identifiers from lifecycle hooks. While the runtime already passes ToolContext for 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 -q
  • uv run pytest tests/test_agent_llm_hooks.py tests/test_computer_action.py tests/test_run_step_execution.py -q

@github-actions github-actions bot added documentation Improvements or additions to documentation feature:core labels Mar 16, 2026
@seratch seratch added this to the 0.14.x milestone Mar 17, 2026
@seratch seratch changed the title Clarify ToolContext availability in function-tool lifecycle hooks docs: clarify ToolContext availability in function-tool lifecycle hooks Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants