Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,43 @@ def event_handler(event: SessionEvent) -> None:
raw_representation=event,
)
queue.put_nowait(update)
elif event.type == SessionEventType.TOOL_EXECUTION_START:
tool_call_id = getattr(event.data, "tool_call_id", None) or ""
tool_name = getattr(event.data, "tool_name", None) or ""
arguments = getattr(event.data, "arguments", None)
fc = Content.from_function_call(
call_id=tool_call_id,
name=tool_name,
arguments=arguments,
raw_representation=event.data,
)
update = AgentResponseUpdate(
role="assistant",
contents=[fc],
raw_representation=event,
)
queue.put_nowait(update)
elif event.type == SessionEventType.TOOL_EXECUTION_COMPLETE:
tool_call_id = getattr(event.data, "tool_call_id", None) or ""
result_obj = getattr(event.data, "result", None)
result_text = getattr(result_obj, "content", "") if result_obj else ""
success = getattr(event.data, "success", None)
error_val = getattr(event.data, "error", None)
exception = None
if success is False and error_val is not None:
exception = error_val.message if hasattr(error_val, "message") else str(error_val)
fr = Content.from_function_result(
call_id=tool_call_id,
result=result_text or "",
exception=exception,
raw_representation=event.data,
)
update = AgentResponseUpdate(
role="tool",
contents=[fr],
raw_representation=event,
)
queue.put_nowait(update)
elif event.type == SessionEventType.SESSION_IDLE:
queue.put_nowait(None)
elif event.type == SessionEventType.SESSION_ERROR:
Expand Down
Loading
Loading