Skip to content

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

refactor(inference): move dialect conversion to inference boundary

Steven Enamakel00ab86038564
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
index 030262b8af..e53b3cdf23 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
@@ -15,7 +15,6 @@ use tinytools_agent::dialect::ToolDialect;
use tinyagents_harness::middleware::wrap_harness_instruction;
use crate::agent::{
- message_convert::dialect_response_from_provider,
session_host::turn_checkpoint::{
self, CloseVerdict, CloseViolation, build_deterministic_checkpoint,
build_deterministic_final_summary, close_repair_instruction, close_verification_prompt,
@@ -24,6 +23,7 @@ use crate::agent::{
},
tinyagents::{TinyagentsTurnOutcome, TurnModelSource},
};
+use crate::inference::provider::model::dialect_response_from_provider;
use crate::inference::provider::{AGENT_TURN_MAX_OUTPUT_TOKENS, BilledUsage, ChatResponse};
/// Accounting from model calls performed after the harness loop has ended.
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs b/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
index fce8882f3b..9462ebd2ba 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs
@@ -32,14 +32,6 @@ mod runner;
// execution leaf after a neutral driver has prepared and admitted a request.
pub(crate) use runner::run_subagent_direct;
-// `user_is_signed_in_to_composio` is the mode-aware "can the user call
-// composio at all?" probe added in Wave 2 (#1710). Re-exported here so
-// non-composio probe sites (registration gates, telemetry)
-// can call it as
-// `crate::agent::subagent_host::user_is_signed_in_to_composio`
-// without reaching into a private sibling module.
-pub(crate) use provider::user_is_signed_in_to_composio;
-
pub(crate) use prompt::append_subagent_role_contract;
pub(crate) use provider::resolve_subagent_source;
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs b/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs
index 8496c89f06..bdaa016655 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs
@@ -86,23 +86,3 @@ pub(crate) fn resolve_subagent_source(
ModelSpec::Exact(model) => (parent_source, model.clone()),
}
}
-
-// ─────────────────────────────────────────────────────────────────────────────
-// Composio sign-in probe
-// ─────────────────────────────────────────────────────────────────────────────
-
-/// Probe whether the user can call Composio at all under the current
-/// config. Returns `true` when the mode-aware factory can build EITHER
-/// a backend-mode client (legacy JWT-driven path) OR a direct-mode
-/// client (BYO Composio API key). The resolved client is dropped
-/// immediately — this is purely a "signed-in vs not" check used by the
-/// spawn-time refresh path. Per-action dispatch resolves a fresh client
-/// elsewhere via [`resolve_composio_route`] so the live `composio.mode`
-/// toggle keeps winning.
-///
-/// Extracted as a free function so the regression suite can exercise
-/// the same probe the runner uses without spinning up the full
-/// `run_typed_mode` plumbing.
-pub(crate) fn user_is_signed_in_to_composio(config: &crate::config::Config) -> bool {
- crate::integrations::composio::client::resolve_composio_route(config).is_ok()
-}
diff --git a/crates/openhuman-core/src/inference/mod.rs b/crates/openhuman-core/src/inference/mod.rs
index 10ce22398d..5242d83829 100644
--- a/crates/openhuman-core/src/inference/mod.rs
+++ b/crates/openhuman-core/src/inference/mod.rs
@@ -33,7 +33,7 @@ pub mod model_context;
pub(crate) mod reasoning;
pub mod ops;
pub mod provider;
-pub(crate) mod turn_models;
+pub mod turn_models;
mod schemas;
pub mod tokenjuice;
diff --git a/crates/openhuman-core/src/inference/provider/model.rs b/crates/openhuman-core/src/inference/provider/model.rs
index f85f03ce44..ad5ec36236 100644
--- a/crates/openhuman-core/src/inference/provider/model.rs
+++ b/crates/openhuman-core/src/inference/provider/model.rs
@@ -6,6 +6,7 @@ use tinyinference_llm::message::{AssistantMessage, ContentBlock};
use tinyinference_llm::model::{ChatModel, ModelRequest, ModelResponse};
use tinyinference_llm::tool::ToolCall as TaToolCall;
use tinyinference_llm::usage::{ProviderUsageReport, recover_usage};
+use tinytools_agent::dialect::DialectResponse;
use crate::inference::provider::{BilledUsage, ChatResponse};
@@ -13,6 +14,14 @@ pub(crate) type TurnChatModel = Arc<dyn ChatModel<()>>;
pub(crate) type TierRoutes = Vec<(String, TurnChatModel)>;
pub(crate) type BuiltTurnModels = (TurnChatModel, TierRoutes, TurnChatModel);
+/// Convert a host response into the canonical dialect response at the inference boundary.
+pub(crate) fn dialect_response_from_provider(response: &ChatResponse) -> DialectResponse {
+ DialectResponse {
+ text: response.text.clone(),
+ tool_calls: response.tool_calls.clone(),
+ }
+}
+
/// Build a [`PFormatRegistry`](tinytools_agent::PFormatRegistry)
/// from the tool schemas advertised on a [`ModelRequest`] (issue #4465).
///
diff --git a/crates/openhuman-core/src/integrations/composio/auth_probe.rs b/crates/openhuman-core/src/integrations/composio/auth_probe.rs
new file mode 100644
index 0000000000..e3e1465f47
--- /dev/null
+++ b/crates/openhuman-core/src/integrations/composio/auth_probe.rs
@@ -0,0 +1,21 @@
+//! Mode-aware Composio sign-in probe used by sub-agent integration refresh.
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Composio sign-in probe
+// ─────────────────────────────────────────────────────────────────────────────
+
+/// Probe whether the user can call Composio at all under the current
+/// config. Returns `true` when the mode-aware factory can build EITHER
+/// a backend-mode client (legacy JWT-driven path) OR a direct-mode
+/// client (BYO Composio API key). The resolved client is dropped
+/// immediately — this is purely a "signed-in vs not" check used by the
+/// spawn-time refresh path. Per-action dispatch resolves a fresh client
+/// elsewhere via [`resolve_composio_route`] so the live `composio.mode`
+/// toggle keeps winning.
+///
+/// Extracted as a free function so the regression suite can exercise
+/// the same probe the runner uses without spinning up the full
+/// `run_typed_mode` plumbing.
+pub(crate) fn user_is_signed_in_to_composio(config: &crate::config::Config) -> bool {
+ crate::integrations::composio::client::resolve_composio_route(config).is_ok()
+}