agenta icon indicating copy to clipboard operation
agenta copied to clipboard

(bug) Turns longer than 15 minutes lose their end time: the turn-complete call gets a 401

Open mmabrouk opened this issue 2 months ago • 4 comments

When a turn runs longer than 15 minutes, I expect the runner to record the end of the turn. Instead the runner's turn-complete call is rejected with a 401 and the turn row keeps end_time = NULL. The turn itself finishes fine and the transcript is complete. Continuity still loads on the next turn.

Steps to reproduce

Reproduced on the self-hosted OSS stack agenta-oss-team, images v0.115.2, local sandbox, Codex harness.

  1. Start a turn that runs for more than 15 minutes.
  2. Let it finish.
  3. Read the turn row in session_turns.

Session 5df56bf3-7332-40ee-9c93-271c0ef655c2, turn 10, started 11:55:46, ended 12:14:02 (18 minutes):

api log:

12:14:02 [DEBUG] [auth] unauthorized [oss.src.middlewares.auth] status_code=401 path=/sessions/turns/complete method=POST reason=expired_signature detail={'message': 'Unauthorized', 'reason': 'expired_signature'}
12:14:02 172.21.0.1:58814 - "POST /sessions/turns/complete HTTP/1.1" 401

runner log:

[sandbox-agent] complete HTTP 401 session=5df56bf3-7332-40ee-9c93-271c0ef655c2 turn=10

database, every turn of this session longer than 15 minutes has no end time:

turn_index | start_time                 | end_time
        10 | 2026-09-06 11:55:46.684+00 | (null)
         9 | 2026-09-07 09:33:18.551+00 | (null)
         5 | 2026-09-06 18:57:23.824+00 | (null)
         3 | 2026-09-06 15:12:16.222+00 | (null)

Turns shorter than 15 minutes in the same session all have an end time and a 200 on the same call.

mmabrouk avatar Sep 07 '26 16:09 mmabrouk

AGE-4283

linear-code[bot] avatar Sep 07 '26 16:09 linear-code[bot]

@mmabrouk i would like to work on this issue if it is still available

connect-aima avatar Sep 08 '26 10:09 connect-aima

thanks @connect-aima. this one is for the internal team because it spans the runner, api authentication, and turn state. #6659 is a smaller open issue if you'd like to take it.

mmabrouk avatar Sep 08 '26 16:09 mmabrouk

Closing: fixed by PR #7350 ("use current credentials for turn completion"). completeTurn in services/runner/src/engines/sandbox_agent/run-turn.ts now sends authorization: credential() from the live lease. A turn longer than 15 minutes no longer gets a 401. b790eff9e does the same for approval rows.


Generated by Claude Code

ashrafchowdury avatar Nov 04 '26 22:11 ashrafchowdury