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: 7 additions & 5 deletions src/agent_engine_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,7 @@ def list_sessions(
"""List all sessions for an agent."""
client = get_ready_client()
try:
sessions = list(client.list_sessions(agent_id))

if not sessions:
console.print("No sessions found.")
return
sessions = client.list_sessions(agent_id)

table = Table(title="Sessions")
table.add_column("Session ID", style="cyan")
Expand All @@ -349,7 +345,9 @@ def list_sessions(
table.add_column("Created")
table.add_column("Expires")

has_sessions = False
for session in sessions:
has_sessions = True
session_id = get_id(session)
display_name = getattr(session, "display_name", "") or ""
user_id = getattr(session, "user_id", "") or ""
Expand All @@ -375,6 +373,10 @@ def list_sessions(
expire_time,
)

if not has_sessions:
console.print("No sessions found.")
return

console.print(table)
except Exception as e:
console.print(f"[red]Error listing sessions: {escape(str(e))}[/red]")
Expand Down