fix: propagate real tool_call_id instead of hardcoded placeholder (#73)

The worker (both agent/worker.rs and worker/runtime.rs) was passing the
literal string "tool_call_id" to ChatMessage::tool_result instead of
the actual tool call ID from the LLM response. This breaks
OpenAI-compatible providers that match tool results to their
corresponding calls by ID.

- Add tool_call_id field to ToolSelection struct
- Propagate ToolCall.id through select_tools() into ToolSelection
- Replace all hardcoded "tool_call_id" usages with selection.tool_call_id
- Generate unique IDs for plan-based synthetic selections
- Add test verifying tool_call_id is preserved

Co-authored-by: Yi LIU <[email protected]>
Co-authored-by: Illia Polosukhin <[email protected]>
This commit is contained in:
AI-Reviewer-QS
2026-02-14 21:39:25 +00:00
committed by GitHub
co-authored by Yi LIU Illia Polosukhin
parent 225af29db2
commit eaef335db6
3 changed files with 35 additions and 5 deletions
+3 -2
View File
@@ -313,6 +313,7 @@ Work independently to complete this job. Report when done."#,
parameters: tc.arguments.clone(),
reasoning: String::new(),
alternatives: vec![],
tool_call_id: tc.id.clone(),
};
self.process_result(reason_ctx, &selection, result);
}
@@ -422,7 +423,7 @@ Work independently to complete this job. Report when done."#,
);
reason_ctx.messages.push(ChatMessage::tool_result(
"tool_call_id",
&selection.tool_call_id,
&selection.tool_name,
wrapped,
));
@@ -436,7 +437,7 @@ Work independently to complete this job. Report when done."#,
Err(e) => {
tracing::warn!("Tool {} failed: {}", selection.tool_name, e);
reason_ctx.messages.push(ChatMessage::tool_result(
"tool_call_id",
&selection.tool_call_id,
&selection.tool_name,
format!("Error: {}", e),
));