diff --git a/crates/ironclaw_engine/orchestrator/default.py b/crates/ironclaw_engine/orchestrator/default.py index 5b521489..c54c06fd 100644 --- a/crates/ironclaw_engine/orchestrator/default.py +++ b/crates/ironclaw_engine/orchestrator/default.py @@ -181,8 +181,8 @@ def run_loop(context, goal, actions, state, config): if nudge_enabled and nudge_count < max_nudges and signals_tool_intent(text): nudge_count += 1 __add_message__("user", - "You described what you'd do but didn't write code. " - "Please write a ```repl code block to execute your plan.") + "You expressed intent to use a tool but didn't make an action call. " + "Please go ahead and call the appropriate action.") continue # Plain text response - done diff --git a/crates/ironclaw_engine/src/executor/loop_engine.rs b/crates/ironclaw_engine/src/executor/loop_engine.rs index 6583b929..ac45e27c 100644 --- a/crates/ironclaw_engine/src/executor/loop_engine.rs +++ b/crates/ironclaw_engine/src/executor/loop_engine.rs @@ -282,8 +282,10 @@ impl ExecutionLoop { // Post-cleanup: persist final state match result { Ok(orch_result) => { - self.thread.total_tokens_used += orch_result.tokens_used.total(); - self.thread.total_cost_usd += orch_result.tokens_used.cost_usd; + // Token tracking is handled by __emit_event__("step_completed") + // and __llm_complete__ within the orchestrator, so no need to + // add orch_result.tokens_used here (would double-count). + let _ = &orch_result.tokens_used; // acknowledge field self.clear_runtime_checkpoint(); self.persist_runtime_state(None, &mut persisted_event_count) .await?; diff --git a/crates/ironclaw_engine/src/executor/orchestrator.rs b/crates/ironclaw_engine/src/executor/orchestrator.rs index d3ae7f6d..387c4da6 100644 --- a/crates/ironclaw_engine/src/executor/orchestrator.rs +++ b/crates/ironclaw_engine/src/executor/orchestrator.rs @@ -597,6 +597,10 @@ fn handle_emit_event( "step_completed" => { let input = extract_u64_kwarg(kwargs, "input_tokens").unwrap_or(0); let output = extract_u64_kwarg(kwargs, "output_tokens").unwrap_or(0); + // Increment step count (mirrors the old Rust loop's step_count += 1) + thread.step_count += 1; + // Track token usage + thread.total_tokens_used += input + output; EventKind::StepCompleted { step_id: StepId::new(), tokens: TokenUsage {