Skip to content

t1085: Increase AI reasoning timeout from 120s to 300s#1643

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/t1085-ai-timeout
Feb 18, 2026
Merged

t1085: Increase AI reasoning timeout from 120s to 300s#1643
marcusquinn merged 1 commit intomainfrom
bugfix/t1085-ai-timeout

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 18, 2026

Summary

  • Increases default SUPERVISOR_AI_TIMEOUT from 120s to 300s (5 min)
  • Opus needs more time to analyze 15KB+ of project context and produce structured JSON
  • First successful AI response was cut off mid-reasoning at 120s (2005 bytes of chain-of-thought, no JSON output)
  • Still configurable via SUPERVISOR_AI_TIMEOUT env var

Evidence

From reason-20260218-142828.md — first run with working --format default:

Summary by CodeRabbit

  • Bug Fixes
    • Increased AI session timeout from 2 minutes to 5 minutes to improve stability and reduce premature session terminations during longer operations.

Opus needs more than 120s to analyze 15KB+ of project context and
produce a structured JSON action plan. The first successful AI
response (2005 bytes of reasoning) was cut off mid-thought by the
timeout. 300s (5 min) gives opus adequate time for complex analysis.
Configurable via SUPERVISOR_AI_TIMEOUT env var.
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 an issue where AI reasoning processes were prematurely terminating due to insufficient timeout periods. By extending the default AI timeout, it ensures that AI models have adequate time to complete complex analyses and produce comprehensive, structured responses, thereby improving the reliability and completeness of AI-driven operations.

Highlights

  • AI Reasoning Timeout Increase: Increased the default SUPERVISOR_AI_TIMEOUT from 120 seconds to 300 seconds (5 minutes) to accommodate the processing time required by advanced AI models like Opus for analyzing large contexts and generating structured JSON output.
Changelog
  • .agents/scripts/supervisor/ai-reason.sh
    • Updated the default value for the ai_timeout variable from 120 to 300 seconds.
    • Added a comment explaining the rationale for the increased timeout, specifically mentioning the needs of the Opus model for processing large contexts and generating structured JSON.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

Walkthrough

The AI session timeout in the supervisor script is increased from 120 to 300 seconds, with a comment explaining the change relates to Opus context size. Control flow and error handling logic remain unchanged.

Changes

Cohort / File(s) Summary
Timeout Configuration
.agents/scripts/supervisor/ai-reason.sh
Increased default ai_timeout from 120 to 300 seconds with explanatory comment referencing Opus context size requirements.

Estimated Code Review Effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

⏳ More time for thoughts to brew and brew,
Five minutes now for Opus' view,
From two to three—the patient way,
Context thrives when timers play! 🤖✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: increasing the AI reasoning timeout from 120s to 300s, directly matching the changeset modification in ai-reason.sh.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t1085-ai-timeout

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 23 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Feb 18 14:35:06 UTC 2026: Code review monitoring started
Wed Feb 18 14:35:07 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 23

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 23
  • VULNERABILITIES: 0

Generated on: Wed Feb 18 14:35:09 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request effectively increases the AI reasoning timeout from 120 seconds to 300 seconds, addressing the need for the Opus model to have more time to process large contexts and produce structured JSON output. The change is clearly documented with an inline comment explaining the rationale. The modification is straightforward and aligns with the functional requirements described.

@marcusquinn marcusquinn merged commit f6a971f into main Feb 18, 2026
10 of 11 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.agents/scripts/supervisor/ai-reason.sh (1)

146-153: ⚠️ Potential issue | 🟠 Major

Stale-lock threshold now equals the AI timeout — concurrent sessions possible.

With the timeout raised to 300 s, the condition lock_age -lt 300 on line 147 gives zero margin. A legitimate session that is still running at second 300 will have lock_age == 300, fail the < 300 check, and be treated as stale even though the process is alive — letting a second reasoning session start concurrently.

Previously (120 s timeout vs 300 s stale-guard) there was a comfortable 180 s buffer. That buffer is now gone.

🔒 Proposed fix — derive stale threshold from the timeout env-var
-		# If lock holder is still alive and lock is not stale (< 5 min), skip
-		if kill -0 "$lock_pid" 2>/dev/null && [[ "$lock_age" -lt 300 ]]; then
+		# If lock holder is still alive and lock is not stale (timeout + 60s buffer), skip
+		local _lock_stale_threshold=$(( ${SUPERVISOR_AI_TIMEOUT:-300} + 60 ))
+		if kill -0 "$lock_pid" 2>/dev/null && [[ "$lock_age" -lt "$_lock_stale_threshold" ]]; then

This keeps the threshold in sync with whatever value SUPERVISOR_AI_TIMEOUT is set to, including when it is overridden via the environment.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/supervisor/ai-reason.sh around lines 146 - 153, The
stale-lock check uses a hardcoded 300s and the "< 300" test so a live process at
exactly 300s is treated as stale; change the code to read SUPERVISOR_AI_TIMEOUT
(defaulting to 300 if unset) into a variable (e.g., AI_TIMEOUT) and use that for
the comparison, and treat equality as still-live (use -le "$AI_TIMEOUT" or
equivalent) when checking lock_age against lock_pid/lock_file so the stale
threshold follows the configured timeout and avoids concurrent sessions.
🧹 Nitpick comments (1)
.agents/scripts/supervisor/ai-reason.sh (1)

485-494: sed bracket extraction stops at the first ], not the last.

sed -n '/\[/,/\]/p' prints from the first line containing [ to the first line containing ]. For a multi-line JSON array with nested arrays (e.g., a "tags" field), this truncates at the first closing bracket inside the payload, producing unparseable JSON. jq will reject it and the fallback returns empty, so this degrades gracefully rather than silently corrupting — but it means Try 4 is effectively a no-op for any non-trivial response.

♻️ More robust bracket extraction with Python/awk
-	# Try 4: Find first [ and last ] in the response
-	local bracket_json
-	bracket_json=$(printf '%s' "$response" | sed -n '/\[/,/\]/p')
-	if [[ -n "$bracket_json" ]]; then
-		parsed=$(printf '%s' "$bracket_json" | jq '.' 2>/dev/null)
-		if [[ $? -eq 0 && -n "$parsed" ]]; then
-			printf '%s' "$parsed"
-			return 0
-		fi
-	fi
+	# Try 4: Extract from first [ to matching last ] using Python for bracket-depth tracking
+	local bracket_json
+	bracket_json=$(printf '%s' "$response" | python3 -c "
+import sys, json
+text = sys.stdin.read()
+start = text.find('[')
+if start == -1: sys.exit(1)
+depth, end = 0, -1
+for i, ch in enumerate(text[start:], start):
+    if ch == '[': depth += 1
+    elif ch == ']':
+        depth -= 1
+        if depth == 0: end = i; break
+if end != -1: print(text[start:end+1])
+" 2>/dev/null || echo "")
+	if [[ -n "$bracket_json" ]]; then
+		parsed=$(printf '%s' "$bracket_json" | jq '.' 2>/dev/null)
+		if [[ $? -eq 0 && -n "$parsed" ]]; then
+			printf '%s' "$parsed"
+			return 0
+		fi
+	fi

This tracks bracket depth, correctly handling nested arrays in tags, questions, etc.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/scripts/supervisor/ai-reason.sh around lines 485 - 494, The sed
range extraction using "bracket_json=$(printf '%s' \"$response\" | sed -n
'/\\[/,/\\]/p')" stops at the first closing bracket and fails for nested arrays;
change Try 4 to extract the JSON array by tracking bracket depth instead (e.g.,
use an awk or Python one-liner that reads "$response", finds the first '[' and
then emits characters until matching the corresponding closing ']' accounting
for nested brackets), assign that output back to bracket_json, then keep the
existing parsed=$(printf '%s' "$bracket_json" | jq '.' 2>/dev/null) and checks;
ensure you reference the same variables (response, bracket_json, parsed) so the
subsequent jq parsing logic is unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In @.agents/scripts/supervisor/ai-reason.sh:
- Around line 146-153: The stale-lock check uses a hardcoded 300s and the "<
300" test so a live process at exactly 300s is treated as stale; change the code
to read SUPERVISOR_AI_TIMEOUT (defaulting to 300 if unset) into a variable
(e.g., AI_TIMEOUT) and use that for the comparison, and treat equality as
still-live (use -le "$AI_TIMEOUT" or equivalent) when checking lock_age against
lock_pid/lock_file so the stale threshold follows the configured timeout and
avoids concurrent sessions.

---

Nitpick comments:
In @.agents/scripts/supervisor/ai-reason.sh:
- Around line 485-494: The sed range extraction using "bracket_json=$(printf
'%s' \"$response\" | sed -n '/\\[/,/\\]/p')" stops at the first closing bracket
and fails for nested arrays; change Try 4 to extract the JSON array by tracking
bracket depth instead (e.g., use an awk or Python one-liner that reads
"$response", finds the first '[' and then emits characters until matching the
corresponding closing ']' accounting for nested brackets), assign that output
back to bracket_json, then keep the existing parsed=$(printf '%s'
"$bracket_json" | jq '.' 2>/dev/null) and checks; ensure you reference the same
variables (response, bracket_json, parsed) so the subsequent jq parsing logic is
unchanged.

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