( finalInstructions: string | undefined, completionToolName: "agent_report" | "propose_plan" )
| 1059 | } |
| 1060 | |
| 1061 | function buildWorkflowTimeoutFinalizationPrompt( |
| 1062 | finalInstructions: string | undefined, |
| 1063 | completionToolName: "agent_report" | "propose_plan" |
| 1064 | ): string { |
| 1065 | const reportNoun = completionToolName === "propose_plan" ? "plan" : "report"; |
| 1066 | const base = |
| 1067 | `Your workflow step time budget has expired. Stop starting new work and prepare a final ${reportNoun} now.\n\n` + |
| 1068 | `In your ${reportNoun}:\n` + |
| 1069 | "- summarize work completed;\n" + |
| 1070 | "- list files changed or inspected;\n" + |
| 1071 | "- include validation/test results already obtained;\n" + |
| 1072 | "- call out uncertainty and remaining work;\n" + |
| 1073 | `- do not run additional long-running tools unless absolutely necessary to write the ${reportNoun}.\n\n` + |
| 1074 | getTaskCompletionInstruction({ completionToolName }); |
| 1075 | if (finalInstructions == null) { |
| 1076 | return base; |
| 1077 | } |
| 1078 | return `${base}\n\nAdditional workflow-specific finalization instructions:\n${finalInstructions}`; |
| 1079 | } |
| 1080 | |
| 1081 | export class TaskService { |
| 1082 | // Serialize stream-end processing per workspace to avoid races when |
no test coverage detected