Skip to content

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

refactor: remove tool schema bridge

Steven Enamakelb44251083d28
diff --git a/crates/openhuman-core/src/agent/tinyagents/README.md b/crates/openhuman-core/src/agent/tinyagents/README.md
index 0e3120a56d..9220f55d53 100644
--- a/crates/openhuman-core/src/agent/tinyagents/README.md
+++ b/crates/openhuman-core/src/agent/tinyagents/README.md
@@ -5,7 +5,7 @@ The **adapter seam** between OpenHuman and the vendored [`tinyagents`](../../../
## Responsibilities
- Assemble a per-turn harness (`assemble_turn_harness` in `harness_assembly.rs`): register the turn's `ChatModel`s, every shared tool, and the full middleware stack, then drive it via `AgentHarness::invoke_stream_in_context` (`turn_runner.rs`).
-- Convert between OpenHuman and crate types: tiered `ChatModel` bundles from `(role, config)` (`turn_models.rs`, `model.rs`), `Tool` → crate `Tool` (`tools.rs`, `convert.rs`), and `ChatMessage`/`ConversationMessage` ↔ crate `Message` via `crate::agent::message_convert`.
+- Convert between OpenHuman and crate types: tiered `ChatModel` bundles from `(role, config)` (`turn_models.rs`, `model.rs`), direct TinyTools/TinyInference tool declarations at their consumers, and `ChatMessage`/`ConversationMessage` ↔ crate `Message` via `crate::agent::message_convert`.
- Enforce cross-cutting policy as harness middleware: approval/security gating, tool policy and CLI/RPC-only denial, cost budgets, context compaction/summarization, credential scrubbing, malformed-argument recovery, and the repeated-tool-failure circuit breaker (`middleware*.rs`).
- Route workloads to model tiers and record the resolved provider/model for audit (`routes.rs`, canonical TinyInference response metadata).
- Make turns durable and replayable: a JSONL event journal plus status store (`journal.rs`), a startup sweep for orphaned runs (`reaper.rs`), and a read-only RPC surface over both (`replay/`).
@@ -31,7 +31,6 @@ The **adapter seam** between OpenHuman and the vendored [`tinyagents`](../../../
| `reaper.rs` | `reap_orphaned_runs`: startup sweep that marks non-terminal runs `Cancelled` in the durable status store. The only writer over the status seam that `replay/` reads. |
| `middleware.rs` + `middleware/` | The named OpenHuman middleware stack. `turn_context.rs`: `TurnContextMiddleware` (bundles config and installs the enabled hooks), `TranscriptSnapshotMiddleware`/`TranscriptSnapshotSink`, `HandoffConfig`/`HandoffMiddleware` (oversized sub-agent results stashed for `extract_from_result`). `prompt_cache.rs`: `PromptCacheSegmentMiddleware`. `tool_output.rs`: `ToolOutputMiddleware` (per-result byte cap and optional payload summarizer). `approval.rs`: `ApprovalSecurityMiddleware`. `cli_rpc_only.rs`: `CliRpcOnlyMiddleware`. `tool_policy.rs`: the `ToolPolicyMiddleware` struct and impl (records blocks into `crate::tools::registry::denials`). `tool_outcome_capture.rs`: `ToolOutcomeCaptureMiddleware`. `embedder_hooks.rs`: `EmbedderToolHooksMiddleware`. `arg_recovery.rs`: `ArgRecoveryMiddleware`. `memory_protocol.rs`: `MemoryProtocolMiddleware`. `cost_budget.rs`: `CostBudgetMiddleware`. `repeated_failure.rs`: `RepeatedToolFailureMiddleware`. `loop_guards.rs`: `TerminalInferenceFailure`. `repeat_progress.rs`: `RepeatProgressMiddleware` (adjacent-repeat streaks plus a run-wide `(call, result)` recurrence ledger) and `RepeatEvictionObserver` (registered last; resets the ledger when compaction evicts a recorded result, #6275). `message_trim.rs`: `ImageAwareMessageTrimMiddleware`. `final_call_wrap_up.rs`: `FinalCallWrapUpMiddleware`. `artifact_index_toc.rs`: `ArtifactIndexTocMiddleware` (issue #6014). `credential_scrub.rs`: `CredentialScrubMiddleware` (issue #4453). |
| `model.rs` | Helpers and wrappers over native crate `ChatModel` values: message/response translation, usage merging, stream-delta forwarding, `MaxTokensModel`, `ProfileOverrideModel`. |
-| `convert.rs` | `spec_to_schema`: OpenHuman `ToolSpec` → crate `ToolSchema`. Message conversion lives in `crate::agent::message_convert`. |
| `tools.rs` | `CanonicalSharedToolAdapter`: resolves an OpenHuman shared tool registry and forwards the canonical `tinytools::Tool` contract; `EarlyExitHook` pauses successful `ask_user_clarification`-style calls. |
| `routes.rs` | `WORKLOAD_ROUTE_TIERS` (the tier inventory projected into the model registry), `RequiredCapabilitiesMiddleware`, `FallbackObserverMiddleware`, `UsageCarryMiddleware`, and the per-model fallback policy. |
| `topology.rs` | `all_graph_topologies`: behaviour-free `GraphTopology` exports of every custom OpenHuman graph for debug/inspection. |
diff --git a/crates/openhuman-core/src/agent/tinyagents/convert.rs b/crates/openhuman-core/src/agent/tinyagents/convert.rs
deleted file mode 100644
index ce61d6546c..0000000000
--- a/crates/openhuman-core/src/agent/tinyagents/convert.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-//! Tool-schema conversion retained at the OpenHuman/TinyAgents tool seam.
-//!
-//! Durable message conversion lives in `agent::message_convert`, beside the
-//! OpenHuman transcript record it adapts. This module remains until WP-4
-//! decides the host tool-trait boundary.
-
-use tinyinference_llm::tool::ToolSchema;
-
-use tinytools::ToolSpec;
-
-pub(crate) fn spec_to_schema(spec: &ToolSpec) -> ToolSchema {
- ToolSchema::new(
- spec.name.clone(),
- spec.description.clone(),
- spec.parameters.clone(),
- )
-}
-
-#[cfg(test)]
-#[path = "convert_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/agent/tinyagents/convert_tests.rs b/crates/openhuman-core/src/agent/tinyagents/convert_tests.rs
deleted file mode 100644
index 0b6b1bd47f..0000000000
--- a/crates/openhuman-core/src/agent/tinyagents/convert_tests.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-use super::*;
-
-#[test]
-fn converts_tool_schema() {
- let spec = ToolSpec {
- name: "echo".into(),
- description: "echoes".into(),
- parameters: serde_json::json!({"type": "object"}),
- };
- let schema = spec_to_schema(&spec);
- assert_eq!(schema.name, "echo");
- assert_eq!(schema.parameters, serde_json::json!({"type": "object"}));
-}
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/arg_recovery.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/arg_recovery.rs
index 99c93dd085..b18f1a62ab 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/arg_recovery.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/arg_recovery.rs
@@ -109,18 +109,20 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Arg
/// Resolves the harness [`ToolSchema`] for `name` across the runner's shared
/// tool sets.
///
-/// Built via the same [`spec_to_schema`](crate::agent::tinyagents::convert::spec_to_schema)
-/// conversion the runner uses for canonical tool schemas, so the
-/// `parameters` we validate against are byte-identical to the ones the crate's
-/// fatal `validate_call` gate checks — otherwise our pre-validation could
-/// disagree with the crate and either miss a fatal case or stub a call the crate
-/// still rejects.
+/// It constructs the canonical TinyInference schema directly from the
+/// TinyTools declaration, so the `parameters` we validate against are
+/// byte-identical to the ones the crate's fatal `validate_call` gate checks —
+/// otherwise our pre-validation could disagree with the crate and either miss
+/// a fatal case or stub a call the crate still rejects.
fn schema_for_tool(tool_sets: &[Arc<Vec<Box<dyn Tool>>>], name: &str) -> Option<ToolSchema> {
tool_sets
.iter()
.flat_map(|set| set.iter())
.find(|tool| tool.name() == name)
- .map(|tool| crate::agent::tinyagents::convert::spec_to_schema(&tool.spec()))
+ .map(|tool| {
+ let spec = tool.spec();
+ ToolSchema::new(spec.name, spec.description, spec.parameters)
+ })
}
/// Whether a tool's JSON-schema `parameters` declares any `required` field.
diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rs
index df1ea03e36..a37a504848 100644
--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs
@@ -21,8 +21,6 @@
pub(crate) mod abort_guard;
pub mod config;
-pub(crate) mod convert;
-
mod embeddings;
mod harness_assembly;
mod harness_context_ladder;
diff --git a/crates/openhuman-core/src/mcp/server/README.md b/crates/openhuman-core/src/mcp/server/README.md
index 92167dd5c0..72a381bd05 100644
--- a/crates/openhuman-core/src/mcp/server/README.md
+++ b/crates/openhuman-core/src/mcp/server/README.md
@@ -79,7 +79,8 @@ No `store.rs`. The only durable side effect is the **MCP write-audit log**, writ
- `crate::core::logging` (`CliLogDefault`, `init_for_cli_run`) — install the stderr tracing subscriber for the MCP subprocess.
- `crate::config` (`Config`, `rpc::load_config_with_timeout`, `McpAuthConfig`/`McpClientIdentityConfig` in tests) — load config for policy/searxng gating and per-call config.
- `crate::security` (`SecurityPolicy`, `ToolOperation`) — enforce read/act autonomy policy per tool call.
-- `crate::agent` (`Agent`, `registry::agents::BUILTINS`, `harness::AgentDefinitionRegistry`, `tinyagents::convert::spec_to_schema`) — build the orchestrator agent for `core.list_tools`/`core.tool_instructions`, list/run subagents, and cross-check the resource catalog.
+- `crate::agent` (`Agent`, `registry::agents::BUILTINS`, `harness::AgentDefinitionRegistry`) — build the orchestrator agent for `core.list_tools`/`core.tool_instructions`, list/run subagents, and cross-check the resource catalog.
+- `tinyinference_llm::tool::ToolSchema` — directly materialize model-visible tool declarations for `core.tool_instructions`.
- `tinyagents_harness::tool::prompt_tool_instructions` — render the markdown tool-use instructions block for `core.tool_instructions`.
- `crate::tools` (`SEARXNG_MAX_RESULTS`, `normalize_categories`) — SearXNG bounds + category normalization for `searxng_search`.
- `crate::mcp::audit` (`record_write`, `NewMcpWriteRecord`, list/query helpers in tests) — durable write-audit log.
diff --git a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
index 40c3ad9fc1..faeb16bc9b 100644
--- a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
+++ b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
@@ -1,8 +1,8 @@
-use serde_json::{json, Map, Value};
+use serde_json::{Map, Value, json};
+use tinyinference_llm::tool::ToolSchema;
-use crate::agent::harness::AgentDefinitionRegistry;
-use crate::agent::tinyagents::convert::spec_to_schema;
use crate::agent::Agent;
+use crate::agent::harness::AgentDefinitionRegistry;
use crate::config::rpc as config_rpc;
use crate::core::all;
use crate::security::{SecurityPolicy, ToolOperation};
@@ -239,7 +239,13 @@ async fn core_tool_instructions() -> Result<Value, ToolCallError> {
let schemas: Vec<_> = agent
.tool_specs()
.iter()
- .map(|spec| spec_to_schema(spec))
+ .map(|spec| {
+ ToolSchema::new(
+ spec.name.clone(),
+ spec.description.clone(),
+ spec.parameters.clone(),
+ )
+ })
.collect();
Ok(tool_text_success(
tinyagents_harness::tool::prompt_tool_instructions(&schemas),
diff --git a/scripts/ci/agent-runtime-boundary-baseline.json b/scripts/ci/agent-runtime-boundary-baseline.json
index 9c83def624..6255dda441 100644
--- a/scripts/ci/agent-runtime-boundary-baseline.json
+++ b/scripts/ci/agent-runtime-boundary-baseline.json
@@ -41,20 +41,6 @@
"text": "let run_result = Box::pin(run_turn_via_tinyagents_shared(",
"occurrence": 1
},
- {
- "rule": "openhuman-runtime-bridge",
- "path": "crates/openhuman-core/src/agent/tinyagents/convert_tests.rs",
- "line": 10,
- "text": "let schema = spec_to_schema(&spec);",
- "occurrence": 1
- },
- {
- "rule": "openhuman-runtime-bridge",
- "path": "crates/openhuman-core/src/agent/tinyagents/convert.rs",
- "line": 11,
- "text": "pub(crate) fn spec_to_schema(spec: &ToolSpec) -> ToolSchema {",
- "occurrence": 1
- },
{
"rule": "openhuman-runtime-bridge",
"path": "crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs",
@@ -62,17 +48,10 @@
"text": "pub(super) fn assemble_turn_harness(",
"occurrence": 1
},
- {
- "rule": "openhuman-runtime-bridge",
- "path": "crates/openhuman-core/src/agent/tinyagents/middleware/arg_recovery.rs",
- "line": 123,
- "text": ".map(|tool| crate::agent::tinyagents::convert::spec_to_schema(&tool.spec()))",
- "occurrence": 1
- },
{
"rule": "openhuman-runtime-bridge",
"path": "crates/openhuman-core/src/agent/tinyagents/mod.rs",
- "line": 83,
+ "line": 81,
"text": "pub(crate) use turn_runner::run_turn_via_tinyagents_shared;",
"occurrence": 1
},
@@ -97,20 +76,6 @@
"text": "} = assemble_turn_harness(",
"occurrence": 1
},
- {
- "rule": "openhuman-runtime-bridge",
- "path": "crates/openhuman-core/src/mcp/server/tools/dispatch.rs",
- "line": 4,
- "text": "use crate::agent::tinyagents::convert::spec_to_schema;",
- "occurrence": 1
- },
- {
- "rule": "openhuman-runtime-bridge",
- "path": "crates/openhuman-core/src/mcp/server/tools/dispatch.rs",
- "line": 242,
- "text": ".map(|spec| spec_to_schema(spec))",
- "occurrence": 1
- },
{
"rule": "openhuman-task-local",
"path": "crates/openhuman-core/src/agent/bus.rs",
@@ -954,7 +919,7 @@
{
"rule": "openhuman-task-local",
"path": "crates/openhuman-core/src/mcp/server/tools/dispatch.rs",
- "line": 385,
+ "line": 391,
"text": "crate::agent::turn_origin::with_origin(origin, agent.run_single(&prompt)),",
"occurrence": 1
},