Repository navigation
feat(hooks): expose embedded tool lifecycle hooks - #5449
Conversation
Co-authored-by: Medulla <medulla@tinyhumans.ai>
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Comment |
Co-authored-by: Medulla <medulla@tinyhumans.ai>
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d88a2f0a86
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/mod.rs. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/mod.rs. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/middleware.rs. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/middleware.rs. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/middleware.rs. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 367dd7540d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| None | ||
| }; | ||
|
|
||
| post_turn_hooks.extend(crate::openhuman::agent::hooks::embedder_post_turn_hooks()); |
There was a problem hiding this comment.
Apply registered post-turn hooks to AgentBuilder sessions
When an embedder constructs the public agent entry point via Agent::builder(), this extension is never reached: AgentBuilder::build copies only self.post_turn_hooks into the session. Consequently, a hook registered through register_embedder_post_turn_hook is silently absent from those subsequently created sessions, contrary to the registration API's contract; merge the global snapshot in the common builder path instead of only in the from_config factory.
Useful? React with 👍 / 👎.
| // summarization/cap or tool-outcome capture layers. | ||
| let embedder_tool_hooks = crate::openhuman::agent::hooks::embedder_tool_hooks(); | ||
| if !embedder_tool_hooks.is_empty() { | ||
| harness.push_middleware(Arc::new(middleware::EmbedderToolHooksMiddleware::new( |
There was a problem hiding this comment.
Invoke lifecycle hooks only after tool admission
When the model emits an unknown tool name, this generic middleware's before_tool runs before the harness applies UnknownToolPolicy::ReturnToolError (the ordering is explicitly noted in the policy setup near TaToolPolicyMiddleware). The embedder therefore receives a PreToolUse event whose supposedly registered tool will never execute, and an authorization hook that rejects it replaces OpenHuman's recoverable unknown-tool response with the hook error. Schema-invalid calls have the same pre-admission problem; place this callback at the admitted tool-dispatch boundary or explicitly skip calls that will be rejected before execution.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60ae43f37f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// The provider call id for correlating pre- and post-hook records. | ||
| pub call_id: String, |
There was a problem hiding this comment.
Scope lifecycle events to their agent run
When multiple sessions execute tools concurrently, call_id alone cannot reliably correlate lifecycle events because the hook is process-global while call IDs are only local to a model response; for example, prompt-parsed calls synthesize IDs as call_0, call_1, etc. on every response (src/openhuman/agent/tinyagents/model.rs:101-105). Two sessions can therefore emit indistinguishable pre/post records, preventing an auditing or authorization host from attributing a call to the correct session, agent, or entrypoint. Include a run/session identifier in ToolHookContext or namespace the exposed call ID.
Useful? React with 👍 / 👎.
…n-hooks\n\nfeat(hooks): expose embedded tool lifecycle hooks\n
OpenHuman can now receive lifecycle hooks from its embedding host.
The new hook surface runs before and after actual tinyagents tool dispatch, and carries embedding-host post-turn hooks into newly created sessions. Pre-tool hooks can veto execution; post-tool hooks are observer-only.
Validation:
cargo fmt --check.This is the dependency for the Medulla wiring PR.