Skip to content

Commit 5a8206c

Browse files
MorabbinCopilot
andcommitted
Fix Python SDK to always send structured tool results
Remove the failure special-case that sent only the error string for result_type='failure'. Now the Python SDK always sends the full ResultResult struct (including error, resultType, toolTelemetry), consistent with Node, Go, and .NET SDKs. This fixes the e2e test snapshot mismatch: the shared YAML snapshots expect the CLI to receive a structured result (which it formats as 'Failed to execute ... due to error: Error: Tool execution failed'), but the old Python path sent only the error string, producing a different message format that the replay proxy couldn't match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0b1d5a0 commit 5a8206c

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

python/copilot/session.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -944,27 +944,17 @@ async def _execute_tool_and_respond(
944944
else:
945945
tool_result = result # type: ignore[assignment]
946946

947-
# If the tool reported a failure with an error message, send it via the
948-
# top-level error param so the server formats the tool message consistently
949-
# with other SDKs (e.g., "Failed to execute 'tool' ... due to error: ...").
950-
if tool_result.result_type == "failure" and tool_result.error:
951-
await self.rpc.tools.handle_pending_tool_call(
952-
SessionToolsHandlePendingToolCallParams(
953-
request_id=request_id,
947+
await self.rpc.tools.handle_pending_tool_call(
948+
SessionToolsHandlePendingToolCallParams(
949+
request_id=request_id,
950+
result=ResultResult(
951+
text_result_for_llm=tool_result.text_result_for_llm,
952+
result_type=tool_result.result_type,
954953
error=tool_result.error,
955-
)
956-
)
957-
else:
958-
await self.rpc.tools.handle_pending_tool_call(
959-
SessionToolsHandlePendingToolCallParams(
960-
request_id=request_id,
961-
result=ResultResult(
962-
text_result_for_llm=tool_result.text_result_for_llm,
963-
result_type=tool_result.result_type,
964-
tool_telemetry=tool_result.tool_telemetry,
965-
),
966-
)
954+
tool_telemetry=tool_result.tool_telemetry,
955+
),
967956
)
957+
)
968958
except Exception as exc:
969959
try:
970960
await self.rpc.tools.handle_pending_tool_call(

0 commit comments

Comments
 (0)