The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(agent): add post-commit hook for learning sink
Steven Enamakel854594655b82
diff --git a/crates/openhuman-core/src/agent/hooks.rs b/crates/openhuman-core/src/agent/hooks.rsindex 1add09e49f..9f3c015bd2 100644--- a/crates/openhuman-core/src/agent/hooks.rs+++ b/crates/openhuman-core/src/agent/hooks.rs@@ -309,23 +309,27 @@ pub fn embedder_tool_hooks_in(ctx: &crate::core::runtime::DispatchCtx) -> Vec<Armod tests;/// Fire all hooks in parallel, logging errors without blocking the caller.-pub fn fire_hooks(hooks: &[Arc<dyn PostTurnHook>], ctx: TurnContext) {+pub fn fire_hooks(+ hooks: &[Arc<dyn PostTurnHook>],+ dispatch: &crate::core::runtime::DispatchCtx,+ ctx: TurnContext,+) {log::debug!("[learning] dispatching {} post-turn hook(s) (tool_calls={}, response_chars={})",hooks.len(),ctx.tool_calls.len(),ctx.assistant_response.chars().count());- // Capture the ambient CoreContext before detaching: a bare `tokio::spawn`+ // Take the caller's CoreContext before detaching: a bare `tokio::spawn`// does not inherit the `CURRENT_CONTEXT` task-local, so under a scoped// multi-tenant dispatch a detached hook would fall back to the process// default context — and anything context-derived inside the hook (for// example a workspace-scoped store) would read and// write another tenant's workspace. Re-entering the scope inside the task// keeps the hook on the dispatch it belongs to; when there is no scoped- // context (the desktop's single-tenant path), `current()` already answers- // the process default and re-scoping it is a no-op.- let core_ctx = crate::core::runtime::context::CoreContext::current();+ // context (the desktop's single-tenant path), the process default is+ // already what the hook reads and re-scoping it is a no-op.+ let core_ctx = dispatch.core().cloned();for (idx, hook) in hooks.iter().enumerate() {let hook = Arc::clone(hook);let ctx = ctx.clone();diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rsindex 919fb1c98e..f7c1dac202 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/post_commit.rs@@ -132,6 +132,8 @@ pub(super) async fn finalize_committed_turn(receipt: tinyagents_runtime::CommitReceipt<crate::agent::tinyagents::host::OpenHumanRunContext>,) {let commit_started = std::time::Instant::now();+ // The turn's own context, taken before the receipt is dropped.+ let dispatch = receipt.options.context.dispatch_ctx();let output = receipt.outcome.output.clone().unwrap_or_default();// Skips compaction checkpoints (user-role, not the user's words).let input = tinyagents_harness::summarization::last_user_message(&receipt.outcome.history)@@ -235,6 +237,7 @@ pub(super) async fn finalize_committed_turn(}crate::agent::hooks::fire_hooks(post_turn_hooks,+ &dispatch,crate::agent::hooks::TurnContext {user_message: input,assistant_response: output,diff --git a/crates/openhuman-core/src/agent/tinyagents/host/learning_sink.rs b/crates/openhuman-core/src/agent/tinyagents/host/learning_sink.rsindex dd8a5f4aa8..d97958d60b 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/learning_sink.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/learning_sink.rs@@ -112,7 +112,12 @@ impl LearningSink for OpenHumanLearningSink {self.hooks.len());- hooks::fire_hooks(&self.hooks, Self::turn_context_from(summary));+ // Transitional (#7801): the learning sink is built without a context.+ hooks::fire_hooks(+ &self.hooks,+ &crate::core::runtime::DispatchCtx::ambient(),+ Self::turn_context_from(summary),+ );Ok(())}}