[MCP] Render full MCP errors to the model (#5298)
Previously, the model couldn't see why MCP tool calls failed, many of which were the model using the parameters incorrectly. A common failure is the model stringifying the json for the notion-update-page tool which it then couldn't correct. I want to do some system prompt massaging around this as well. However, it is crucial that the model sees the error so it can fix it. Before: <img width="2984" height="832" alt="CleanShot 2025-10-17 at 13 02 36" src="https://github.com/user-attachments/assets/709a3d27-b71b-4d8d-87b6-9b2d7fe4e6f2" /> After: <img width="2488" height="1550" alt="CleanShot 2025-10-17 at 13 01 18" src="https://github.com/user-attachments/assets/13a0b7dc-fdad-4996-bf2d-0772872c34fc" /> 🎉 <img width="1078" height="568" alt="CleanShot 2025-10-17 at 13 09 30" src="https://github.com/user-attachments/assets/64cde8be-9e6c-4e61-b971-c2ba22504292" /> Fixes #4707
This commit is contained in:
@@ -58,7 +58,10 @@ pub(crate) async fn handle_mcp_tool_call(
|
||||
let result = sess
|
||||
.call_tool(&server, &tool_name, arguments_value.clone())
|
||||
.await
|
||||
.map_err(|e| format!("tool call error: {e}"));
|
||||
.map_err(|e| format!("tool call error: {e:?}"));
|
||||
if let Err(e) = &result {
|
||||
tracing::warn!("MCP tool call error: {e:?}");
|
||||
}
|
||||
let tool_call_end_event = EventMsg::McpToolCallEnd(McpToolCallEndEvent {
|
||||
call_id: call_id.clone(),
|
||||
invocation,
|
||||
|
||||
Reference in New Issue
Block a user