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
refactor(agent): use canonical tool call format from tinytools
Steven Enamakele45b60415a16
diff --git a/crates/openhuman-core/src/agent/prompts/types.rs b/crates/openhuman-core/src/agent/prompts/types.rsindex 4255f621f3..58876451f3 100644--- a/crates/openhuman-core/src/agent/prompts/types.rs+++ b/crates/openhuman-core/src/agent/prompts/types.rs@@ -249,68 +249,6 @@ pub fn swap_deferred_for_discovery_bridge<'a>(}}-/// How TinyTools should render and parse an agent's tool calls.-///-/// The prompt layer carries this only to select the TinyTools dialect; it does-/// not define a tool-call protocol of its own.-#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]-pub enum ToolCallFormat {- /// Compact positional legacy dialect.- PFormat,- /// JSON-in-tag rendering with full schemas. The default.- #[default]- Json,- /// Provider supplies structured tool calls — catalogue is- /// informational. Renders in the same JSON-schema form as `Json`.- Native,- /// Python `def` signatures; the model calls `name(arg="value")`.- Python,- /// TypeScript `function` signatures; the model calls `name({arg: "value"})`.- TypeScript,-}--impl ToolCallFormat {- /// The harness policy that speaks this format.- ///- /// `Native` maps to `Auto` rather than forcing native: the session only- /// picks it when the provider profile supports native tools, and `Auto`- /// resolves to the same thing while still letting the harness fall back- /// for a model that turns out not to.- pub(crate) fn harness_dispatcher(self) -> tinyagents_harness::config::ToolDispatcher {- use tinyagents_harness::config::ToolDispatcher;- match self {- ToolCallFormat::PFormat => ToolDispatcher::Pformat,- ToolCallFormat::Json => ToolDispatcher::Xml,- ToolCallFormat::Native => ToolDispatcher::Auto,- ToolCallFormat::Python => ToolDispatcher::Python,- ToolCallFormat::TypeScript => ToolDispatcher::Typescript,- }- }-- /// The code style behind a code-call format, `None` for the others.- pub(crate) fn code_style(self) -> Option<tinytools_agent::dialect::CodeStyle> {- match self {- ToolCallFormat::Python => Some(tinytools_agent::dialect::CodeStyle::Python),- ToolCallFormat::TypeScript => Some(tinytools_agent::dialect::CodeStyle::TypeScript),- ToolCallFormat::PFormat | ToolCallFormat::Json | ToolCallFormat::Native => None,- }- }-}--/// Map the canonical dialect's catalogue spelling onto the host prompt wire-/// vocabulary at the prompt boundary.-pub(crate) fn tool_call_format_from_dialect(- format: tinytools_agent::dialect::ToolCallFormat,-) -> ToolCallFormat {- match format {- tinytools_agent::dialect::ToolCallFormat::PFormat => ToolCallFormat::PFormat,- tinytools_agent::dialect::ToolCallFormat::Json => ToolCallFormat::Json,- tinytools_agent::dialect::ToolCallFormat::Native => ToolCallFormat::Native,- tinytools_agent::dialect::ToolCallFormat::Python => ToolCallFormat::Python,- tinytools_agent::dialect::ToolCallFormat::TypeScript => ToolCallFormat::TypeScript,- }-}-// ─────────────────────────────────────────────────────────────────────────────// Authenticated user identity// ─────────────────────────────────────────────────────────────────────────────@@ -361,7 +299,7 @@ pub struct PromptContext<'a> {/// When non-empty, only tools in this set are rendered. Skills/// section is also omitted when a filter is active.pub visible_tool_names: &'a std::collections::HashSet<String>,- pub tool_call_format: ToolCallFormat,+ pub tool_call_format: tinytools_agent::dialect::ToolCallFormat,/// Active Composio integrations the user has connected.pub connected_integrations: &'a [ConnectedIntegration],/// Pre-rendered `## Connected Identities` markdown block loaded oncediff --git a/crates/openhuman-core/src/agent/session_host/builder/dispatcher.rs b/crates/openhuman-core/src/agent/session_host/builder/dispatcher.rsdeleted file mode 100644index e759be0967..0000000000--- a/crates/openhuman-core/src/agent/session_host/builder/dispatcher.rs+++ /dev/null@@ -1,40 +0,0 @@-//! Which tool-call dialect a session speaks to its provider, resolved from-//! the configured `agent.tool_dispatcher` choice and the provider's native-//! tool support.--use tinytools_agent::dialect::CodeStyle;--/// Which tool-call dialect a session speaks to its provider.-#[derive(Debug, Clone, Copy, PartialEq, Eq)]-pub(super) enum DispatcherKind {- /// Provider-native structured function calling (JSON tool specs on the wire).- Native,- /// JSON-in-tag: `<tool_call>{"name":…,"arguments":{…}}</tool_call>` in text.- Xml,- /// Compact positional P-Format (`tool[a|b]`) — opt-in only.- PFormat,- /// Code-style calls against Python or TypeScript signatures — opt-in only.- Code(CodeStyle),-}--/// Pick the tool-call dialect from the configured `agent.tool_dispatcher`-/// choice and the provider's native-tool support.-///-/// `"auto"` (and any unrecognized value) resolves to native when the provider-/// supports it, otherwise JSON-in-tag — **never** P-Format or a code dialect,-/// which are opt-in (`"pformat"`, `"python"`, `"typescript"`) because their-/// compact syntaxes mis-parse on some models.-pub(super) fn resolve_dispatcher_kind(- dispatcher_choice: &str,- supports_native: bool,-) -> DispatcherKind {- match dispatcher_choice {- "native" => DispatcherKind::Native,- "xml" => DispatcherKind::Xml,- "pformat" => DispatcherKind::PFormat,- "python" => DispatcherKind::Code(CodeStyle::Python),- "typescript" => DispatcherKind::Code(CodeStyle::TypeScript),- _ if supports_native => DispatcherKind::Native,- _ => DispatcherKind::Xml,- }-}diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rsindex 7382bac21d..af97da8e42 100644--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs@@ -1,6 +1,5 @@//! `OpenHumanSessionHost::from_config` factory methods and internal `build_session_agent_inner` constructor.-use super::dispatcher::{resolve_dispatcher_kind, DispatcherKind};use super::host_tools::derive_turn_workspace_descriptor;use super::should_synthesize_delegation_tools;use crate::agent::harness::host_definition::{@@ -640,14 +639,20 @@ impl OpenHumanSessionHost {.chain(delegation_tools.iter()).map(|tool| (tool.name(), tool.parameters_schema())),);- let dispatcher_kind = resolve_dispatcher_kind(&dispatcher_choice, supports_native);+ let dispatcher_kind =+ tinytools_agent::dialect::ToolCallFormat::resolve(&dispatcher_choice, supports_native);let tool_dispatcher: Box<dyn ToolDialect> = match dispatcher_kind {- DispatcherKind::Native => Box::new(NativeDialect),- DispatcherKind::Xml => Box::new(XmlDialect),- DispatcherKind::PFormat => Box::new(PFormatDialect::new(pformat_registry.clone())),- DispatcherKind::Code(style) => {- Box::new(CodeDialect::new(style, pformat_registry.clone()))- }+ ToolCallFormat::Native => Box::new(NativeDialect),+ ToolCallFormat::Json => Box::new(XmlDialect),+ ToolCallFormat::PFormat => Box::new(PFormatDialect::new(pformat_registry.clone())),+ ToolCallFormat::Python => Box::new(CodeDialect::new(+ tinytools_agent::dialect::CodeStyle::Python,+ pformat_registry.clone(),+ )),+ ToolCallFormat::TypeScript => Box::new(CodeDialect::new(+ tinytools_agent::dialect::CodeStyle::TypeScript,+ pformat_registry.clone(),+ )),};log::debug!(