feat(ai): surface tool invocations in chat history
load_history now groups preceding tool_call + tool_result scaffolding
under each assistant reply as `tools: [{name, arguments, result}]`.
Result bodies over 2000 chars are truncated for payload size with a
`result_truncated` flag; the full value remains in training_messages.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -704,6 +704,17 @@ pub struct RenderedHistoryMessage {
|
||||
pub role: String,
|
||||
pub content: String,
|
||||
pub is_initial: bool,
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
pub tools: Vec<HistoryToolInvocation>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct HistoryToolInvocation {
|
||||
pub name: String,
|
||||
pub arguments: serde_json::Value,
|
||||
pub result: String,
|
||||
#[serde(skip_serializing_if = "std::ops::Not::not")]
|
||||
pub result_truncated: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -787,6 +798,16 @@ pub async fn chat_history_handler(
|
||||
role: m.role,
|
||||
content: m.content,
|
||||
is_initial: m.is_initial,
|
||||
tools: m
|
||||
.tools
|
||||
.into_iter()
|
||||
.map(|t| HistoryToolInvocation {
|
||||
name: t.name,
|
||||
arguments: t.arguments,
|
||||
result: t.result,
|
||||
result_truncated: t.result_truncated,
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
.collect(),
|
||||
turn_count: view.turn_count,
|
||||
|
||||
Reference in New Issue
Block a user