Skip to main content
A state is one stage of what a research agent is doing: “it is asking the model what to do”, “it is reading this page”, “it is writing the report”. The states of a run are its history, kept in the order the agent entered them, so you can see how a research went from start to end. States are about activity. They are not about the research plan: the sub-questions the investigative loop works through are the frontier questions (deep-research-loop.md), with their own statuses. The two only meet in the selecting and delegating states, which say which question the loop picked or handed out. This page explains what a state is, which states exist, how they are stored and how to read them. The run they belong to (its status, the report, the usage) is in research.md, and the agent’s loop in deep-research-agent.md.

What a state holds

Each state is a row of gb_agent_research_states: The table is append-only. A state is entered, then ended (finished_at set); it is never rewritten. The current state of a run is always its last row, and the run’s state field mirrors it. Each run has its own states. A sub-agent of the investigative loop is a run of its own, so it has its own states, and it is listed with its parent (see subagents.md).

The states

Common to all loops

The usual path of a simple run is starting, then thinking and a tool state (searching, reading, querying, remembering or using_tool) as many times as the model needs, then thinking again and completed. When the agent uses all its steps, the last model call is writing_report instead, so a run always ends with a report. A run that fails has the state it failed in with the error, followed by a failed state that carries the error too.

Investigative loop

A run of an agent with loop = "investigative" (agent-defs.md) adds these states, which describe the loop’s own steps (deep-research-loop.md): The detail of a turn of this loop is turn 7 of 60, question q_003. A tool call inside the loop keeps its usual state (searching, reading, …).

Other

  • spawning: the spawn_subagent tool of the simple loop was removed in 0.189.0. Runs made before then still have these rows; no new run enters it.
  • importing: only for a run in Modal (runner modal). The container has ended and the server loads what the agent learned into its databases. An error on this state says why the import failed; the run keeps its report.

Reading the states

REST and MCP

GET /v1/gb/research/{id} returns the run with its states, in the order they were entered:
The same run is returned by the research_get MCP tool. The timestamps and the rest of the states are omitted here. GET /v1/gb/research/{id}/stream pushes the run as Server-Sent Events, and each snapshot carries the states too. The admin UI shows them in the States section of a run’s Details modal.

CLI

gligabao research get ID prints the run with every state it went through. Add --raw to print only the report.

Progress events

The standalone binary gligabao_agent prints one JSON line each time an agent enters a state:
agent is main or the name of a sub-agent, and state_seq numbers the states of that agent from 1. When a state ends with an error, the same state_seq is written once more with the error set.

How the states are recorded

The states are written by the manager of the research (internal/agent_research/). The agent reports each model call and tool run to an observer, and the manager turns them into state rows. The names are constants in internal/agent_research/core/core.go, and the investigative loop’s names are in internal/agent_research/investigate_core/loop_state.go. Both tables are defined in internal/agent_research/db/sqlite/sql/schema.sql and internal/agent_research/db/postgres/sql/schema.sql. A run of the Modal runner records the states its container reports, and the sub-agents’ states inside it are imported with the sub-agent’s name in front of the detail (research.md).

States and frontier questions, side by side

A question’s status is a different enum from a run’s state, even where the words look alike.