You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
The code returns only the text of the first part in last_event.content.parts:
tool_result = last_event.content.parts[0].text
This implementation causes issues when the response contains multiple parts, as only the first part's text is returned and any additional parts are ignored. As a result, important information in subsequent parts is lost, leading to incomplete or incorrect tool outputs.
Expected behavior:
All parts' texts should be concatenated (e.g., joined with \n) and returned as a single string, so that multi-part responses are handled correctly.
Suggested fix:
Replace the above line with:
tool_result = "\n".join(
[p.text for p in last_event.content.parts if getattr(p, "text", None)]
)
This will ensure that all available text parts are included in the tool result.