Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/zeroclaw-api/src/model_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ pub struct ChatRequest<'a> {
pub struct ToolResultMessage {
pub tool_call_id: String,
pub content: String,
/// Name of the tool that produced this result, retained so downstream
/// media-marker canonicalization stays provenance-aware: path-listing
/// tools (`content_search`, `glob_search`) must not have incidental image
/// paths promoted to routable `[IMAGE:...]` markers (PR #7345). Empty when
/// the producing tool is unknown (e.g. results reconstructed from a
/// provider-wire `tool` message that never carried the name), in which case
/// the blind canonicalizer runs exactly as before (PR #6183).
/// `#[serde(default)]` keeps older serialized session records readable.
#[serde(default)]
pub tool_name: String,
}

/// A message in a multi-turn conversation, including tool interactions.
Expand Down
7 changes: 7 additions & 0 deletions crates/zeroclaw-infra/src/acp_session_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ impl AcpSessionStore {
"out" => outs.push(ToolResultMessage {
tool_call_id,
content: payload,
// Carry the producing tool name (looked up from the
// matching 'in' row on write) so a resumed session
// stays provenance-aware for media-marker
// canonicalization (PR #7345).
tool_name,
}),
other => {
::zeroclaw_log::record!(
Expand Down Expand Up @@ -925,6 +930,7 @@ mod tests {
ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc-1".into(),
content: "file.txt\n".into(),
tool_name: String::new(),
}]),
ConversationMessage::Chat(ChatMessage::assistant("done")),
];
Expand Down Expand Up @@ -1076,6 +1082,7 @@ mod tests {
ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc-1".into(),
content: "ok".into(),
tool_name: String::new(),
}]),
],
)
Expand Down
16 changes: 16 additions & 0 deletions crates/zeroclaw-runtime/src/agent/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,10 @@ impl Agent {
.and_then(|c| c.as_str())
.unwrap_or_default()
.to_string(),
// Provider-wire tool messages do not carry the
// producing tool name; replayed results fall back
// to blind canonicalization (PR #6183, #7345).
tool_name: String::new(),
})
})
.collect();
Expand All @@ -1796,6 +1800,9 @@ impl Agent {
.and_then(|c| c.as_str())
.unwrap_or_default()
.to_string(),
// No provenance on the provider-wire shape; blind canon
// applies as before (PR #6183, #7345).
tool_name: String::new(),
};
push_tool_results(&mut replayed, vec![result]);
continue;
Expand Down Expand Up @@ -3958,6 +3965,7 @@ mod tests {
ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc-1".into(),
content: "ok".into(),
tool_name: String::new(),
}]),
ConversationMessage::Chat(ChatMessage::assistant("done")),
];
Expand Down Expand Up @@ -4700,6 +4708,7 @@ mod tests {
.push(ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: format!("tc{i}"),
content: format!("result{i}"),
tool_name: String::new(),
}]));
}
}
Expand Down Expand Up @@ -4805,6 +4814,7 @@ mod tests {
.push(ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc1".into(),
content: "result1".into(),
tool_name: String::new(),
}]));
// AC2, TR2
agent.history.push(ConversationMessage::AssistantToolCalls {
Expand All @@ -4822,6 +4832,7 @@ mod tests {
.push(ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc2".into(),
content: "result2".into(),
tool_name: String::new(),
}]));
// AC3, TR3
agent.history.push(ConversationMessage::AssistantToolCalls {
Expand All @@ -4839,6 +4850,7 @@ mod tests {
.push(ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc3".into(),
content: "result3".into(),
tool_name: String::new(),
}]));

assert_eq!(agent.history.len(), 7);
Expand Down Expand Up @@ -4957,6 +4969,7 @@ mod tests {
.push(ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc1".into(),
content: "result1".into(),
tool_name: String::new(),
}]));
// AC2, TR2
agent.history.push(ConversationMessage::AssistantToolCalls {
Expand All @@ -4974,6 +4987,7 @@ mod tests {
.push(ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc2".into(),
content: "result2".into(),
tool_name: String::new(),
}]));

assert_eq!(agent.history.len(), 5);
Expand Down Expand Up @@ -5089,6 +5103,7 @@ mod tests {
.push(ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc1".into(),
content: "result1".into(),
tool_name: String::new(),
}]));
// AC2, TR2
agent.history.push(ConversationMessage::AssistantToolCalls {
Expand All @@ -5106,6 +5121,7 @@ mod tests {
.push(ConversationMessage::ToolResults(vec![ToolResultMessage {
tool_call_id: "tc2".into(),
content: "result2".into(),
tool_name: String::new(),
}]));

assert_eq!(agent.history.len(), 6);
Expand Down
Loading