fix: make 'chat has no workspace agent' error actually helpful#23971
fix: make 'chat has no workspace agent' error actually helpful#23971
Conversation
The old error message 'chat has no workspace agent' was about as useful as a chocolate teapot. LLM agents would see this cryptic message on every tool call when a workspace was stopped and spiral into confusion, concluding there must be a shell hook intercepting commands containing the word 'chat'. The new message explains what happened and what to do about it: use start_workspace or create_workspace.
There was a problem hiding this comment.
Pull request overview
Updates the sentinel workspace-unavailable error text so tool failures provide actionable remediation when a chat’s associated workspace has no runnable agent (commonly when the workspace is stopped).
Changes:
- Replaced the
errChatHasNoWorkspaceAgenterror string with a more instructive message. - Updated chatd tests to assert against the new message substring.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
coderd/x/chatd/chatd.go |
Updates the sentinel error message presented when no workspace agent is available. |
coderd/x/chatd/chatd_test.go |
Adjusts assertions to match the new error message substring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
coderd/x/chatd/chatd.go
Outdated
| ) | ||
|
|
||
| var errChatHasNoWorkspaceAgent = xerrors.New("chat has no workspace agent") | ||
| var errChatHasNoWorkspaceAgent = xerrors.New("workspace has no running agent: the workspace may be stopped. Use the start_workspace tool to start it, or create_workspace to create a new one") |
There was a problem hiding this comment.
The new guidance suggests using create_workspace to create a new workspace when there is no running agent. In the stopped-workspace scenario that triggers this sentinel (no agents in the latest build), create_workspace is idempotent and will return the existing workspace with a message to use start_workspace, not create a new one—so this advice is misleading. Consider rewording to primarily recommend start_workspace, and only mention create_workspace for the separate case where the chat has no workspace (or the workspace was deleted).
| var errChatHasNoWorkspaceAgent = xerrors.New("workspace has no running agent: the workspace may be stopped. Use the start_workspace tool to start it, or create_workspace to create a new one") | |
| var errChatHasNoWorkspaceAgent = xerrors.New("workspace has no running agent: the workspace may be stopped. Use the start_workspace tool to start the existing workspace. If this chat has no workspace or its workspace was deleted, use the create_workspace tool to create a new one.") |
coderd/x/chatd/chatd.go
Outdated
| ) | ||
|
|
||
| var errChatHasNoWorkspaceAgent = xerrors.New("chat has no workspace agent") | ||
| var errChatHasNoWorkspaceAgent = xerrors.New("workspace has no running agent: the workspace may be stopped. Use the start_workspace tool to start it, or create_workspace to create a new one") |
There was a problem hiding this comment.
Error strings in this package are consistently lowercase and avoid sentence punctuation (e.g., "chat has no workspace" at chatd.go:347 and "workspace agent connector is not configured" at chatd.go:515). This new sentinel message starts a new sentence with a capital letter and includes a period, which breaks that established style. Consider keeping it actionable but formatted like the surrounding errors (all-lowercase, no trailing punctuation).
| var errChatHasNoWorkspaceAgent = xerrors.New("workspace has no running agent: the workspace may be stopped. Use the start_workspace tool to start it, or create_workspace to create a new one") | |
| var errChatHasNoWorkspaceAgent = xerrors.New("workspace has no running agent: the workspace may be stopped; use the start_workspace tool to start it or create_workspace to create a new one") |
|
Do we know at the point we're sending the agent the message if the chat has an associated workspace? If so, we should only tell it what it should do. We shouldn't tell the agent " We should say " |
🧠 |
- Workspace exists but stopped (no running agent): only suggest start_workspace - No workspace attached to chat: only suggest create_workspace Per Danielle's review: we know whether a workspace exists, so we should tell the agent exactly what to do instead of hedging.
|
🤖 Good call. Pushed 376a3b8 which splits the messages:
The agent now gets exactly one action to take, not a menu. |
errChatHasNoWorkspaceAgentmessage from cryptic"chat has no workspace agent"to actionable"workspace has no running agent: the workspace may be stopped. Use the start_workspace tool to start it, or create_workspace to create a new one"Context
When a workspace is stopped, every tool that needs a workspace connection returns this error to the LLM agent. The old message caused agents to spiral into confusion — one concluded there must be a shell hook intercepting commands containing the word "chat".
The sentinel error identity is preserved (
xerrors.Is()checks pointer equality), so all 5 internal control-flow sites that match on this error are unaffected.