Skip to content

fix: make 'chat has no workspace agent' error actually helpful#23971

Merged
johnstcn merged 2 commits intomainfrom
cian/fix-chat-no-agent-error-message
Apr 2, 2026
Merged

fix: make 'chat has no workspace agent' error actually helpful#23971
johnstcn merged 2 commits intomainfrom
cian/fix-chat-no-agent-error-message

Conversation

@johnstcn
Copy link
Copy Markdown
Member

@johnstcn johnstcn commented Apr 2, 2026

  • Change errChatHasNoWorkspaceAgent message 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"
  • Update test assertions to match the new message substring
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.

🤖 Written by a Coder Agent. Will be reviewed by a human.

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.
Copy link
Copy Markdown
Member Author

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ready for review

@johnstcn johnstcn marked this pull request as ready for review April 2, 2026 12:08
Copilot AI review requested due to automatic review settings April 2, 2026 12:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 errChatHasNoWorkspaceAgent error 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.

)

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")
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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.")

Copilot uses AI. Check for mistakes.
)

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")
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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")

Copilot uses AI. Check for mistakes.
@DanielleMaywood
Copy link
Copy Markdown
Contributor

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 "start_workspace if you have one or create_workspace if you don't".

We should say "start_workspace to start the attached workspace" only if there is an attached one and "create_workspace to create a workspace" if there isn't one.

@johnstcn
Copy link
Copy Markdown
Member Author

johnstcn commented Apr 2, 2026

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 "start_workspace if you have one or create_workspace if you don't".

We should say "start_workspace to start the attached workspace" only if there is an attached one and "create_workspace to create a workspace" if there isn't one.

🧠

- 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.
Copy link
Copy Markdown
Member Author

johnstcn commented Apr 2, 2026

🤖 Good call. Pushed 376a3b8 which splits the messages:

  • Workspace exists, stopped (errChatHasNoWorkspaceAgent): "workspace has no running agent: the workspace is likely stopped. Use the start_workspace tool to start it"
  • No workspace attached (two inline errors): "no workspace is associated with this chat. Use the create_workspace tool to create one"

The agent now gets exactly one action to take, not a menu.

@johnstcn johnstcn merged commit 2ebc076 into main Apr 2, 2026
44 of 47 checks passed
@johnstcn johnstcn deleted the cian/fix-chat-no-agent-error-message branch April 2, 2026 13:18
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants