Skip to content

(feat) Runner should rebuild session context from records when a session cannot be resumed warm #5443

Description

@mmabrouk

Problem

Today the front end resends the entire message history to the runner on every turn (web/packages/agenta-playground/src/state/execution/agentRequest.ts, the history array). This is a pre-sessions workaround, and it has real costs: the payload grows with every turn, and any attachment bytes in the history are re-uploaded again and again.

The product direction is the opposite split of responsibility:

  • The front end sends only the last message on each turn.
  • The runner owns conversation context. When a session is warm, the harness already holds the context. When a session cannot be resumed warm (runner restart, sandbox eviction, crash), the runner should read the session's records and rebuild the conversation itself before running the new turn.

The substrate for this already exists. The runner persists every event to the API's records log independent of any browser (services/runner/src/sessions/persist.ts, POST /sessions/records/ingest), and records can be queried back (POST /sessions/records/query, RecordsRouter in api/oss/src/apis/fastapi/sessions/router.py). What is missing is the runner-side rebuild: on a cold start, query the records for the session and reconstruct the harness conversation from them, instead of relying on the front end to resend everything.

Todo

  • Runner: on cold session start, query /sessions/records/query for the session and rebuild the conversation context from records before running the new turn.
  • Front end: once the runner rebuild lands, stop resending full history and send only the last message.
  • Make the cold-replay rendering faithful (today a past image is replayed as the literal string "[image]", services/runner/src/engines/sandbox_agent/transcript.ts). The agent multi-modality design (PR [docs] Plan agent multi-modality #5439) makes records carry small attachment references instead of bytes, which is what a faithful rebuild needs.

Related

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions