Skip to content

feat(hooks): expose embedded tool lifecycle hooks - #5449

Merged
senamakel merged 8 commits into
tinyhumansai:mainfrom
senamakel:embedded-openhuman-hooks
Aug 8, 2026
Merged

senamakel merged 8 commits into
tinyhumansai:mainfrom
senamakel:embedded-openhuman-hooks

Conversation

@senamakel

@senamakel senamakel commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

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.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel requested a review from a team August 8, 2026 10:44

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aff581d9-fdc0-45c5-b094-9f69c4b6e882

📥 Commits

Reviewing files that changed from the base of the PR and between 8ec2db1 and 60ae43f.

📒 Files selected for processing (4)
  • src/openhuman/agent/harness/session/builder/factory.rs
  • src/openhuman/agent/hooks.rs
  • src/openhuman/agent/tinyagents/middleware.rs
  • src/openhuman/agent/tinyagents/mod.rs

Comment @coderabbitai help to get the list of available commands.

Co-authored-by: Medulla <medulla@tinyhumans.ai>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/openhuman/agent/tinyagents/mod.rs Outdated
Comment thread src/openhuman/agent/tinyagents/middleware.rs Outdated
@senamakel senamakel self-assigned this Aug 8, 2026
senamakel and others added 5 commits August 8, 2026 13:51
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>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 8, 2026
Checkpoint of work in progress, touching src/openhuman/agent/tinyagents/middleware.rs.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +132 to +133
/// The provider call id for correlating pre- and post-hook records.
pub call_id: String,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@senamakel
senamakel merged commit 5c8cc41 into tinyhumansai:main Aug 8, 2026
20 checks passed
senamakel added a commit to nocstah/openhuman that referenced this pull request Sep 11, 2026
…n-hooks\n\nfeat(hooks): expose embedded tool lifecycle hooks\n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant