Skip to content

feat: unify agent turn timeout and fix codex render boundary#18

Merged
axeldelafosse merged 1 commit intomainfrom
feat/unify-agent-turn-timeout
Feb 25, 2026
Merged

feat: unify agent turn timeout and fix codex render boundary#18
axeldelafosse merged 1 commit intomainfrom
feat/unify-agent-turn-timeout

Conversation

@axeldelafosse
Copy link
Copy Markdown
Owner

Summary

  • Unified turn timeout: Extracted a single AGENT_TURN_TIMEOUT_MS constant in constants.ts, replacing the duplicated WAIT_TIMEOUT_MS (codex) and DEFAULT_WAIT_TIMEOUT_MS (claude) definitions. Both servers now import from one source of truth.
  • Increased timeout: Bumped from 10 minutes to ~11.7 hours to support long-running agent sessions without spurious timeouts.
  • Codex render fix: Skip message boundary insertion when a completed event matches an item already streamed via deltas, preventing spurious line breaks mid-stream.

Test plan

  • Verify long-running codex and claude turns no longer time out prematurely
  • Confirm codex pretty-format output doesn't insert extra newlines between delta-streamed and completed messages
  • Run bun run check — passes cleanly

- Extract AGENT_TURN_TIMEOUT_MS (≈11.7h) into constants.ts as single source of truth
- Replace per-file WAIT_TIMEOUT_MS / DEFAULT_WAIT_TIMEOUT_MS with shared constant
- Fix codex renderer skipping message boundary when completed event matches active delta stream
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @axeldelafosse, 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 refactors agent timeout mechanisms by consolidating disparate timeout constants into a single, shared source and substantially extending the timeout duration to accommodate prolonged agent interactions. Additionally, it addresses a rendering anomaly in the Codex agent to ensure cleaner output by preventing unnecessary message boundaries when streaming content.

Highlights

  • Unified Agent Turn Timeout: A new constant, AGENT_TURN_TIMEOUT_MS, has been introduced in constants.ts to centralize the timeout definition for both Claude and Codex agents, replacing previously duplicated WAIT_TIMEOUT_MS and DEFAULT_WAIT_TIMEOUT_MS.
  • Increased Timeout Duration: The agent turn timeout has been significantly increased from 10 minutes to approximately 11.7 hours (42,000,069 ms) to prevent premature timeouts during long-running agent sessions.
  • Codex Render Boundary Fix: Logic was added to codex-render.ts to prevent spurious line breaks by skipping message boundary insertion when a completed event corresponds to an item already streamed via deltas.
Changelog
  • src/loop/claude-sdk-server.ts
    • Replaced DEFAULT_WAIT_TIMEOUT_MS with the new AGENT_TURN_TIMEOUT_MS constant for consistency.
  • src/loop/codex-app-server.ts
    • Removed the local WAIT_TIMEOUT_MS constant and adopted the unified AGENT_TURN_TIMEOUT_MS.
    • Updated timeout calls to use the new AGENT_TURN_TIMEOUT_MS constant.
  • src/loop/codex-render.ts
    • Implemented conditional logic to skip message boundary insertion if a completed event matches an already delta-streamed item, preventing redundant newlines.
  • src/loop/constants.ts
    • Added a new constant AGENT_TURN_TIMEOUT_MS and set its value to 42,000,069 milliseconds.
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.

Copy link
Copy Markdown

@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

This pull request successfully unifies the agent turn timeout into a single constant, AGENT_TURN_TIMEOUT_MS, and significantly increases its value to support long-running sessions. The change is correctly applied across both the Claude and Codex servers. Additionally, it introduces a fix in the Codex renderer to prevent extra newlines, improving output formatting. The changes are logical and well-implemented. I have one suggestion regarding the new timeout constant to improve code maintainability.

Comment thread src/loop/constants.ts
@axeldelafosse axeldelafosse merged commit 4ddefbf into main Feb 25, 2026
2 checks passed
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