Skip to content

Fix 'no thread found' error when restoring agent thread on workspace open#49045

Merged
rtfeldman merged 3 commits intomainfrom
AI-19/fix-empty-thread-restore
Feb 13, 2026
Merged

Fix 'no thread found' error when restoring agent thread on workspace open#49045
rtfeldman merged 3 commits intomainfrom
AI-19/fix-empty-thread-restore

Conversation

@rtfeldman
Copy link
Contributor

@rtfeldman rtfeldman commented Feb 12, 2026

When the multi-workspace thread restoration feature serializes the active thread's session ID, it includes empty threads that were never persisted to the database (because NativeAgent::save_thread skips empty threads). On restart, AgentPanel::load() tries to restore this thread by calling load_agent_thread(), which queries the SQLite DB. Since the empty thread was never saved, the query returns None, which becomes the error: "no thread found with ID: SessionId(...)". This shows as "Error Loading Zed Agent" / "Failed to Launch" in the UI.

Fix:
Before attempting to restore a serialized thread on panel load, query the DB to verify the thread actually exists. If it doesn't, log an error and skip restoration (the panel falls back to creating a new thread as normal).

Closes AI-19

Release Notes:

  • Fixed an "Error Loading Zed Agent" error that could appear when opening a workspace where the previous agent thread was empty.

…space open

Don't serialize empty threads that won't be in the DB, and validate
thread exists in the DB before attempting to restore it on load.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 12, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 12, 2026
When the agent panel serializes the last active thread's session ID and
that thread doesn't exist in the database on restart (e.g. empty thread
that was never persisted), the panel would show 'Error Loading Zed Agent'
/ 'Failed to Launch'.

Now AgentPanel::load() queries the database to verify the thread exists
before attempting restoration. If the thread is missing, it logs an error
and falls back to the default behavior (creating a new thread).
@rtfeldman rtfeldman marked this pull request as ready for review February 13, 2026 15:32
@rtfeldman rtfeldman merged commit 46b986c into main Feb 13, 2026
27 checks passed
@rtfeldman rtfeldman deleted the AI-19/fix-empty-thread-restore branch February 13, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant