Repository navigation
Give opencode real timeout headroom in Local Agent Guides CI - #7235
Conversation
The connection (opencode) cell flakes with a 600s timeout reported as guide drift, but it is not a hang: in a passing run the same opencode run finishes in ~482s (08:12:31 to 08:20:33), right against the shared AGENT_INVOKE_TIMEOUT of 600s, so about one run in six drifts past the cap. opencode is the slow outlier. The print-mode agents (claude -p, codex exec) run one turn against a minimal injected system prompt, while opencode run runs its own full turn with opencode's large system prompt plus a separate small_model call to name the session (start.py pins small_model to the same 4B the server hosts). On a CPU-served gemma-4-E4B that is about 8 minutes, leaving no margin under 600s. Double opencode's per-invoke timeout in agent-guides-drive.sh and keep the tight 600s cap for the fast agents, so a genuine headless-TTY hang still fails quickly. 1200s stays well under the 40-minute job budget.
There was a problem hiding this comment.
Code Review
This pull request doubles the timeout limit for the 'opencode' agent in .github/scripts/agent-guides-drive.sh to prevent test flakiness caused by its slower execution. Feedback points out that if the timeout value contains a trailing 's' suffix, the arithmetic multiplication will fail with a syntax error in Bash, and suggests stripping the suffix beforehand.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| # headroom (still well under the 40-min job budget); the fast agents keep the | ||
| # tight cap that still catches a real headless-TTY hang. | ||
| case "$AGENT" in | ||
| opencode) TIMEOUT=$(( TIMEOUT * 2 )) ;; |
There was a problem hiding this comment.
If AGENT_INVOKE_TIMEOUT is configured with a trailing s suffix (e.g., 600s), which is a common format for timeout values, the arithmetic expansion $(( TIMEOUT * 2 )) will fail with a syntax error in Bash. Additionally, if the suffix is preserved, the error message on line 145 (timed out after ${TIMEOUT}s) would print 1200ss.
We can robustly handle this by stripping the trailing s suffix before performing the multiplication.
| opencode) TIMEOUT=$(( TIMEOUT * 2 )) ;; | |
| opencode) | |
| TIMEOUT_NUM="${TIMEOUT%s}" | |
| TIMEOUT=$(( TIMEOUT_NUM * 2 )) | |
| ;; |
There was a problem hiding this comment.
Good catch. Normalized at assignment in 2b5936b: TIMEOUT="${TIMEOUT%s}" strips an optional trailing 's' before the doubling, so both the arithmetic and the "${TIMEOUT}s" message stay valid for a timeout(1)-style value. Placed it at the assignment so it also covers the non-opencode display path, not just the opencode branch.
Strip an optional trailing 's' from AGENT_INVOKE_TIMEOUT so the opencode
arithmetic, and the "${TIMEOUT}s" timeout message, stay valid if a
timeout(1)-style suffix is ever configured.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b5936b614
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # headroom (still well under the 40-min job budget); the fast agents keep the | ||
| # tight cap that still catches a real headless-TTY hang. | ||
| case "$AGENT" in | ||
| opencode) TIMEOUT=$(( TIMEOUT * 2 )) ;; |
There was a problem hiding this comment.
Preserve all GNU timeout duration formats
When a caller sets AGENT_INVOKE_TIMEOUT using a valid non-second GNU timeout duration such as 10m, 1h, or 0.5s, this arithmetic expansion fails before the agent is invoked (10m: value too great for base / invalid arithmetic). GNU timeout --help explicitly accepts floating-point values with optional s, m, h, or d suffixes, all of which worked before this change because the value was passed through unchanged. Normalize these formats to seconds before doubling, or only apply arithmetic when the value is a numeric seconds value.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good call. Reworked in 2fcb24c to only apply the doubling when TIMEOUT is a bare-integer seconds value; any GNU timeout(1) duration suffix (s/m/h/d, including floats like 0.5s) is now passed through unchanged and parsed by timeout(1) directly, so the arithmetic never sees a non-number. Bare seconds (the CI default) still double.
Guard the arithmetic so a GNU timeout(1) duration suffix (s/m/h/d, including floats like 0.5s) is passed through unchanged instead of breaking the expansion; timeout(1) parses those directly. Bare seconds still double.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…ai#7235) * Raise the opencode invoke timeout in Local Agent Guides CI The connection (opencode) cell flakes with a 600s timeout reported as guide drift, but it is not a hang: in a passing run the same opencode run finishes in ~482s (08:12:31 to 08:20:33), right against the shared AGENT_INVOKE_TIMEOUT of 600s, so about one run in six drifts past the cap. opencode is the slow outlier. The print-mode agents (claude -p, codex exec) run one turn against a minimal injected system prompt, while opencode run runs its own full turn with opencode's large system prompt plus a separate small_model call to name the session (start.py pins small_model to the same 4B the server hosts). On a CPU-served gemma-4-E4B that is about 8 minutes, leaving no margin under 600s. Double opencode's per-invoke timeout in agent-guides-drive.sh and keep the tight 600s cap for the fast agents, so a genuine headless-TTY hang still fails quickly. 1200s stays well under the 40-minute job budget. * Normalize the agent invoke timeout before doubling it for opencode Strip an optional trailing 's' from AGENT_INVOKE_TIMEOUT so the opencode arithmetic, and the "${TIMEOUT}s" timeout message, stay valid if a timeout(1)-style suffix is ever configured. * Only double the opencode timeout for a bare-integer seconds value Guard the arithmetic so a GNU timeout(1) duration suffix (s/m/h/d, including floats like 0.5s) is passed through unchanged instead of breaking the expansion; timeout(1) parses those directly. Bare seconds still double. --------- Co-authored-by: danielhanchen <[email protected]>
Problem
The
connection (opencode)cell of Local Agent Guides CI flakes with a timeout, surfaced as guide drift:It is not actually a hang. In a passing run the same
opencode runfinishes in about 482s (08:12:31 to 08:20:33), which sits right against the sharedAGENT_INVOKE_TIMEOUTof 600s. Roughly one recent run in six drifts past the cap and fails, so this cell has been intermittently red on unrelated PRs.Why opencode is the slow one
The print-mode agents (
claude -p,codex exec) run a single turn against the minimal system prompt the workflow injects.opencode runis different: it runs its own full turn with opencode's large system prompt, and on top of that it makes a separatesmall_modelcall to name the session (start.pypinssmall_modelto the same 4B the server hosts). On a CPU-served gemma-4-E4B that is roughly 8 minutes of prefill and generation, so 600s leaves almost no margin and normal per-run variance tips it over.Fix
Give opencode double the per-invoke timeout in
agent-guides-drive.sh, and keep the tight 600s cap for the fast agents so a genuine headless-TTY hang still fails quickly. 1200s stays well under the 40-minute job budget.Verification
bash -nandshellcheck -S warningclean onagent-guides-drive.sh.