MCPcopy
hub / github.com/coder/mux / finalizeAgentTaskReport

Method finalizeAgentTaskReport

src/node/services/taskService.ts:9371–9613  ·  view source on GitHub ↗
(
    childWorkspaceId: string,
    childEntry: { projectPath: string; workspace: WorkspaceConfigEntry } | null | undefined,
    rawReportArgs: {
      reportMarkdown: string;
      title?: string;
      structuredOutput?: unknown;
      planFilePath?: string;
    }
  )

Source from the content-addressed store, hash-verified

9369 }
9370
9371 private async finalizeAgentTaskReport(
9372 childWorkspaceId: string,
9373 childEntry: { projectPath: string; workspace: WorkspaceConfigEntry } | null | undefined,
9374 rawReportArgs: {
9375 reportMarkdown: string;
9376 title?: string;
9377 structuredOutput?: unknown;
9378 planFilePath?: string;
9379 }
9380 ): Promise<AgentReportFinalizationResult> {
9381 this.markTaskForegroundRelevant(childWorkspaceId);
9382
9383 assert(
9384 childWorkspaceId.length > 0,
9385 "finalizeAgentTaskReport: childWorkspaceId must be non-empty"
9386 );
9387 assert(
9388 typeof rawReportArgs.reportMarkdown === "string" && rawReportArgs.reportMarkdown.length > 0,
9389 "finalizeAgentTaskReport: reportMarkdown must be non-empty"
9390 );
9391
9392 const cfgBeforeReport = this.config.loadConfigOrDefault();
9393 const latestEntryBeforeReport =
9394 findWorkspaceEntry(cfgBeforeReport, childWorkspaceId) ?? childEntry;
9395 const statusBefore = latestEntryBeforeReport?.workspace.taskStatus;
9396 if (statusBefore === "reported") {
9397 return { finalized: true };
9398 }
9399
9400 const allowLegacyInvalidOutputSchema = await this.shouldAllowLegacyInvalidWorkflowOutputSchema(
9401 childWorkspaceId,
9402 latestEntryBeforeReport
9403 );
9404 const reportArgs = normalizeWorkflowAgentReportArgsForWorkflowTask(
9405 latestEntryBeforeReport?.workspace.workflowTask,
9406 rawReportArgs
9407 );
9408 const validationMessage = validateWorkflowAgentReportStructuredOutput({
9409 workflowTask: latestEntryBeforeReport?.workspace.workflowTask,
9410 reportArgs,
9411 allowLegacyInvalidOutputSchema,
9412 });
9413 if (validationMessage != null) {
9414 log.warn("Rejecting invalid workflow agent_report structured output", {
9415 childWorkspaceId,
9416 workflowTask: latestEntryBeforeReport?.workspace.workflowTask,
9417 message: validationMessage,
9418 });
9419 if (statusBefore === "interrupted") {
9420 return {
9421 finalized: false,
9422 reason: "terminal_interrupted",
9423 message: validationMessage,
9424 };
9425 }
9426
9427 await this.editWorkspaceEntry(
9428 childWorkspaceId,

Tested by

no test coverage detected