t1398.4: Add session count awareness#2883
Conversation
…sions (t1398.4) Add session-count-helper.sh that detects interactive AI coding sessions (OpenCode, Claude Code, Cursor, Windsurf, Aider) and warns when the count exceeds a configurable threshold (default: 5). Distinguishes interactive TUI sessions from headless workers by examining process command lines. Integration points: - Startup flow (aidevops-update-check.sh): warns on session start - Pre-edit check (pre-edit-check.sh): non-blocking warning before edits Configuration: - Config key: safety.max_interactive_sessions (default: 5, 0 = disabled) - Env override: AIDEVOPS_MAX_SESSIONS - Schema and defaults updated Closes #2877
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new system to monitor and manage the number of concurrent interactive AI coding sessions. The primary goal is to help users prevent potential memory pressure and performance degradation by providing timely warnings when too many AI assistants are running simultaneously. This enhancement aims to improve system stability and resource management without interrupting the user's workflow. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Mar 5 03:08:56 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request introduces a helpful feature to monitor and warn about a high number of concurrent interactive AI sessions, which can help manage system resources. The implementation is well-structured, with a dedicated helper script and integration into existing startup and pre-edit checks.
My review focuses on improving the robustness and clarity of the new script. I've suggested removing error suppression (2>/dev/null) in a few places to align with project guidelines and improve debuggability. I also noted an opportunity to make the list command's output more complete and less confusing for the user, aligning with the principle that informational functions should be comprehensive.
The changes to configuration files and environment variable mappings are all correct. Overall, this is a solid addition.
| # Check for excessive concurrent interactive sessions (t1398.4) | ||
| local session_warning="" | ||
| if [[ -x "${script_dir}/session-count-helper.sh" ]]; then | ||
| session_warning="$("${script_dir}/session-count-helper.sh" check 2>/dev/null || true)" |
There was a problem hiding this comment.
Suppressing stderr with 2>/dev/null can hide important diagnostic messages from the helper script, such as syntax errors or problems with dependencies like pgrep. The project's general rules advise against blanket error suppression to make debugging easier. The || true is sufficient to prevent the script from exiting on a warning (exit code 1).
| session_warning="$("${script_dir}/session-count-helper.sh" check 2>/dev/null || true)" | |
| session_warning="$("${script_dir}/session-count-helper.sh" check || true)" |
References
- Avoid blanket suppression of command errors with '2>/dev/null' in shell scripts to ensure that system issues remain visible for debugging.
|
|
||
| # Session count warning (t1398.4) — non-blocking, informational only | ||
| if [[ -x "$SCRIPT_DIR/session-count-helper.sh" ]]; then | ||
| session_warning=$("$SCRIPT_DIR/session-count-helper.sh" check 2>/dev/null || true) |
There was a problem hiding this comment.
As in aidevops-update-check.sh, suppressing stderr with 2>/dev/null here can hide important errors from the helper script. Please remove it to allow diagnostic messages to be visible, in line with the project's general rules for debugging.
| session_warning=$("$SCRIPT_DIR/session-count-helper.sh" check 2>/dev/null || true) | |
| session_warning=$("$SCRIPT_DIR/session-count-helper.sh" check || true) |
References
- Avoid blanket suppression of command errors with '2>/dev/null' in shell scripts to ensure that system issues remain visible for debugging.
| # the first argument after the binary name. | ||
| # Headless: .opencode run ... | ||
| local opencode_pids="" | ||
| opencode_pids=$(pgrep -f '\.opencode' 2>/dev/null || true) |
There was a problem hiding this comment.
Using 2>/dev/null here suppresses all stderr output from pgrep, which could hide important errors like 'command not found' if pgrep isn't installed, or other system issues. According to the project's general rules, error suppression should be avoided to aid debugging. The || true is sufficient to handle the case where no processes are found. This applies to all pgrep calls in this script (e.g., lines 120, 143, 148, 153, 167, 204).
| opencode_pids=$(pgrep -f '\.opencode' 2>/dev/null || true) | |
| opencode_pids=$(pgrep -f '\.opencode' || true) |
References
- Avoid blanket suppression of command errors with '2>/dev/null' in shell scripts to ensure that system issues remain visible for debugging.
|
|
||
| # List detected interactive sessions with details. | ||
| # Output format: PID | APP | RSS_MB | UPTIME | DIR | ||
| list_sessions() { |
There was a problem hiding this comment.
The list_sessions function currently only lists details for 'OpenCode' and 'Claude Code' sessions. However, count_interactive_sessions also counts 'Cursor', 'Windsurf', and 'Aider' sessions. This can lead to confusing output from the list command, where the detailed list is shorter than the reported total. To improve clarity, please extend list_sessions to also find and display details for Cursor, Windsurf, and Aider processes, similar to how it's done for OpenCode and Claude Code.
References
- An info/describe function like 'list_sessions' should be comprehensive and include all relevant items, especially if another related function (e.g., 'count_interactive_sessions') counts them, to allow users to inspect their own work and avoid confusing output, aligning with the principle that info/describe functions must include relevant details.
…p -c incompatibility Address PR #2883 review feedback (Gemini Code Assist): - Remove 2>/dev/null from session-count-helper.sh calls in pre-edit-check.sh and aidevops-update-check.sh to surface diagnostic errors - Remove 2>/dev/null from pgrep calls in session-count-helper.sh (retain only on ps calls where PID race conditions justify suppression) - Fix pgrep -c flag usage (not available on macOS) — replace with pgrep | wc -l - Extend list_sessions() to include Cursor, Windsurf, and Aider details, matching the apps already counted by count_interactive_sessions() - Extract _print_session_detail() helper to reduce duplication Closes #2897
…ibility (#2945) * fix: remove blanket 2>/dev/null stderr suppression and fix macOS pgrep -c incompatibility Address PR #2883 review feedback (Gemini Code Assist): - Remove 2>/dev/null from session-count-helper.sh calls in pre-edit-check.sh and aidevops-update-check.sh to surface diagnostic errors - Remove 2>/dev/null from pgrep calls in session-count-helper.sh (retain only on ps calls where PID race conditions justify suppression) - Fix pgrep -c flag usage (not available on macOS) — replace with pgrep | wc -l - Extend list_sessions() to include Cursor, Windsurf, and Aider details, matching the apps already counted by count_interactive_sessions() - Extract _print_session_detail() helper to reduce duplication Closes #2897 * fix: remove redundant wc whitespace normalization in session-count-helper.sh Arithmetic expansion already handles leading whitespace from wc -l output, making the $((var + 0)) normalization steps unnecessary. Addresses Gemini Code Assist review feedback on PR #2945.
…ions() coverage Address PR #2883 review feedback (GH#2898): - Remove 2>/dev/null from all pgrep calls — || true already handles no-match exit codes, and stderr suppression hid real errors (e.g. pgrep -c unsupported on macOS) - Replace Linux-only pgrep -c with pgrep | wc -l for cross-platform compat - Extend list_sessions() to include Cursor, Windsurf, and Aider processes, matching the coverage of count_interactive_sessions() - Extract _print_session_detail() helper to reduce duplication in list output - Remove 2>/dev/null from session-count-helper.sh callers in aidevops-update-check.sh and pre-edit-check.sh Closes #2898
…ions() coverage Address PR #2883 review feedback (GH#2898): - Remove 2>/dev/null from all pgrep calls — || true already handles no-match exit codes, and stderr suppression hid real errors (e.g. pgrep -c unsupported on macOS) - Replace Linux-only pgrep -c with pgrep | wc -l for cross-platform compat - Extend list_sessions() to include Cursor, Windsurf, and Aider processes, matching the coverage of count_interactive_sessions() - Extract _print_session_detail() helper to reduce duplication in list output - Remove 2>/dev/null from session-count-helper.sh callers in aidevops-update-check.sh and pre-edit-check.sh Closes #2898
…ions() coverage (#2962) Address PR #2883 review feedback (GH#2898): - Remove 2>/dev/null from all pgrep calls — || true already handles no-match exit codes, and stderr suppression hid real errors (e.g. pgrep -c unsupported on macOS) - Replace Linux-only pgrep -c with pgrep | wc -l for cross-platform compat - Extend list_sessions() to include Cursor, Windsurf, and Aider processes, matching the coverage of count_interactive_sessions() - Extract _print_session_detail() helper to reduce duplication in list output - Remove 2>/dev/null from session-count-helper.sh callers in aidevops-update-check.sh and pre-edit-check.sh Closes #2898



Summary
session-count-helper.shthat detects interactive AI coding sessions (OpenCode, Claude Code, Cursor, Windsurf, Aider) and warns when the count exceeds a configurable threshold (default: 5)opencode run,claude -pare excluded)aidevops-update-check.sh) and pre-edit check (pre-edit-check.sh) as non-blocking warningsConfiguration
safety.max_interactive_sessions(default: 5, set to 0 to disable)AIDEVOPS_MAX_SESSIONSaidevops-config.schema.json) and defaults (aidevops.defaults.jsonc) updatedFiles Changed
.agents/scripts/session-count-helper.shcount,check,listcommands.agents/scripts/aidevops-update-check.sh.agents/scripts/pre-edit-check.sh.agents/configs/aidevops.defaults.jsoncsafety.max_interactive_sessions.agents/configs/aidevops-config.schema.json.agents/scripts/shared-constants.shAIDEVOPS_MAX_SESSIONSTesting
Verified on Linux with 2 interactive OpenCode sessions + multiple headless workers:
Headless workers (
opencode run ...) are correctly excluded from the count.Closes #2877