﻿# How OpenRouter agent-toolkit state relates to ordinary chat history

OpenRouter agent state organizes structured conversation transitions; it does not replace external artifact state, and format conversion cannot create missing tool evidence.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/learn-openrouter-toolkit-state/
Language: en

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

- [OpenRouter agent SDK migration](https://openrouter.ai/docs/client-sdks/agent-migration).

- [OpenRouter API reference](https://openrouter.ai/docs/api-reference/overview).

- [OpenRouter provider selection](https://openrouter.ai/docs/guides/routing/provider-selection).

Related context: [Provider routing](/journal/openrouter-provider-routing/); [Tool-calling integration](/journal/openrouter-tool-calling/).
