Skip to content

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

Merge main into fix/cc-selfexec-tools

Steven Enamakeld9bdf86e05d1
diff --cc src/openhuman/inference/provider/claude_code/event_mapper.rs
index e05301618b,ae364c20c1..51092c87a9
--- a/src/openhuman/inference/provider/claude_code/event_mapper.rs
+++ b/src/openhuman/inference/provider/claude_code/event_mapper.rs
@@@ -42,10 -23,10 +42,8 @@@ use crate::openhuman::inference::provid
#[derive(Debug, Clone)]
struct BlockState {
kind: BlockKind,
-- call_id: Option<String>,
tool_name: Option<String>,
text_accum: String,
-- input_accum: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
@@@ -155,10 -132,10 +153,8 @@@ impl EventMapper
index,
BlockState {
kind: BlockKind::Text,
-- call_id: None,
tool_name: None,
text_accum: String::new(),
-- input_accum: String::new(),
},
);
Vec::new()
@@@ -168,10 -145,10 +164,8 @@@
index,
BlockState {
kind: BlockKind::Thinking,
-- call_id: None,
tool_name: None,
text_accum: String::new(),
-- input_accum: String::new(),
},
);
Vec::new()
@@@ -191,19 -164,29 +185,32 @@@
.and_then(Value::as_str)
.filter(|s| !s.is_empty())
.map(str::to_string);
+ if let Some(name) = tool_name.as_deref() {
+ log::debug!(
+ "[claude-code][event-mapper] CLI self-executed tool `{name}` (not surfaced to the harness)"
+ );
+ }
+ if call_id.is_none() || tool_name.is_none() {
+ log::warn!(
+ "[claude-code][event-mapper] skipping tool_use block with missing id or name"
+ );
+ return Vec::new();
+ }
+ let call_id = call_id.unwrap();
+ let tool_name = tool_name.unwrap();
+ // The block is tracked so its `input_json_delta`s and its stop
+ // event are swallowed rather than leaking, but it is NOT
+ // surfaced to OpenHuman's harness — see the note on
+ // `on_block_stop`.
+ log::debug!(
+ "[claude-code][event-mapper] cli-internal tool_use name={tool_name} id={call_id} (not surfaced)"
+ );
self.blocks.insert(
index,
BlockState {
kind: BlockKind::Tool,
- call_id,
- tool_name,
- call_id: Some(call_id),
+ tool_name: Some(tool_name),
text_accum: String::new(),
-- input_accum: String::new(),
},
);
Vec::new()
@@@ -243,14 -226,14 +250,9 @@@
vec![ProviderDelta::ThinkingDelta { delta: text }]
}
(BlockKind::Tool, "input_json_delta") => {
- // Self-executed by the CLI (see the module docs). Accumulate so
- // these argument fragments never reach the visible text, but
- // surface nothing to the harness.
-- let partial = delta
-- .get("partial_json")
-- .and_then(Value::as_str)
- .unwrap_or("");
- state.input_accum.push_str(partial);
- .unwrap_or("")
- .to_string();
- // Accumulated for the debug log only; the call itself is the
- // CLI's to run, so nothing is emitted (see `on_block_stop`).
- state.input_accum.push_str(&partial);
++ // Self-executed by the CLI (see the module docs). Discard the
++ // argument fragments: they are not surfaced to the harness and
++ // retaining them until block stop only wastes memory.
Vec::new()
}
_ => Vec::new(),
@@@ -258,12 -241,31 +260,30 @@@
}
fn on_block_stop(&mut self, index: u64) -> Vec<ProviderDelta> {
- // Drop the finished block from the in-flight map. Text/thinking streamed
- // incrementally; a `tool_use` block is deliberately NOT finalized into a
- // harness tool call — the CLI already executed it (see the module docs),
- // so `tool_calls` stays empty and the harness treats the turn's final
- // assistant text as terminal instead of trying to re-dispatch.
- self.blocks.remove(&index);
+ let Some(state) = self.blocks.remove(&index) else {
+ return Vec::new();
+ };
+ if state.kind == BlockKind::Tool {
+ // A native `tool_use` block from this CLI is the CLI's OWN call —
+ // its builtins (Bash / Read / Write / Edit …) or a server from the
+ // `--mcp-config` we hand it. The CLI executes them itself inside
+ // its own agentic loop, which is why the matching `tool_result`
+ // blocks are deliberately dropped in `map_event`.
+ //
+ // Surfacing the *call* while dropping its *result* handed
+ // OpenHuman's harness a tool it does not own and cannot run: with
+ // `full_access` on (no `--disallowedTools`), a turn that reached
+ // for `Bash` produced repeated tool failures until the circuit
+ // breaker halted the run, and the turn then burned its 900s
+ // wall-clock backstop. So neither half is surfaced, and this
+ // provider behaves as what it is — a chat model whose tool use is
+ // internal. OpenHuman's own tools reach it through the prompt
+ // catalogue, not through native tool calls.
+ log::debug!(
- "[claude-code][event-mapper] dropping cli-internal tool call name={} args_len={}",
++ "[claude-code][event-mapper] dropping cli-internal tool call name={}",
+ state.tool_name.unwrap_or_default(),
- state.input_accum.len()
+ );
+ }
Vec::new()
}