Repository navigation
Description
A conversation's turn, tool-result continuation and resume each start when the host calls them; the full runtime does not queue them per conversation or per session. A turn that starts while a continuation or a resume of the same conversation runs interleaves with it.
Failing input. A turn pauses for read_file. The host passes its result with handleToolResults() and, before that stream ends, sends the conversation's next message with processRequest().
What happens (read at master after #636):
- The continuation takes the pause in one synchronous step (
ExternalToolResultHandler.takeStreamPause(), or the resume's take after its second check), so the new turn's start (TurnExecutionPipeline.prepareTurn(), theendSavedPausecall before Phase 8) finds no pause to end. - Phase 8 records the new turn's input while the continuation has not yet recorded its results or its reply, so the input lands among the continuation's messages: the stored history can hold the pause's
tool_calls, then the user's message, then the tool results, which providers refuse as a call not followed by its results. - Both run on the session's GMI. The shipped
GMIrefuses a user turn while a continuation keeps itPROCESSING(GMI.ensureReady(),SYS_INVALID_STATE), but only after Phase 8 recorded the turn's input; before the continuation reaches the GMI, the turn runs beside it.
Stated as a limit in docs/TURN_LIFECYCLE.md (opening paragraph) and docs/getting-started/HIGH_LEVEL_API.md (the one-instance paragraph): start a conversation's next turn once the stream of its continuation or resume has ended.
Design question. Two ways to close it:
- Queue a session's operations, as
agent().session()does with itsTurnLock(src/api/runtime/gmiSession.ts). A tool that a continuation runs and that starts a turn on its own conversation would wait on the continuation that waits on it, so a queue needs a rule for nested operations. - Refuse a turn, before Phase 2 acquires the GMI and before Phase 8 records anything, while a continuation or a resume of its conversation runs (
SYS_INVALID_STATE), so the host retries once that stream ends.
The integration test a new turn that starts while a resume continues the pause leaves the pause to the resume, so its call is answered once (tests/api/AgentOS.toolResultContinuation.integration.spec.ts) runs this interleaving today and checks only that the call is answered once.
Links
- Docs: https://github.com/framerslab/agentos/blob/master/docs/TURN_LIFECYCLE.md
- Docs: https://github.com/framerslab/agentos/blob/master/docs/getting-started/HIGH_LEVEL_API.md
Activity
jddunn commentedon Nov 23, 2026
23 Nov 2026 UTC. The overlap is still covered by the documented host sequencing rule. A runtime fix needs a decision on how turns, continuations and resumes share the session queue, including re-entrant tool calls and when to record input. That has to be decided before changing the ordering.