In this article
OpenRouter agent state organizes structured conversation transitions; it does not replace external artifact state, and format conversion cannot create missing tool evidence.
An agent loop needs more than a list of user-visible chat bubbles. It also tracks structured tool requests, returned observations and the point at which work should continue or stop. OpenRouter’s agent-toolkit state helpers belong to this orchestration layer, while ordinary API message history remains part of the model-input contract.
Identify the state the next step depends on
Imagine a repository assistant that requests a file lookup and then explains the result. Before the lookup finishes, the loop has an outstanding operation; afterward, it has an observation associated with that request. Displaying only the final prose would hide this transition. The API reference and client-tools guide describe the structured exchange. The application’s state needs enough information to determine what the next model step can legitimately use, without confusing a planned action with evidence already obtained.
Toolkit helpers organize an application concern
The migration guide lists conversation state helpers and message-format converters among the agent-toolkit surfaces. Their presence should not be interpreted as a claim that every external process or repository state is automatically captured. In the lookup example, a helper can participate in arranging conversation data, while the actual file and command outcome remain separate artifacts. This article explains the architectural distinction rather than inventing a helper’s undocumented object shape or a persistence guarantee that the guide does not provide.
Format conversion is not evidence creation
A converter can represent existing conversation material in a target interface. It cannot make an unexecuted tool call into a completed lookup or reconstruct information that the application discarded. Preserve the required identifiers and supported structured items when building the next request. Chat Completions messages and Responses API output/input items differ in shape. A valid conversion therefore follows their contracts, while factual correctness still depends on the original observation and its relationship to the task.
Test continuation across a meaningful boundary
A useful fixture pauses after requesting the lookup, supplies the actual result and checks that the next step uses it correctly. Another fixture can represent a failed lookup so the loop does not silently invent success. These are focused engineering checks of the state transition. Package migration adds a separate import-ownership question: the guide places agent helpers in @openrouter/agent. Keeping package interface, conversation representation and external artifact state distinct makes a resumed agent workflow easier to explain and prevents a visible chat transcript from being mistaken for a complete execution record.
Primary sources
Related context: Provider routing; Tool-calling integration.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.