fix: skip update check in headless/non-interactive sessions#2400
fix: skip update check in headless/non-interactive sessions#2400marcusquinn merged 1 commit intomainfrom
Conversation
Add is_headless() detection to aidevops-update-check.sh that skips the network call to GitHub when running in headless dispatch mode. Detection uses three signals: env vars (FULL_LOOP_HEADLESS, OPENCODE_HEADLESS, AIDEVOPS_HEADLESS), --headless flag, and no-TTY on stdin. The --interactive flag overrides all headless detection, used by the AGENTS.md greeting flow when the model intentionally wants the full update check. Reduces headless session startup from ~300ms to ~10ms by eliminating the curl to api.github.com. Also updated ~/.config/opencode/AGENTS.md (global config, outside repo): - Added explicit SKIP RULES section with hard gates for slash commands, headless mode, and direct task instructions - Added Long-Running Tasks section pointing to ralph-loop for iterative development, with note that headless time budgets don't apply to interactive sessions - Changed update check call to pass --interactive flag
Summary of ChangesHello @marcusquinn, 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 addresses user feedback regarding slow non-interactive sessions and models ignoring skip rules by optimizing the 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
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
WalkthroughA new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
🔍 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 Feb 26 21:20:03 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Code Review
This pull request introduces a check to skip the update process in headless or non-interactive sessions, which is a valuable optimization. The implementation is sound, but I've suggested a refactoring for the new is_headless function to improve its efficiency and readability by simplifying argument parsing and consolidating conditional logic, aligning with best practices for robust CLI argument parsing and loop efficiency.
| is_headless() { | ||
| # Detect non-interactive/headless mode from multiple signals. | ||
| # The --interactive flag overrides all headless detection (used by | ||
| # AGENTS.md greeting flow when the model intentionally wants the | ||
| # full update check despite running inside a Bash tool with no TTY). | ||
| local arg | ||
| for arg in "$@"; do | ||
| if [[ "$arg" == "--interactive" ]]; then | ||
| return 1 | ||
| fi | ||
| done | ||
| # 1. Explicit env vars set by dispatch systems | ||
| if [[ "${FULL_LOOP_HEADLESS:-}" == "true" ]]; then | ||
| return 0 | ||
| fi | ||
| if [[ "${OPENCODE_HEADLESS:-}" == "true" ]]; then | ||
| return 0 | ||
| fi | ||
| if [[ "${AIDEVOPS_HEADLESS:-}" == "true" ]]; then | ||
| return 0 | ||
| fi | ||
| # 2. CLI flag: --headless passed to this script | ||
| for arg in "$@"; do | ||
| if [[ "$arg" == "--headless" ]]; then | ||
| return 0 | ||
| fi | ||
| done | ||
| # 3. No TTY on stdin (piped input, e.g. opencode run / claude -p) | ||
| # This catches cases where the model ignores AGENTS.md skip rules. | ||
| if [[ ! -t 0 ]]; then | ||
| return 0 | ||
| fi | ||
| return 1 | ||
| } |
There was a problem hiding this comment.
The is_headless function can be made more efficient and readable. It currently iterates over the script's arguments twice to check for --interactive and --headless flags. This can be done in a single pass, improving loop efficiency and aligning with best practices for robust CLI argument parsing. Additionally, the multiple if statements for checking environment variables can be consolidated into one for conciseness.
is_headless() {
# Detect non-interactive/headless mode from multiple signals.
# The --interactive flag overrides all headless detection (used by
# AGENTS.md greeting flow when the model intentionally wants the
# full update check despite running inside a Bash tool with no TTY).
local interactive=false
local headless=false
local arg
for arg in "$@" ; do
case "$arg" in
--interactive) interactive=true ;;
--headless) headless=true ;;
esac
done
if [[ "$interactive" == "true" ]]; then
return 1
}
# 1. Explicit env vars set by dispatch systems
if [[ "${FULL_LOOP_HEADLESS:-}" == "true" || "${OPENCODE_HEADLESS:-}" == "true" || "${AIDEVOPS_HEADLESS:-}" == "true" ]]; then
return 0
}
# 2. CLI flag
if [[ "$headless" == "true" ]]; then
return 0
}
# 3. No TTY on stdin (piped input, e.g. opencode run / claude -p)
# This catches cases where the model ignores AGENTS.md skip rules.
if [[ ! -t 0 ]]; then
return 0
}
return 1
}References
- When parsing CLI command strings to extract specific arguments, use a robust method that accounts for different flag formats (e.g., '--flag value', '--flag=value', and valueless flags) by maintaining a whitelist of flags known to consume an additional argument. This rule emphasizes using robust methods for parsing CLI arguments, which includes efficient single-pass processing of flags like
--interactiveand--headless. - In shell scripts, move the calculation of loop-invariant variables outside of loops to improve efficiency. This rule promotes improving loop efficiency by avoiding redundant iterations, such as processing the same argument list multiple times when a single pass suffices.



Summary
is_headless()detection toaidevops-update-check.shthat skips the GitHub API network call (~300ms) when running in headless dispatch modeFULL_LOOP_HEADLESS,OPENCODE_HEADLESS,AIDEVOPS_HEADLESS),--headlessflag, and no-TTY on stdin--interactiveflag overrides all headless detection for the greeting flow~/.config/opencode/AGENTS.md) with explicit SKIP RULES, long-running task guidance, and ralph-loop routingProblem
User feedback: "when I run a non-interactive opencode, it starts with aidevops update and that kills the whole point of the non-interactive part" and "the new system prompt is not letting it go through long running jobs"
Root Causes
opencode run), this added latency and sometimes blocked the session./ralph-loopor/full-loop.Changes
aidevops-update-check.shis_headless()function with layered detectionmain()that outputs version without network call--interactiveflag for explicit opt-in to full check~/.config/opencode/AGENTS.md(global config, not in repo)--interactiveflagTesting
ShellCheck: zero violations.
Summary by CodeRabbit
Release Notes