Skip to content

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

merge: sync PR 6982 with upstream and fix workspace build

Steven Enamakel97b0afa8c86f
diff --cc crates/openhuman-core/src/agent/session_host/managed_tools.rs
index 0000000000,93f626204b..ed3e2ca89b
mode 000000,100644..100644
--- a/crates/openhuman-core/src/agent/session_host/managed_tools.rs
+++ b/crates/openhuman-core/src/agent/session_host/managed_tools.rs
@@@ -1,0 -1,60 +1,60 @@@
+ //! Refresh only the attached-tool catalogue; keep the host prefix frozen.
+ use std::{collections::HashSet, sync::Arc};
+ use tinyagents_runtime::PrefixSnapshot;
+ use tinyinference_llm::message::Message;
+ use tinytools::ToolSpec;
+ const MARKER: &str = "<openhuman-permanent-tools>\n";
+ pub(super) fn refresh_prefix(
+ prefix: &PrefixSnapshot,
+ specs: &[Arc<ToolSpec>],
+ names: &HashSet<String>,
+ ) -> Option<PrefixSnapshot> {
+ if names.is_empty() {
+ return None;
+ }
+ let mut messages: Vec<Message> = prefix
+ .messages()
+ .iter()
+ .filter(|message| !message.text().starts_with(MARKER))
+ .cloned()
+ .collect();
+ let mut entries: Vec<&ToolSpec> = specs
+ .iter()
+ .filter(|spec| names.contains(&spec.name))
+ .map(AsRef::as_ref)
+ .collect();
+ entries.sort_by(|a, b| a.name.cmp(&b.name));
+ let catalogue = entries
+ .iter()
+ .map(|spec| {
+ format!(
+ "{}: {}\nParameters: {}",
+ spec.name, spec.description, spec.parameters
+ )
+ })
+ .collect::<Vec<_>>()
+ .join("\n\n");
+ messages.push(Message::system(format!(
+ "{MARKER}{catalogue}\n</openhuman-permanent-tools>"
+ )));
+ if messages == prefix.messages() {
+ None
+ } else {
- Some(PrefixSnapshot::new(messages).refreshing())
++ Some(PrefixSnapshot::new(messages))
+ }
+ }
+
+ /// Check before deduplication, preserving the existing synthesized executors
+ /// and schemas if a new permanent source would shadow them.
+ pub(super) fn reject_synthesized_collisions(
+ names: &HashSet<String>,
+ synthesized: &[Box<dyn tinytools::Tool>],
+ ) -> anyhow::Result<()> {
+ if let Some(tool) = synthesized.iter().find(|tool| names.contains(tool.name())) {
+ anyhow::bail!(
+ "permanent tool name collision with synthesized tool: {}",
+ tool.name()
+ );
+ }
+ Ok(())
+ }