chore: backport Coder Agents system-instruction improvements to 2.37 (#29237, #29281, #29401, #29579) - #29654
Conversation
) The old message, "no workspace is associated with this chat," read like a general chat error and did not make clear that the *tool call itself* needed a workspace. Smaller/local models tend to misread vague tool errors as a hard stop, so the new wording says directly what is missing and what to do: "this tool requires a workspace and this chat does not have one." Fixes CODAGT-1029 > Generated by Coder Agents on behalf of @bpmct. (cherry picked from commit 439f4fd)
… retrying an exclusive tool (#29281) When the model batches `advisor` (an exclusive tool) with other tool calls, every call in the batch is rejected and the `advisor` result only says to retry with `advisor` alone. That nudges the model toward re-calling `advisor` immediately, even when the sibling calls were there to gather context for it. Extend the message so the model is told to run the other tools first when it still needs their output, then retry with only the exclusive tool call. Generated by Coder Agents on behalf of @ibetitsmike. (cherry picked from commit 0362e53)
(cherry picked from commit eb800dc)
Chatd's guidance discouraged workspace creation even when the chat lacked the tools or context needed to finish a request. Make a suitable workspace the fallback when missing tools, skills, MCPs, or context block progress, while preferring existing capabilities when sufficient. Align the system prompt, workspace awareness, planning guidance, tool description, regression tests, and user documentation. Preserve template-selection guardrails and delegated-agent restrictions. **Open review finding:** workspace readiness can precede initial MCP/context discovery. The wording now acknowledges this limitation; a runtime synchronization fix is pending a scope decision. <details> <summary>Implementation and verification context</summary> - Coding requests authorize necessary workspace setup without a separate workspace request; self-contained examples remain workspace-free when existing capabilities suffice. - Detached root chats create a workspace; attached stopped workspaces use start_workspace. Persisted awareness describes the initial state rather than claiming the chat remains detached. - Delegated chats report workspace needs to their parent. Provisioning does not unlock workspace MCP tools in Plan Mode. - Use actually exposed capabilities; do not assume readiness means all skills, MCP tools, and context have loaded, or recreate workspaces to retry discovery. - Prompt, workspace-creation, template-selection, setup-failure, Plan Mode MCP boundary, and API prompt-composition tests pass. The creation E2E now verifies published instructions, skills, and MCP tools appear in request two with no extra user turn; repeated and race runs pass. This does not establish live-model compliance or discovery readiness. - Full make pre-commit passes, including generation, formatting, lint, and the slim build. All CI checks pass on f4f6133 (23 passed, 8 skipped), and Codex reports no major issues on that commit. - Codex review iterations corrected prompt/tool conflicts. The alleged immutable-per-turn tool catalog was disproved by the per-task generation lifecycle. The narrower initial-discovery race remains open: no existing chatd-visible signal distinguishes pending discovery from completed empty or failed discovery. </details> Generated by Coder Agents on behalf of @ibetitsmike. Backport note: the TestCreateWorkspaceTool_EndToEnd rewrite from the original commit is omitted. It depends on DisableWorkspaceAgentContextSync (#28522) and on same-turn workspace-context publication, neither of which is on release/2.37. The 2.37 version of that test still passes with the new guidance; only the workspace-awareness assertions are updated. (cherry picked from commit cc8c766)
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
👋 Hey @ibetitsmike! This PR is targeting the Only bug fixes should be cherry-picked to release branches. If this is a bug fix, please update the PR title to match the conventional commit format: If this is not a bug fix, it likely should not target a release branch. |
Documentation CheckUpdates Needed
The rest of the diff documents itself. The workspace-provisioning behavior change is covered by the backported edits to Note: the same sentence is stale on Automated review via Coder Agents |
Backport of the Coder Agents system-instruction improvements that landed on main since 2.37 branched, so 2.37 chats get the same task, completion, and workspace guidance as main.
Source PRs, cherry-picked with
-xin merge order:fix(coderd/x/chatd): clarify the no-workspace tool error message. Applied as-is.fix(coderd/x/chatd/chatloop): tell the model to gather context before retrying an exclusive tool. Applied as-is.fix(coderd/x/chatd): improve agent task and completion guidance (inspect, act, validate, finish discipline; explore-subagent search discipline). Applied as-is.fix: use workspaces when chat capabilities are insufficient (system prompt, workspace awareness, planning overlay,create_workspacetool description, user docs). Applied with one omission, described below.After these picks
coderd/x/chatd/prompt.go,coderd/x/chatd/instruction_internal_test.go, andcoderd/x/chatd/chattool/createworkspace.goare byte-identical to main.Omitted from #29579: the
TestCreateWorkspaceTool_EndToEndrewrite. It depends onDisableWorkspaceAgentContextSync(#28522) and on same-turn workspace-context publication, neither of which is onrelease/2.37, and without that flag the seeded snapshot races agent discovery. The 2.37 version of the test still passes against the new guidance; only the workspace-awareness assertions inTestCreateChatInsertsWorkspaceAwarenessMessageare updated. The commit message carries the same note.Other chatd commits since the branch point were reviewed and not backported: they are runtime or feature changes (compaction tool definitions, reasoning overrides, SVG attachments, stream timeout, quickgen model routing), not instruction changes.
Validation on this branch:
go test ./coderd/x/chatd/ -run 'TestDefaultSystemPrompt|TestPlanningOverlayPrompt|TestWorkspaceAwareness|TestRenderPlanPathPrompt|TestExploreSubagentOverlayPrompt|TestStoreChatAttachment_NoWorkspace|TestCreateChatInsertsWorkspaceAwarenessMessage|TestCreateWorkspaceTool_EndToEnd': 12 tests pass, including the E2E.go test ./coderd/x/chatd/chattool/ ./coderd/x/chatd/chatloop/ -run 'TestCreateWorkspaceDescription|TestExclusiveToolPolicy': pass.go test ./coderd/ -run TestChatSystemPrompt: pass.markdownlint-cli2on the five touched docs pages: 0 errors.