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

> Agno SQL databases, SingleStoreDb included, now place new runs after a session's stored runs, and team and workflow runs reload their RunStatus.

- Published: 2026-11-12
- Author: Bas Nijholt
- Categories: Changelog
- Canonical: https://www.agno.com/blog/session-runs-stay-in-order-after-deletes-and-team-runs-reload-runstatus
- Markdown: https://www.agno.com/blog/session-runs-stay-in-order-after-deletes-and-team-runs-reload-runstatus.md

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.

```python
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)
```

```text
# 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:

```text
# Before
'COMPLETED'

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

See the [SQLite for Team cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/06_storage/sqlite/sqlite_for_team.py), and learn more about [session storage](https://docs.agno.com/database/session-storage) and [SingleStore](https://docs.agno.com/database/providers/singlestore/overview) in the documentation.
