Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

Merge pull request #8232 from senamakel/fix/dedupe-deferred-tool-snapshot

Steven Enamakel4ca3028233d0
diff --cc crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
index ea50fae664,0b2d695250..0330c99193
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/prelude.rs
@@@ -362,13 -349,42 +349,49 @@@ impl OpenHumanTurnPrelude
&self,
receipt: &CommitReceipt<OpenHumanRunContext>,
) {
- self.memory_post_turn(receipt);
+ // A plan that finished this turn hands its notes over: they stay for
+ // the thread's next turns and go to long-term memory with the reply.
+ let finished_plan = crate::agent::tinyagents::state_block::close_finished_plan(
+ &self.workspace_dir,
+ self.thread_id.as_deref(),
+ )
+ .await;
+ self.memory_post_turn(receipt, finished_plan);
}
}
+
+ /// The declarations a turn's snapshot grants: the advertised specs, then the
+ /// deferred ones, name-unique.
+ ///
+ /// A deferred name can have two registrations -- a host tool spliced in ahead
+ /// of a config-derived built-in of the same name (`HostTurnTools::merge_into`).
+ /// The advertised list is already deduplicated, but `tool_specs` is the raw
+ /// registry, so both would reach `ToolSnapshot::new`, which refuses two
+ /// different declarations under one name and fails the whole turn. The first
+ /// occurrence wins, as it does for the advertised list, so the host's tool is
+ /// the one granted.
+ fn granted_tool_specs(
+ visible: &[Arc<tinytools::ToolSpec>],
+ registered: &[Arc<tinytools::ToolSpec>],
+ deferred: &std::collections::HashSet<String>,
+ has_thread: bool,
+ ) -> Vec<tinytools::ToolSpec> {
+ let specs = visible
+ .iter()
+ .chain(
+ registered
+ .iter()
+ .filter(|spec| deferred.contains(&spec.name)),
+ )
+ .filter(|spec| {
+ has_thread
+ || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(&spec.name)
+ })
+ .map(|spec| spec.as_ref().clone())
+ .collect();
+ super::super::builder::dedup_visible_tool_specs(specs)
+ }
+
+ #[cfg(test)]
+ #[path = "prelude_tests.rs"]
+ mod tests;