Skip to content

⚡ Optimize session listing by using iterators#17

Merged
mmontan merged 1 commit intomainfrom
performance-optimize-sessions-iterator-4640066907036728142
Feb 24, 2026
Merged

⚡ Optimize session listing by using iterators#17
mmontan merged 1 commit intomainfrom
performance-optimize-sessions-iterator-4640066907036728142

Conversation

@mmontan
Copy link
Collaborator

@mmontan mmontan commented Feb 24, 2026

💡 What: Refactored list_sessions in src/agent_engine_cli/main.py to process the sessions iterator directly instead of converting it to a full list.
🎯 Why: This optimization reduces the peak memory footprint of the CLI when listing a large number of sessions. It avoids an unnecessary intermediate list allocation and allows session objects to be processed and discarded one by one.
📊 Measured Improvement: While a quantitative benchmark was impractical due to environmental constraints (missing dependencies in the sandbox), this change is a guaranteed memory improvement by removing a full list copy of the session results. The peak memory usage is now proportional to the size of the Rich Table and the individual session objects being processed, rather than being at least the size of the entire session list.


PR created automatically by Jules for task 4640066907036728142 started by @mmontan

Refactor `list_sessions` to process the iterator directly, avoiding
an unnecessary intermediate list conversion. This reduces memory
footprint when handling a large number of sessions.

Co-authored-by: mmontan <2553915+mmontan@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@mmontan mmontan merged commit 4203be7 into main Feb 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant