Skip to content

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

feat(config): add tool_dispatcher setting for agent tool call formatting

Steven Enamakel848f0e1b4329
diff --git a/crates/openhuman-core/src/config/ops/agent.rs b/crates/openhuman-core/src/config/ops/agent.rs
index e44fdf9cc8..a51fc09a62 100644
--- a/crates/openhuman-core/src/config/ops/agent.rs
+++ b/crates/openhuman-core/src/config/ops/agent.rs
@@ -56,8 +56,18 @@ pub struct AgentSettingsPatch {
/// root (or to a guessed user dir) is silently ignored. Going through the
/// running core writes wherever `Config::save` actually points.
pub chat_agent_id: Option<String>,
+ /// How tool calls are spoken to the model (`[agent] tool_dispatcher`):
+ /// one of [`TOOL_DISPATCHER_CHOICES`] (case-insensitive). `None` leaves it
+ /// unchanged. Takes effect for new sessions; a resumed thread keeps the
+ /// dialect its prompt was frozen with.
+ pub tool_dispatcher: Option<String>,
}
+/// Accepted spellings of `[agent] tool_dispatcher`. `auto` is the default:
+/// native structured calls when the provider supports them, else JSON-in-tag.
+pub const TOOL_DISPATCHER_CHOICES: [&str; 6] =
+ ["auto", "native", "xml", "pformat", "python", "typescript"];
+
/// Partial update for the agent's editable filesystem roots.
///
/// Only `action_dir` is editable today (issue #3240). `workspace_dir` and
@@ -233,10 +243,30 @@ pub async fn apply_agent_settings(
}
}
+ let tool_dispatcher = match update.tool_dispatcher.as_deref() {
+ Some(raw) => {
+ let normalized = raw.trim().to_ascii_lowercase();
+ if !TOOL_DISPATCHER_CHOICES.contains(&normalized.as_str()) {
+ log::warn!("[config][agent] rejected tool_dispatcher={normalized:?}");
+ return Err(format!(
+ "invalid tool_dispatcher '{normalized}' (expected {})",
+ TOOL_DISPATCHER_CHOICES.join(" | ")
+ ));
+ }
+ Some(normalized)
+ }
+ None => None,
+ };
+
if let Some(timeout_secs) = update.agent_timeout_secs {
config.agent.agent_timeout_secs = timeout_secs;
}
+ if let Some(tool_dispatcher) = tool_dispatcher {
+ log::debug!("[config][agent] tool_dispatcher -> {tool_dispatcher}");
+ config.agent.tool_dispatcher = tool_dispatcher;
+ }
+
if let Some(chat_agent_id) = update.chat_agent_id {
let trimmed = chat_agent_id.trim();
config.agent.chat_agent_id = (!trimmed.is_empty()).then(|| trimmed.to_string());
@@ -285,6 +315,10 @@ pub async fn get_agent_settings() -> Result<RpcOutcome<serde_json::Value>, Strin
"env_override": crate::tools::timeout::env_override_active(),
"min_timeout_secs": crate::tools::timeout::MIN_TIMEOUT_SECS,
"max_timeout_secs": crate::tools::timeout::MAX_TIMEOUT_SECS,
+ "tool_dispatcher": config.agent.tool_dispatcher,
+ "tool_dispatcher_env_override": std::env::var("OPENHUMAN_TOOL_DISPATCHER")
+ .map(|v| !v.trim().is_empty())
+ .unwrap_or(false),
});
Ok(RpcOutcome::single_log(value, "agent settings read"))
}
diff --git a/crates/openhuman-core/src/config/schemas/controllers/agent.rs b/crates/openhuman-core/src/config/schemas/controllers/agent.rs
index 7113b1a3d0..b1ead496ca 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/agent.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/agent.rs
@@ -75,6 +75,7 @@ pub(super) fn handle_update_agent_settings(params: Map<String, Value>) -> Contro
let patch = config_rpc::AgentSettingsPatch {
agent_timeout_secs: update.agent_timeout_secs,
chat_agent_id: update.chat_agent_id,
+ tool_dispatcher: update.tool_dispatcher,
};
match config_rpc::load_and_apply_agent_settings(patch).await {
Ok(outcome) => {
diff --git a/crates/openhuman-core/src/config/schemas/helpers.rs b/crates/openhuman-core/src/config/schemas/helpers.rs
index e73e0050d8..da330c4e35 100644
--- a/crates/openhuman-core/src/config/schemas/helpers.rs
+++ b/crates/openhuman-core/src/config/schemas/helpers.rs
@@ -235,6 +235,10 @@ pub(super) struct AgentSettingsUpdate {
/// override (back to the orchestrator); omitted leaves it unchanged.
#[serde(default)]
pub(super) chat_agent_id: Option<String>,
+ /// `auto | native | xml | pformat | python | typescript`. Validated
+ /// server-side; omitted leaves it unchanged.
+ #[serde(default)]
+ pub(super) tool_dispatcher: Option<String>,
}
#[derive(Debug, Deserialize)]
diff --git a/crates/openhuman-core/src/config/schemas/schema_defs/agent.rs b/crates/openhuman-core/src/config/schemas/schema_defs/agent.rs
index b7ac8630d3..ad87581937 100644
--- a/crates/openhuman-core/src/config/schemas/schema_defs/agent.rs
+++ b/crates/openhuman-core/src/config/schemas/schema_defs/agent.rs
@@ -84,7 +84,7 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
inputs: vec![],
outputs: vec![json_output(
"settings",
- "Agent settings: agent_timeout_secs, effective_timeout_secs, env_override, min_timeout_secs, max_timeout_secs.",
+ "Agent settings: agent_timeout_secs, effective_timeout_secs, env_override, min_timeout_secs, max_timeout_secs, tool_dispatcher, tool_dispatcher_env_override.",
)],
}),
"update_agent_settings" => Some( ControllerSchema {
@@ -102,6 +102,12 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
ty: TypeSchema::Option(Box::new(TypeSchema::String)),
comment: "Agent definition id the web-chat path routes turns to. Empty string reverts to the orchestrator. A named definition's own max_iterations governs the turn, so this is how a longer-running agent is selected.",
required: false,
+ },
+ FieldSchema {
+ name: "tool_dispatcher",
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment: "How tool calls are spoken to the model: auto (default; native when supported, else JSON-in-tag) | native | xml | pformat | python | typescript. Applies to new sessions.",
+ required: false,
}],
outputs: vec![json_output("snapshot", "Updated config snapshot.")],
}),