Skip to content
Merged
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
12 changes: 11 additions & 1 deletion livekit-agents/livekit/agents/voice/run_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,17 @@ def __init__(self, *, user_input: str | None = None, output_type: type[Run_T] |

@property
def events(self) -> list[RunEvent]:
"""List of all recorded events generated during the run."""
"""
List of recorded run events in chronological order.

This surface is intended for assertions in tests. Events may include
`ChatMessageEvent`, `FunctionCallEvent`,
`FunctionCallOutputEvent`, and `AgentHandoffEvent`.

Use `RunResult.events` when validating what happened in a run instead
of depending on lower-level session internals, room state, or raw media
artifacts.
"""
return self._recorded_items
Comment on lines +92 to 93
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

events returns the underlying _recorded_items list directly. Since this docstring now positions RunResult.events as the recommended external testing surface, callers can easily (and accidentally) mutate the list and corrupt the recorded event stream for subsequent assertions/debug output. Consider returning an immutable view (e.g., a tuple) or a shallow copy, or explicitly document that the returned list must be treated as read-only.

Suggested change
"""
return self._recorded_items
Returns a shallow copy of the recorded events so callers cannot mutate
the internal event stream.
"""
return list(self._recorded_items)

Copilot uses AI. Check for mistakes.

@functools.cached_property
Expand Down
Loading