Skip to content

feat(coderd): accept parameters in start_workspace tool#24434

Merged
ethanndickson merged 4 commits intomainfrom
workspace-start-2ayk-2
Apr 21, 2026
Merged

feat(coderd): accept parameters in start_workspace tool#24434
ethanndickson merged 4 commits intomainfrom
workspace-start-2ayk-2

Conversation

@ethanndickson
Copy link
Copy Markdown
Member

@ethanndickson ethanndickson commented Apr 16, 2026

When the chat start_workspace tool triggers an active-version upgrade that introduces new required parameters, the build fails with a parameter validation error. Previously this returned a message telling the user to update from the UI — a dead end for the model.

This PR lets the model recover inside the chat by:

  1. Accepting an optional parameters map on start_workspace (same schema as create_workspace), forwarded as RichParameterValues.
  2. Returning structured JSON error responses that preserve validation details and the workspace's template_id, so the model can call read_template to discover what changed.
  3. Replacing the UI-only guidance in exp_chats.go with model-actionable retry instructions.

The expected model flow on an active-version parameter failure is now:

start_workspace → fails (structured error with template_id + validations)
read_template   → discovers new required parameters
start_workspace → retries with parameters map → workspace starts
image

Base automatically changed from workspace-start-2ayk to main April 16, 2026 14:16
@ethanndickson ethanndickson force-pushed the workspace-start-2ayk-2 branch from 13da2f0 to feda075 Compare April 16, 2026 14:21
@ethanndickson ethanndickson marked this pull request as ready for review April 16, 2026 14:22
Copy link
Copy Markdown
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

The approach is well-reasoned. Pariston investigated four framings of the problem (missing capability, unhelpful format, eager auto-upgrade, missing orchestration) and concluded the chosen solution is the simplest one that works. The parameter forwarding mirrors create_workspace exactly, ElementsMatch correctly handles map iteration order, and the IsError: false + structured JSON pattern is consistent with the existing buildToolResponse convention. The ClientType backfill on two straggler tests is a nice cleanup.

Severity count: 2 P2, 2 P3, 1 P4, 3 Nit.

The main concern is DEREM-3: template_id is injected into every Responder error, not just parameter validation failures. Five reviewers converged on this independently. The fix is a one-line scope guard.

The two CI title failures are from the scope coderd/x/chatd/chattool not covering coderd/exp_chats.go. P2 [DEREM-6] Use coderd or omit the scope.

"This test proves the tool layer correctly unpacks a structured Responder error into JSON. It does not prove the error gets structured correctly in the first place." -- Bisky

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/chattool/startworkspace.go Outdated
Comment thread coderd/x/chatd/chattool/chattool.go
Comment thread coderd/exp_chats.go Outdated
Comment thread coderd/x/chatd/chattool/startworkspace_test.go
Comment thread coderd/x/chatd/chattool/startworkspace.go Outdated
Comment thread coderd/exp_chats.go Outdated
@ethanndickson ethanndickson changed the title feat(coderd/x/chatd/chattool): accept parameters in start_workspace tool feat(coderd): accept parameters in start_workspace tool Apr 17, 2026
@ethanndickson
Copy link
Copy Markdown
Member Author

Also addressed DEREM-6 by retitling the PR to feat(coderd): accept parameters in start_workspace tool, so the scope now matches the full diff.

The start_workspace chat tool now accepts an optional parameters map,
matching the existing create_workspace pattern. When an active-version
upgrade introduces new required parameters, the tool returns structured
JSON with the error details, validation failures, and template_id so
the model can call read_template, discover what changed, and retry
start_workspace with the correct values.

Changes:
- Add startWorkspaceArgs with Parameters map[string]string to
  start_workspace, forwarded as RichParameterValues.
- Add responseErrorResult helper in chattool.go to convert
  codersdk.Response into structured tool JSON (preserving
  validations that IsError content would drop).
- Update exp_chats.go to replace the UI-only guidance message
  with model-actionable retry instructions and preserve the
  original responder's detail/validations.
- Add PassesParameters and update ManualUpdateRequired tests.
@ethanndickson ethanndickson force-pushed the workspace-start-2ayk-2 branch from fe24ae4 to 1e75493 Compare April 17, 2026 05:21
Copy link
Copy Markdown
Collaborator

@ibetitsmike ibetitsmike left a comment

Choose a reason for hiding this comment

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

worth making sure all edge cases are covered - especially if the agent hallucinates param values

Comment thread coderd/x/chatd/chattool/chattool.go
The retry instructions for start_workspace's manual-update-required path
told the model to read_template and retry with parameters, but didn't
guide it on what to do when the right value for a parameter isn't
obvious from its description or defaults. Add one sentence telling the
model to ask the user in that case rather than guessing.
…es in start_workspace

"Optionally provide parameter values" told the model it *can* pass
parameters but not *when* to. Rewrite to 'only if necessary or
explicitly requested by the user' so the model doesn't preemptively
call read_template and pass params on every start.
@ethanndickson ethanndickson merged commit 1203f62 into main Apr 21, 2026
26 checks passed
@ethanndickson ethanndickson deleted the workspace-start-2ayk-2 branch April 21, 2026 01:36
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 21, 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