mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: improve remote mcp workspace and file prompts (#20475)
I have been experimenting (via blink) and these seem to have made the LLM behave more intelligently and consistently when it comes to creating workspaces and manipulating files. Partially addresses https://github.com/coder/internal/issues/1047
This commit is contained in:
@@ -53,8 +53,16 @@ If the command times out, all output captured up to that point is returned with
|
||||
For background commands (background: true), output is captured until the timeout is reached, then the command
|
||||
continues running in the background. The captured output is returned as the result.
|
||||
|
||||
For file operations (list, write, edit), always prefer the dedicated file tools.
|
||||
Do not use bash commands (ls, cat, echo, heredoc, etc.) to list, write, or read
|
||||
files when the file tools are available. The bash tool should be used for:
|
||||
|
||||
- Running commands and scripts
|
||||
- Installing packages
|
||||
- Starting services
|
||||
- Executing programs
|
||||
|
||||
Examples:
|
||||
- workspace: "my-workspace", command: "ls -la"
|
||||
- workspace: "john/dev-env", command: "git status", timeout_ms: 30000
|
||||
- workspace: "my-workspace", command: "npm run dev", background: true, timeout_ms: 10000
|
||||
- workspace: "my-workspace.main", command: "docker ps"`,
|
||||
|
||||
@@ -353,6 +353,18 @@ var CreateWorkspace = Tool[CreateWorkspaceArgs, codersdk.Workspace]{
|
||||
If a user is asking to "test a template", they are typically referring
|
||||
to creating a workspace from a template to ensure the infrastructure
|
||||
is provisioned correctly and the agent can connect to the control plane.
|
||||
|
||||
Before creating a workspace, always confirm the template choice with the user by:
|
||||
|
||||
1. Listing the available templates that match their request.
|
||||
2. Recommending the most relevant option.
|
||||
2. Asking the user to confirm which template to use.
|
||||
|
||||
It is important to not create a workspace without confirming the template
|
||||
choice with the user.
|
||||
|
||||
After creating a workspace, watch the build logs and wait for the workspace to
|
||||
be ready before trying to use or connect to the workspace.
|
||||
`,
|
||||
Schema: aisdk.Schema{
|
||||
Properties: map[string]any{
|
||||
@@ -530,8 +542,13 @@ type CreateWorkspaceBuildArgs struct {
|
||||
|
||||
var CreateWorkspaceBuild = Tool[CreateWorkspaceBuildArgs, codersdk.WorkspaceBuild]{
|
||||
Tool: aisdk.Tool{
|
||||
Name: ToolNameCreateWorkspaceBuild,
|
||||
Description: "Create a new workspace build for an existing workspace. Use this to start, stop, or delete.",
|
||||
Name: ToolNameCreateWorkspaceBuild,
|
||||
Description: `Create a new workspace build for an existing workspace. Use this to start, stop, or delete.
|
||||
|
||||
After creating a workspace build, watch the build logs and wait for the
|
||||
workspace build to complete before trying to start another build or use or
|
||||
connect to the workspace.
|
||||
`,
|
||||
Schema: aisdk.Schema{
|
||||
Properties: map[string]any{
|
||||
"workspace_id": map[string]any{
|
||||
@@ -1531,8 +1548,20 @@ type WorkspaceWriteFileArgs struct {
|
||||
|
||||
var WorkspaceWriteFile = Tool[WorkspaceWriteFileArgs, codersdk.Response]{
|
||||
Tool: aisdk.Tool{
|
||||
Name: ToolNameWorkspaceWriteFile,
|
||||
Description: `Write a file in a workspace.`,
|
||||
Name: ToolNameWorkspaceWriteFile,
|
||||
Description: `Write a file in a workspace.
|
||||
|
||||
If a file write fails due to syntax errors or encoding issues, do NOT switch
|
||||
to using bash commands as a workaround. Instead:
|
||||
|
||||
1. Read the error message carefully to identify the issue
|
||||
2. Fix the content encoding/syntax
|
||||
3. Retry with this tool
|
||||
|
||||
The content parameter expects base64-encoded bytes. Ensure your source content
|
||||
is correct before encoding it. If you encounter errors, decode and verify the
|
||||
content you are trying to write, then re-encode it properly.
|
||||
`,
|
||||
Schema: aisdk.Schema{
|
||||
Properties: map[string]any{
|
||||
"workspace": map[string]any{
|
||||
|
||||
Reference in New Issue
Block a user