feat(hooks): add agent and tool lifecycle boundaries#18889
Open
vincentkoc wants to merge 1 commit intoopenclaw:mainfrom
Open
feat(hooks): add agent and tool lifecycle boundaries#18889vincentkoc wants to merge 1 commit intoopenclaw:mainfrom
vincentkoc wants to merge 1 commit intoopenclaw:mainfrom
Conversation
This was referenced Feb 26, 2026
d48824c to
d942194
Compare
|
🤖 We're reviewing this PR with Aisle We're running a security check on the changes in this PR now. This usually takes a few minutes. ⌛ Progress:
Latest run failed. Keeping previous successful results. Trace ID: Last updated on: 2026-03-08T04:58:46Z |
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.
Why
Agent execution lacked complete lifecycle boundaries around thinking, response generation, and tool execution, reducing traceability for observability and policy systems. This PR adds those boundaries and ensures tool lifecycle hooks carry
toolCallIdcontext when available. lobster-biscuitSplit Context
This PR was accidentally closed after a messed up rebase #12583 which was originally split from closed umbrella PR #9761: #9761.
Detailed Changes
agent:thinking:start/agent:thinking:endagent:response:start/agent:response:endagent:tool:start/agent:tool:endrunAfterToolCallHookwiring for tool execution lifecycle completiontoolCallIdthrough before/after tool hook contexts where availabletoolCallIdand run after-tool hook flowRelated Links, Issues and Resolution
Greptile Summary
This PR adds complete lifecycle boundaries for agent execution (thinking, response generation, and tool execution), improving observability and traceability for policy systems. The implementation propagates
toolCallIdthrough tool lifecycle hooks and ensures consistent hook firing across different execution paths.Key improvements:
lifecycle-hooks.tsmoduleagent:thinking:start/endfire for all agent runsagent:response:start/endhooks that only fire when response output is generatedtoolCallIdtobefore_tool_callandafter_tool_callhooksrunAfterToolCallHookwiring for both success and error paths in tool executionConfidence Score: 5/5
lifecycle-hooks.tsmodule cleanly separates concerns, all hook emission paths include error handling that logs warnings without failing execution, and the test coverage validates the core lifecycle hook behavior. ThetoolCallIdpropagation is handled consistently with proper fallbacks.Last reviewed commit: d48824c