Skip to content

Make the agent step timeout configurable and record spend of failed runs#1746

Open
iyernaveenr wants to merge 1 commit into
eigent-ai:mainfrom
iyernaveenr:naveen_r_iyer/fix-step-timeout
Open

Make the agent step timeout configurable and record spend of failed runs#1746
iyernaveenr wants to merge 1 commit into
eigent-ai:mainfrom
iyernaveenr:naveen_r_iyer/fix-step-timeout

Conversation

@iyernaveenr

Copy link
Copy Markdown

Problem

Any agent turn longer than thirty minutes is aborted with Async step timed out after 1800s, regardless of whether it was making steady progress (observed with a long single-agent writing task that was still producing output when the ceiling hit). The limit is hardcoded, so deployments running long-form tasks cannot adjust it. In addition, a run that fails this way leaves its history row with zero tokens forever, hiding the real spend of the aborted work.

Root cause

  • ListenChatAgent hardcodes step_timeout: float | None = 1800; the underlying agent wraps each non-streaming step in asyncio.wait_for with that value, so the whole turn is cancelled at the ceiling. The screenshot toolkit repeats the same hardcoded fallback.
  • On the frontend, the error step handler marks the task failed but never updates the run's history row, so tokens stays at its initial zero even though per-exchange token counts had been accumulated client-side.

Fix

  • Backend: read the default step timeout from AGENT_STEP_TIMEOUT_SECONDS (seconds; same 1800 default when unset; a non-positive value disables the per-step ceiling; invalid values log a warning and keep the default). The screenshot toolkit fallback uses the same source instead of a second hardcoded constant. Explicit step_timeout arguments (e.g. the short validation timeouts) behave as before.
  • Frontend: when a run ends in an error, record the tokens accumulated so far into the run's history row (best-effort), so failed and timed-out runs no longer report zero spend.

Testing

  • Helper verified at runtime: unset -> 1800, 3600 -> 3600, 0 -> disabled, garbage -> warning + 1800. Both changed backend modules compile and import cleanly (no circular import).
  • tsc passes; lint and formatting clean for the changed frontend file; store test suites pass.
  • Reproduced the original failure with a long writing task aborted at exactly 1800s; with the token recording in place, an aborted run's history row carries the tokens consumed up to the failure.

A hardcoded thirty minute per-step ceiling aborted any longer agent
turn, with no way to adjust it per deployment. Read the limit from the
environment, keeping the same default; a non-positive value disables
the ceiling. When a run fails (including such timeouts), record the
tokens consumed so far in the run's history row, which previously
stayed at zero forever, hiding the spend of the aborted work.

Signed-off-by: Naveen R. Iyer <iyernaveenr@gmail.com>
@Douglasymlai Douglasymlai added the discussion Align change with internal roadmap label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussion Align change with internal roadmap

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants