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
{{ message }}
Repository navigation
[FEATURE]: Adding a session stat command to allow programmatic access to context size and other info for a specific session #19045
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem: there is no easy way to get the context size of a specific session for monitoring or scripting.
Solution: Add a command onto the session command called stat that accepts a session id and returns info about the session to include the context size of the session at that time and other details. Also allow json formatting of the output via the format flag --format json.
FYI I think this is a unique request from my search of existing issues, but it is similar to this issue
I think this would make creating various harnesses for automated workflow that leverage opencode much easier. I have a working implementation locally. I will attache a screenshot of the output. I am open to changing any of the details (command name, data in the output, etc) just let me know.
Reacted by marceljaehn, janorga and Leonard Sheng Sheng Lee
Your request has a distinct angle — a CLI session stat subcommand for programmatic/scripting access with JSON output — which may be sufficiently different to stand on its own. But it's worth reviewing those issues to avoid duplicate effort or to potentially combine approaches.
I believe this feature is different from the ones mentioned here. I am looking for a way to get the context size and other details from the cli for ease of scripting, the issues mentioned above all reference showing data in the TUI
Activity
github-actions commentedon Mar 25, 2026
This issue might be a duplicate of existing issues. Please check:
/contextcommand to display session token usageYour request has a distinct angle — a CLI
session statsubcommand for programmatic/scripting access with JSON output — which may be sufficiently different to stand on its own. But it's worth reviewing those issues to avoid duplicate effort or to potentially combine approaches.calvine commentedon Mar 25, 2026
I believe this feature is different from the ones mentioned here. I am looking for a way to get the context size and other details from the cli for ease of scripting, the issues mentioned above all reference showing data in the TUI
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.