MCPcopy Index your code
hub / github.com/coder/mux / buildCompletionToolRecoveryMessage

Method buildCompletionToolRecoveryMessage

src/node/services/taskService.ts:7376–7404  ·  view source on GitHub ↗
(
    completionToolName: "agent_report" | "propose_plan",
    options?: {
      reason?: "startup" | "stream_end" | "error";
      error?: Pick<ErrorEvent, "error" | "errorType">;
    }
  )

Source from the content-addressed store, hash-verified

7374 }
7375
7376 private buildCompletionToolRecoveryMessage(
7377 completionToolName: "agent_report" | "propose_plan",
7378 options?: {
7379 reason?: "startup" | "stream_end" | "error";
7380 error?: Pick<ErrorEvent, "error" | "errorType">;
7381 }
7382 ): string {
7383 const completionToolLabel =
7384 completionToolName === "propose_plan" ? "propose_plan" : "agent_report";
7385 const completionInstruction = getTaskCompletionInstruction({ completionToolName });
7386 const noExtraWorkInstruction =
7387 completionToolName === "propose_plan"
7388 ? "Do not continue planning or call other tools."
7389 : "Do not continue investigating or call other tools.";
7390
7391 switch (options?.reason) {
7392 case "startup":
7393 return `This task is awaiting its final ${completionToolLabel}. ${noExtraWorkInstruction} ${completionInstruction}`;
7394 case "error": {
7395 const errorType = options.error?.errorType
7396 ? ` (last error: ${options.error.errorType})`
7397 : "";
7398 return `The previous ${completionToolLabel} attempt failed${errorType}. ${noExtraWorkInstruction} ${completionInstruction}`;
7399 }
7400 case "stream_end":
7401 default:
7402 return `Your stream ended without calling ${completionToolLabel}. ${noExtraWorkInstruction} ${completionInstruction}`;
7403 }
7404 }
7405
7406 private async promptTaskForRequiredCompletionTool(
7407 workspaceId: string,

Calls 1

Tested by

no test coverage detected