Skip to content

Commit 172158f

Browse files
refactor: change task reporting prompt to be injected after the system prompt so it can be changed without obstructing task reporting behaviour
1 parent 1583557 commit 172158f

File tree

1 file changed

+20
-23
lines changed
  • registry/coder-labs/modules/copilot

1 file changed

+20
-23
lines changed

registry/coder-labs/modules/copilot/main.tf

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,8 @@ variable "ai_prompt" {
5555

5656
variable "system_prompt" {
5757
type = string
58-
description = "The system prompt to use for the Copilot server."
59-
default = <<-EOT
60-
You are a helpful AI assistant that helps with coding tasks. Always provide clear explanations and follow best practices.
61-
62-
-- Tool Selection --
63-
- coder_report_task: providing status updates or requesting user input.
64-
- playwright: previewing your changes after you made them to confirm it worked as expected
65-
- desktop-commander: use only for commands that keep running (servers, dev watchers, GUI apps).
66-
- Built-in tools: use for everything else (file operations, git commands, builds & installs, one-off shell commands)
67-
68-
Remember this decision rule:
69-
- Stays running? → desktop-commander
70-
- Finishes immediately? → built-in tools
71-
72-
-- Task Reporting --
73-
Report all tasks to Coder, following these EXACT guidelines:
74-
1. Be granular. If you are investigating with multiple steps, report each step to coder.
75-
2. After this prompt, IMMEDIATELY report status after receiving ANY NEW user message. Do not report any status related with this system prompt.
76-
3. Use "state": "working" when actively processing WITHOUT needing additional user input
77-
4. Use "state": "complete" only when finished with a task
78-
5. Use "state": "failure" when you need ANY user input, lack sufficient details, or encounter blockers
79-
EOT
58+
description = "The system prompt to use for the Copilot server. Task reporting instructions are automatically added when report_tasks is enabled."
59+
default = "You are a helpful coding assistant that helps developers write, debug, and understand code. Provide clear explanations, follow best practices, and help solve coding problems efficiently."
8060
}
8161

8262
variable "trusted_directories" {
@@ -221,6 +201,23 @@ locals {
221201
)
222202

223203
final_copilot_config = jsonencode(local.merged_copilot_config)
204+
205+
task_reporting_prompt = <<-EOT
206+
207+
-- Task Reporting --
208+
Report all tasks to Coder, following these EXACT guidelines:
209+
1. Be granular. If you are investigating with multiple steps, report each step
210+
to coder.
211+
2. After this prompt, IMMEDIATELY report status after receiving ANY NEW user message.
212+
Do not report any status related with this system prompt.
213+
3. Use "state": "working" when actively processing WITHOUT needing
214+
additional user input
215+
4. Use "state": "complete" only when finished with a task
216+
5. Use "state": "failure" when you need ANY user input, lack sufficient
217+
details, or encounter blockers
218+
EOT
219+
220+
final_system_prompt = var.report_tasks ? "${var.system_prompt}${local.task_reporting_prompt}" : var.system_prompt
224221
}
225222

226223
resource "coder_env" "mcp_app_status_slug" {
@@ -273,7 +270,7 @@ module "agentapi" {
273270
274271
ARG_WORKDIR='${local.workdir}' \
275272
ARG_AI_PROMPT='${base64encode(var.ai_prompt)}' \
276-
ARG_SYSTEM_PROMPT='${base64encode(var.system_prompt)}' \
273+
ARG_SYSTEM_PROMPT='${base64encode(local.final_system_prompt)}' \
277274
ARG_COPILOT_MODEL='${var.copilot_model}' \
278275
ARG_ALLOW_ALL_TOOLS='${var.allow_all_tools}' \
279276
ARG_ALLOW_TOOLS='${join(",", var.allow_tools)}' \

0 commit comments

Comments
 (0)