Skip to content
Changelog

Session runs stay in order after deletes, and team runs reload RunStatus

November 12, 20261 min read

Agno's SQL databases, SingleStore included, now keep session history in order after you delete runs, and reloaded team and workflow runs get their RunStatus enum back. Before, if you deleted a session's first runs and then started a new one, get_session() returned history out of order. The runs below are real, on SQLite, from the earlier release and this one.

New runs land after the survivors

Agno passes upsert_run the run's position in the in-memory session.runs list. Once earlier runs were deleted, that position fell below rows still in the table, so the new run sorted ahead of older ones. The SQL adapters now store the larger of that position and the session's highest run_index plus one.

for i, run_id in enumerate(["r0", "r1", "r2"]):
    db.upsert_run(RunOutput(run_id=run_id, agent_id="a1", session_id="s1"), session_id="s1", run_index=i)
db.delete_runs(["r0", "r1"])
db.upsert_run(RunOutput(run_id="r3", agent_id="a1", session_id="s1"), session_id="s1", run_index=1)
# Before
rows: [('r3', 1), ('r2', 2)]   get_session order: ['r3', 'r2']
 
# Now
rows: [('r2', 2), ('r3', 3)]   get_session order: ['r2', 'r3']

SingleStoreDb follows the same rule

SingleStore rejects a subquery in the VALUES list of an upsert, so SingleStoreDb reads the session's highest run_index in the INSERT's SELECT and gives new runs the same place in line.

Team and Workflow runs reload their RunStatus

TeamRunOutput.from_dict() and WorkflowRunOutput.from_dict() left the stored status as a string, so a run loaded from a database or the AgentOS client broke any code that read .status.value, the AgentOS team and workflow routers among them. Both now turn the string back into RunStatus, as RunOutput already did. This team run went through SqliteDb and back:

# Before
'COMPLETED'
 
# Now
<RunStatus.completed: 'COMPLETED'>

See the SQLite for Team cookbook, and learn more about session storage and SingleStore in the documentation.

Frequently asked questions

SqliteDb, PostgresDb, MySQLDb and SingleStoreDb do, plus the async SQLite, Postgres and MySQL adapters. Each one stores max(provided index, highest stored index + 1).

No. Saving a run that is already stored keeps its index, so a status update leaves history order as it was. An explicit index above the session's maximum is also kept.

Code that read .status.value on a TeamRunOutput or WorkflowRunOutput loaded from storage got AttributeError: 'str' object has no attribute 'value', because the status came back as a plain string such as 'COMPLETED'.

Shipped around the same time