Skip to content

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

feat: add code-style tool dispatcher and env override

Steven Enamakel99280a63a803
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 9ed2d853b0..b6fd71ba61 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -17,7 +17,9 @@ use crate::tools;
use anyhow::Result;
use std::sync::Arc;
use tinytools::{PermissionLevel, Tool};
-use tinytools_agent::dialect::{NativeDialect, PFormatDialect, ToolDialect, XmlDialect};
+use tinytools_agent::dialect::{
+ CodeDialect, CodeStyle, NativeDialect, PFormatDialect, ToolDialect, XmlDialect,
+};
impl OpenHumanSessionHost {
/// Constructs an `OpenHumanSessionHost` instance from a global system configuration.
@@ -837,6 +839,9 @@ impl OpenHumanSessionHost {
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()))
+ }
};
log::debug!(
@@ -1133,15 +1138,17 @@ enum DispatcherKind {
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, the provider's native-tool support, and the agent id.
///
/// `"auto"` (and any unrecognized value) resolves to native when the provider
-/// supports it, otherwise JSON-in-tag — **never** P-Format, which is opt-in
-/// (`"pformat"`) because its compact positional syntax mis-parses on some
-/// models.
+/// 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.
///
/// `integrations_agent` is special-cased off native: provider-side grammar
/// decoders (e.g. Fireworks) compile every JSON tool schema into a grammar
@@ -1158,6 +1165,8 @@ fn resolve_dispatcher_kind(
"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_provider_role_tests_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/factory_provider_role_tests_tests.rs
index 1581cc862e..28af07fccb 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory_provider_role_tests_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory_provider_role_tests_tests.rs
@@ -78,6 +78,15 @@ fn explicit_choices_are_honoured_including_opt_in_pformat() {
resolve_dispatcher_kind("pformat", true, "chat"),
DispatcherKind::PFormat
);
+ // So are the code dialects.
+ assert_eq!(
+ resolve_dispatcher_kind("python", true, "chat"),
+ DispatcherKind::Code(tinytools_agent::dialect::CodeStyle::Python)
+ );
+ assert_eq!(
+ resolve_dispatcher_kind("typescript", false, "chat"),
+ DispatcherKind::Code(tinytools_agent::dialect::CodeStyle::TypeScript)
+ );
}
#[test]
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner_inner.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner_inner.rs
index 062b683ad8..039a2352b6 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner_inner.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner_inner.rs
@@ -84,6 +84,7 @@ pub(super) async fn run_turn_via_tinyagents_inner(
deterministic_cacheable,
hosted_root.is_some(),
pause_at_cap,
+ run_context.tool_dialect,
);
// Fail-closed registry validation gate (issue #4249, Workstream 10 — registry).
diff --git a/crates/openhuman-core/src/config/schema/load/env_overlay.rs b/crates/openhuman-core/src/config/schema/load/env_overlay.rs
index cecdf0de9f..3675655418 100644
--- a/crates/openhuman-core/src/config/schema/load/env_overlay.rs
+++ b/crates/openhuman-core/src/config/schema/load/env_overlay.rs
@@ -90,6 +90,21 @@ impl Config {
}
}
+ // One-launch override for the tool-call dialect experiment
+ // (`agent.tool_dispatcher`): `auto | native | xml | pformat | python |
+ // typescript`. Validation stays with the dispatcher mapping, which
+ // falls back to `auto` with a warning on an unknown spelling.
+ if let Some(raw) = env.get("OPENHUMAN_TOOL_DISPATCHER") {
+ let trimmed = raw.trim();
+ if !trimmed.is_empty() {
+ tracing::debug!(
+ dispatcher = trimmed,
+ "OPENHUMAN_TOOL_DISPATCHER overrides agent.tool_dispatcher"
+ );
+ self.agent.tool_dispatcher = trimmed.to_string();
+ }
+ }
+
if let Some(workspace) = env.get("OPENHUMAN_WORKSPACE") {
if !workspace.is_empty() {
let (_, workspace_dir) =