Make the agent step timeout configurable and record spend of failed runs#1746
Open
iyernaveenr wants to merge 1 commit into
Open
Make the agent step timeout configurable and record spend of failed runs#1746iyernaveenr wants to merge 1 commit into
iyernaveenr wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ListenChatAgenthardcodesstep_timeout: float | None = 1800; the underlying agent wraps each non-streaming step inasyncio.wait_forwith that value, so the whole turn is cancelled at the ceiling. The screenshot toolkit repeats the same hardcoded fallback.tokensstays at its initial zero even though per-exchange token counts had been accumulated client-side.Fix
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. Explicitstep_timeoutarguments (e.g. the short validation timeouts) behave as before.Testing
3600-> 3600,0-> disabled, garbage -> warning + 1800. Both changed backend modules compile and import cleanly (no circular import).tscpasses; lint and formatting clean for the changed frontend file; store test suites pass.