refactor: remove retry_count from ProviderConfig and enhance error handling in tool execution

- Removed the `retry_count` field from `ProviderConfig` as it is no longer needed.
- Introduced `argument_error` field in `ToolCall` to capture errors related to tool arguments.
- Updated various components to handle argument errors more gracefully, including in the `ToolDispatcher` and `ConversationOutput`.
- Enhanced tests to validate the new error handling and ensure proper functionality of tool calls.
This commit is contained in:
leokun committed 2026-09-01 10:14:53 +08:00
1 parent 29fde7d7c7
commit d83e14af9a
38 files changed
+1105 -444

No files matched your search

+12 -1
View File
@@ -445,9 +445,20 @@ mod tests {
.await
.unwrap();
let argument_error_column_exists: i64 = sqlx::query_scalar(
"SELECT EXISTS(
SELECT 1 FROM pragma_table_info('tool_round_calls')
WHERE name = 'argument_error'
)",
)
.fetch_one(&pool)
.await
.unwrap();
assert_eq!(checksum_after, checksum_before);
assert_eq!(versions, vec![1, 2, 3, 4, 5, 6, 7, 8]);
assert_eq!(versions, vec![1, 2, 3, 4, 5, 6, 7, 8, 9]);
assert_eq!(checkpoint_table_exists, 1);
assert_eq!(argument_error_column_exists, 1);
}
}
+7 -12
View File
@@ -93,22 +93,16 @@ impl Store {
for call in calls {
sqlx::query(
"INSERT INTO tool_round_calls
(round_id, call_index, call_id, model_call_id, name, arguments_json, status)
VALUES (?, ?, ?, ?, ?, ?, 'pending')",
(round_id, call_index, call_id, model_call_id, name, arguments_json, argument_error, status)
VALUES (?, ?, ?, ?, ?, ?, ?, 'pending')",
)
.bind(round_id.as_str())
.bind(call.index as i64)
.bind(&call.call_id)
.bind(&call.model_call_id)
.bind(&call.name)
// A no-argument tool call streams no argument text; persist it as an
// empty object so the `arguments_json` column always holds valid JSON
// and can be re-parsed on load.
.bind(if call.arguments_text.trim().is_empty() {
"{}"
} else {
call.arguments_text.as_str()
})
.bind(serde_json::to_string(&call.arguments)?)
.bind(call.argument_error.as_deref())
.execute(&mut *tx)
.await?;
}
@@ -276,7 +270,7 @@ impl Store {
return Ok(None);
};
let rows = sqlx::query(
"SELECT call_index, call_id, model_call_id, name, arguments_json, status
"SELECT call_index, call_id, model_call_id, name, arguments_json, argument_error, status
FROM tool_round_calls WHERE round_id = ? ORDER BY call_index",
)
.bind(round_id.as_str())
@@ -287,7 +281,7 @@ impl Store {
for row in rows {
let arguments_text: String = row.get(4);
let call_id: String = row.get(1);
if row.get::<&str, _>(5) == "completed" {
if row.get::<&str, _>(6) == "completed" {
completed.push(call_id.clone());
}
calls.push(ToolCall {
@@ -297,6 +291,7 @@ impl Store {
name: row.get(3),
arguments: serde_json::from_str(&arguments_text)?,
arguments_text,
argument_error: row.get(5),
});
}
Ok(Some(ToolRoundSnapshot {