@rallycry/conveyor-agent 7.2.9 → 7.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  loadConveyorConfig,
6
6
  runSetupCommand,
7
7
  runStartCommand
8
- } from "./chunk-INNHAWJK.js";
8
+ } from "./chunk-JYSWXYG6.js";
9
9
  import "./chunk-C5YAMQJ2.js";
10
10
  import {
11
11
  createServiceLogger
package/dist/index.d.ts CHANGED
@@ -100,9 +100,6 @@ declare class AgentConnection {
100
100
  triggerIdentification(): Promise<{
101
101
  identified: boolean;
102
102
  }>;
103
- requestScaleUp(tier: string, reason?: string): Promise<{
104
- scaled: boolean;
105
- }>;
106
103
  refreshAuthToken(): Promise<boolean>;
107
104
  sendEvent(event: Record<string, unknown>): void;
108
105
  flushEvents(): Promise<void>;
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  runStartCommand,
25
25
  stageAndCommit,
26
26
  updateRemoteToken
27
- } from "./chunk-INNHAWJK.js";
27
+ } from "./chunk-JYSWXYG6.js";
28
28
  import "./chunk-C5YAMQJ2.js";
29
29
  import "./chunk-RRXX6DTB.js";
30
30
 
@@ -102,12 +102,17 @@ function extractJsonBlock(text) {
102
102
  }
103
103
  throw new Error("Could not parse JSON from Claude response");
104
104
  }
105
- function extractGradingResult(text, phase) {
105
+ var VALID_GRADING_PHASES = /* @__PURE__ */ new Set(["planning", "building"]);
106
+ function extractCombinedGradingResult(text) {
106
107
  const parsed = extractJsonBlock(text);
107
- const turnGrades = Array.isArray(parsed.turnGrades) ? parsed.turnGrades.map((tg) => ({ ...tg, phase })) : [];
108
+ const turnGrades = Array.isArray(parsed.turnGrades) ? parsed.turnGrades.map((tg) => ({
109
+ ...tg,
110
+ phase: VALID_GRADING_PHASES.has(tg.phase) ? tg.phase : "building"
111
+ })) : [];
108
112
  const summary = parsed.summary ?? "";
109
- const accuracy = typeof parsed.accuracy === "number" ? parsed.accuracy : null;
110
- return { turnGrades, summary, accuracy };
113
+ const planningAccuracy = typeof parsed.planningAccuracy === "number" ? parsed.planningAccuracy : null;
114
+ const buildingAccuracy = typeof parsed.buildingAccuracy === "number" ? parsed.buildingAccuracy : null;
115
+ return { turnGrades, summary, planningAccuracy, buildingAccuracy };
111
116
  }
112
117
  function extractHumanResult(text) {
113
118
  const parsed = extractJsonBlock(text);
@@ -130,13 +135,12 @@ function extractAnalysisResult(text) {
130
135
  } : null
131
136
  };
132
137
  }
133
- function buildMergedSummary(planningResult, buildingResult, humanResult, analysisResult) {
138
+ function buildMergedSummary(gradingResult, humanResult, analysisResult) {
134
139
  const summaryParts = [];
135
140
  if (analysisResult?.summary) {
136
141
  summaryParts.push(analysisResult.summary);
137
142
  } else {
138
- if (planningResult?.summary) summaryParts.push(`Planning: ${planningResult.summary}`);
139
- if (buildingResult?.summary) summaryParts.push(`Building: ${buildingResult.summary}`);
143
+ if (gradingResult?.summary) summaryParts.push(gradingResult.summary);
140
144
  if (humanResult?.summary) summaryParts.push(`Human: ${humanResult.summary}`);
141
145
  }
142
146
  const macroText = analysisResult?.macroEvaluation ? formatMacroEvaluation(analysisResult.macroEvaluation) : null;
@@ -156,144 +160,46 @@ Human Contributions:
156
160
  ${humanEvalText}`;
157
161
  return summary;
158
162
  }
159
- function mergeStepResults(planningResult, buildingResult, humanResult, analysisResult, planningTraceLength) {
160
- const planGrades = planningResult?.turnGrades ?? [];
161
- const buildGrades = (buildingResult?.turnGrades ?? []).map((tg) => ({
162
- ...tg,
163
- turnIndex: tg.turnIndex + planningTraceLength
164
- }));
163
+ function mergeStepResults(gradingResult, humanResult, analysisResult) {
165
164
  return {
166
- turnGrades: [...planGrades, ...buildGrades],
167
- summary: buildMergedSummary(planningResult, buildingResult, humanResult, analysisResult),
168
- planningAccuracy: planningResult?.accuracy ?? null,
169
- buildingAccuracy: buildingResult?.accuracy ?? null,
165
+ turnGrades: gradingResult?.turnGrades ?? [],
166
+ summary: buildMergedSummary(gradingResult, humanResult, analysisResult),
167
+ planningAccuracy: gradingResult?.planningAccuracy ?? null,
168
+ buildingAccuracy: gradingResult?.buildingAccuracy ?? null,
170
169
  humanAccuracy: humanResult?.humanAccuracy ?? null,
171
170
  humanEvaluations: humanResult?.humanEvaluations ?? [],
172
171
  macroEvaluation: analysisResult?.macroEvaluation ?? null
173
172
  };
174
173
  }
175
174
 
176
- // src/runner/task-audit-trace-slicer.ts
177
- var PLAN_UPDATE_PATTERN = /mcp__conveyor__update_task$/;
178
- var PR_CREATION_PATTERN = /mcp__conveyor__create_pull_request$/;
179
- function eventMatchesTool(event, toolPattern) {
180
- if (event.type === "tool_use" && typeof event.data.tool === "string") {
181
- if (toolPattern.test(event.data.tool)) return true;
182
- }
183
- if (event.type === "turn_end" && Array.isArray(event.data.toolCalls)) {
184
- for (const tc of event.data.toolCalls) {
185
- if (typeof tc.tool === "string" && toolPattern.test(tc.tool)) return true;
186
- }
187
- }
188
- return false;
189
- }
190
- function trimToLastSession(trace) {
191
- let lastManifestIndex = -1;
192
- for (let i = trace.length - 1; i >= 0; i--) {
193
- if (trace[i].type === "session_manifest") {
194
- lastManifestIndex = i;
195
- break;
196
- }
197
- }
198
- if (lastManifestIndex <= 0) return trace;
199
- return trace.slice(lastManifestIndex);
200
- }
201
- function findLastToolCallIndex(trace, toolPattern) {
202
- for (let i = trace.length - 1; i >= 0; i--) {
203
- if (eventMatchesTool(trace[i], toolPattern)) return i;
204
- }
205
- return -1;
206
- }
207
- function sliceTrace(rawTrace) {
208
- const trace = trimToLastSession(rawTrace);
209
- const lastPlanUpdateIndex = findLastToolCallIndex(trace, PLAN_UPDATE_PATTERN);
210
- const lastPrCreationIndex = findLastToolCallIndex(trace, PR_CREATION_PATTERN);
211
- const boundaries = { lastPlanUpdateIndex, lastPrCreationIndex };
212
- if (lastPlanUpdateIndex === -1 && lastPrCreationIndex === -1) {
213
- return { planningTrace: [], buildingTrace: trace, boundaries };
214
- }
215
- if (lastPlanUpdateIndex === -1) {
216
- return {
217
- planningTrace: [],
218
- buildingTrace: lastPrCreationIndex >= 0 ? trace.slice(0, lastPrCreationIndex + 1) : trace,
219
- boundaries
220
- };
221
- }
222
- const planEnd = lastPrCreationIndex >= 0 && lastPlanUpdateIndex > lastPrCreationIndex ? lastPrCreationIndex : lastPlanUpdateIndex;
223
- const planningTrace = trace.slice(0, planEnd + 1);
224
- const buildEnd = lastPrCreationIndex >= 0 ? lastPrCreationIndex + 1 : trace.length;
225
- const buildingTrace = trace.slice(planEnd + 1, buildEnd);
226
- return { planningTrace, buildingTrace, boundaries };
227
- }
228
-
229
175
  // src/runner/task-audit-prompts.ts
230
- var PLANNING_AUDIT_SYSTEM_PROMPT = `You are a chess-style analysis engine grading the PLANNING phase of an AI agent's task execution. You receive only the planning portion of the agent's trace \u2014 from the start through the last plan update. Grade each turn objectively.
176
+ var COMBINED_GRADING_SYSTEM_PROMPT = `You are a chess-style analysis engine performing a holistic audit of an AI agent's full task execution \u2014 from initial planning through final implementation. You receive the complete agent trace covering all phases and sessions. Grade each turn objectively.
231
177
 
232
- ## Grading Scale
178
+ ## Phase Identification
233
179
 
234
- - **Correct** (\u265F): Sound moves toward understanding the task \u2014 reading relevant files, analyzing requirements, logical reasoning about approach, following project patterns
235
- - **Neutral** (\xB7): No significant positive or negative effect \u2014 exploratory reads, minor tangents
236
- - **Blunder** (??): Wasted effort \u2014 reading irrelevant files repeatedly, ignoring requirements, spending many turns without making progress toward a plan
180
+ Identify the boundary between planning and building phases:
181
+ - **Planning phase**: Turns from the start through the last \`update_task\` (plan save) call. Includes reading requirements, exploring code, analyzing dependencies, and formulating the plan.
182
+ - **Building phase**: Turns after the last plan save through PR creation (or end of trace). Includes implementation, testing, and PR creation.
183
+ - If no \`update_task\` call is found, treat all turns as building phase.
237
184
 
238
- ## Specific Blunder Examples
239
- - Reading the same file 5+ times without advancing understanding
240
- - Ignoring explicit task requirements or project conventions visible in the code
241
- - Spending many turns on tangential investigation not related to the task
242
- - Failing to read key files that are obvious from the task description
185
+ You MUST label each turn with \`"phase": "planning"\` or \`"phase": "building"\`.
243
186
 
244
- ## Specific Correct Examples
245
- - Reading context files before implementation
246
- - Analyzing requirements and dependencies systematically
247
- - Identifying relevant code patterns to follow
248
- - Building understanding incrementally
187
+ ## Multi-Session Awareness
249
188
 
250
- ## Output Format
251
-
252
- Output a JSON block:
253
-
254
- \`\`\`json
255
- {
256
- "turnGrades": [
257
- {
258
- "turnIndex": 0,
259
- "grade": "correct",
260
- "reasoning": "Read relevant config files to understand project structure",
261
- "eventType": "tool_use",
262
- "eventSummary": "Read package.json and tsconfig.json"
263
- }
264
- ],
265
- "summary": "Brief 2-3 sentence assessment of planning quality",
266
- "accuracy": 0.85
267
- }
268
- \`\`\`
269
-
270
- **Accuracy Calculation**: accuracy = correct / (correct + blunder). Neutral turns are excluded. Return null if no correct or blunder turns exist.
271
-
272
- IMPORTANT: Do NOT include a "phase" field in turnGrades \u2014 the phase is set programmatically. Only include turnIndex, grade, reasoning, eventType, and eventSummary.`;
273
- var BUILDING_AUDIT_SYSTEM_PROMPT = `You are a chess-style analysis engine grading the BUILDING phase of an AI agent's task execution. You receive only the building portion of the agent's trace \u2014 from after the plan was finalized through pull request creation. Grade each turn objectively.
189
+ The trace may contain multiple agent sessions (indicated by \`session_manifest\` events). Grade ALL sessions \u2014 earlier sessions often contain valuable planning work or reflect restart patterns worth evaluating. If an earlier session was abandoned, grade its turns based on quality (exploration reads may be neutral, repeated failures may be blunders).
274
190
 
275
191
  ## Grading Scale
276
192
 
193
+ ### Planning Turns
194
+ - **Correct** (\u265F): Sound moves toward understanding the task \u2014 reading relevant files, analyzing requirements, logical reasoning about approach, following project patterns
195
+ - **Neutral** (\xB7): No significant positive or negative effect \u2014 exploratory reads, minor tangents
196
+ - **Blunder** (??): Wasted effort \u2014 reading irrelevant files repeatedly, ignoring requirements, spending many turns without making progress toward a plan
197
+
198
+ ### Building Turns
277
199
  - **Correct** (\u265F): Sound implementation moves \u2014 proper edits, running tests, fixing errors, following plan steps, adapting to feedback
278
200
  - **Neutral** (\xB7): No significant positive or negative effect \u2014 exploratory reads during implementation, minor tangents
279
201
  - **Blunder** (??): Wasted effort \u2014 incorrect edits immediately reverted, repeated failures without adapting, ignoring the plan, using wrong APIs despite visible patterns
280
202
 
281
- ## Specific Blunder Examples
282
- - Making edits that are immediately reverted or overwritten
283
- - Ignoring explicit plan steps or user corrections
284
- - Repeated failed tool calls (isError: true) without changing approach
285
- - Using wrong APIs despite project patterns visible in the trace
286
- - Spending many turns on tangential work not in the plan
287
-
288
- **Multi-session awareness**: If the trace begins with exploration (reads/greps) before any edits, and there is no prior planning trace, these likely represent the agent re-orienting in a new session. Grade initial orientation reads as neutral unless clearly wasteful (e.g., reading the same file 5+ times).
289
-
290
- ## Specific Correct Examples
291
- - Following plan steps in logical sequence
292
- - Proper error handling and recovery after tool failures
293
- - Adapting approach based on test results or errors
294
- - Efficient tool usage with clear purpose
295
- - Running tests to verify changes
296
-
297
203
  ## Output Format
298
204
 
299
205
  Output a JSON block:
@@ -303,20 +209,22 @@ Output a JSON block:
303
209
  "turnGrades": [
304
210
  {
305
211
  "turnIndex": 0,
212
+ "phase": "planning",
306
213
  "grade": "correct",
307
- "reasoning": "Implemented the required changes following the plan",
214
+ "reasoning": "Read relevant config files to understand project structure",
308
215
  "eventType": "tool_use",
309
- "eventSummary": "Edit src/component.tsx"
216
+ "eventSummary": "Read package.json and tsconfig.json"
310
217
  }
311
218
  ],
312
- "summary": "Brief 2-3 sentence assessment of building quality",
313
- "accuracy": 0.72
219
+ "summary": "Brief 2-3 sentence holistic assessment of the full execution",
220
+ "planningAccuracy": 0.85,
221
+ "buildingAccuracy": 0.72
314
222
  }
315
223
  \`\`\`
316
224
 
317
- **Accuracy Calculation**: accuracy = correct / (correct + blunder). Neutral turns are excluded. Return null if no correct or blunder turns exist.
225
+ **Accuracy Calculation**: For each phase separately: accuracy = correct / (correct + blunder). Neutral turns are excluded. Return null for a phase if it has no correct or blunder turns.
318
226
 
319
- IMPORTANT: Turn indices are 0-based relative to the trace slice provided. Do NOT include a "phase" field \u2014 the phase is set programmatically. Only include turnIndex, grade, reasoning, eventType, and eventSummary.`;
227
+ Turn indices are 0-based relative to the full trace provided. Every turn grade MUST include the phase field.`;
320
228
  var HUMAN_AUDIT_SYSTEM_PROMPT = `You are evaluating human contributions to an AI agent's task execution. For each human message, assess whether it helped, hindered, or had no effect on the agent's work.
321
229
 
322
230
  ## Rating Scale
@@ -427,27 +335,19 @@ ${task.agentInstructions}
427
335
  function buildMultiSessionNote(task) {
428
336
  const count = task.sessionInfo?.sessionCount;
429
337
  if (!count || count <= 1) return null;
430
- return `> **Note:** This task had ${count} total agent sessions. The trace below represents only the final session. Prior sessions were filtered out.
338
+ return `> **Note:** This task had ${count} total agent sessions. All sessions are included in the trace below.
431
339
  `;
432
340
  }
433
- function buildPlanningAuditPrompt(task, planningTrace) {
434
- const parts = [`# Planning Audit: ${task.taskTitle}
435
- `];
436
- const sessionNote = buildMultiSessionNote(task);
437
- if (sessionNote) parts.push(sessionNote);
438
- parts.push(buildTaskContextSection(task));
439
- parts.push(buildTraceSection(planningTrace));
440
- parts.push("Grade each turn above, then output the structured JSON result.");
441
- return parts.join("\n");
442
- }
443
- function buildBuildingAuditPrompt(task, buildingTrace) {
444
- const parts = [`# Building Audit: ${task.taskTitle}
341
+ function buildCombinedGradingPrompt(task) {
342
+ const parts = [`# Full Workflow Audit: ${task.taskTitle}
445
343
  `];
446
344
  const sessionNote = buildMultiSessionNote(task);
447
345
  if (sessionNote) parts.push(sessionNote);
448
346
  parts.push(buildTaskContextSection(task));
449
- parts.push(buildTraceSection(buildingTrace));
450
- parts.push("Grade each turn above, then output the structured JSON result.");
347
+ parts.push(buildTraceSection(task.agentTrace));
348
+ parts.push(
349
+ "Grade each turn above with its phase (planning or building), then output the structured JSON result."
350
+ );
451
351
  return parts.join("\n");
452
352
  }
453
353
  function buildHumanAuditPrompt(task) {
@@ -471,21 +371,20 @@ ${task.taskPlan}
471
371
  parts.push("Evaluate each human message above, then output the structured JSON result.");
472
372
  return parts.join("\n");
473
373
  }
474
- function buildGradingResultSection(label, result) {
475
- const grades = result.turnGrades;
374
+ function buildPhaseResultSection(label, grades, accuracy, summary) {
476
375
  const correct = grades.filter((g) => g.grade === "correct").length;
477
376
  const neutral = grades.filter((g) => g.grade === "neutral").length;
478
377
  const blunder = grades.filter((g) => g.grade === "blunder").length;
479
- const accuracy = result.accuracy === null ? "N/A" : result.accuracy.toFixed(2);
378
+ const accuracyStr = accuracy === null ? "N/A" : accuracy.toFixed(2);
480
379
  return [
481
380
  `## ${label} Phase Results`,
482
- `- Summary: ${result.summary}`,
483
- `- Accuracy: ${accuracy}`,
381
+ `- Summary: ${summary}`,
382
+ `- Accuracy: ${accuracyStr}`,
484
383
  `- ${grades.length} turns: ${correct} correct, ${neutral} neutral, ${blunder} blunders`,
485
384
  ""
486
385
  ].join("\n");
487
386
  }
488
- function buildAnalysisPrompt(task, planningResult, buildingResult, humanResult) {
387
+ function buildAnalysisPrompt(task, gradingResult, humanResult) {
489
388
  const parts = [`# Task Analysis: ${task.taskTitle}
490
389
  `];
491
390
  if (task.taskDescription) parts.push(`## Description
@@ -498,8 +397,30 @@ ${task.taskPlan}
498
397
  if (task.storyPointValue !== null) parts.push(`## Story Points: ${task.storyPointValue}`);
499
398
  parts.push("");
500
399
  if (task.sessionInfo) parts.push(buildSessionInfoSection(task.sessionInfo));
501
- if (planningResult) parts.push(buildGradingResultSection("Planning", planningResult));
502
- if (buildingResult) parts.push(buildGradingResultSection("Building", buildingResult));
400
+ if (gradingResult) {
401
+ const planGrades = gradingResult.turnGrades.filter((g) => g.phase === "planning");
402
+ const buildGrades = gradingResult.turnGrades.filter((g) => g.phase === "building");
403
+ if (planGrades.length > 0) {
404
+ parts.push(
405
+ buildPhaseResultSection(
406
+ "Planning",
407
+ planGrades,
408
+ gradingResult.planningAccuracy,
409
+ gradingResult.summary
410
+ )
411
+ );
412
+ }
413
+ if (buildGrades.length > 0) {
414
+ parts.push(
415
+ buildPhaseResultSection(
416
+ "Building",
417
+ buildGrades,
418
+ gradingResult.buildingAccuracy,
419
+ gradingResult.summary
420
+ )
421
+ );
422
+ }
423
+ }
503
424
  if (humanResult) {
504
425
  const evals = humanResult.humanEvaluations;
505
426
  const helpful = evals.filter((e) => e.rating > 0).length;
@@ -512,8 +433,7 @@ ${task.taskPlan}
512
433
  );
513
434
  parts.push("");
514
435
  }
515
- const allGrades = [...planningResult?.turnGrades ?? [], ...buildingResult?.turnGrades ?? []];
516
- const blunders = allGrades.filter((g) => g.grade === "blunder");
436
+ const blunders = (gradingResult?.turnGrades ?? []).filter((g) => g.grade === "blunder");
517
437
  if (blunders.length > 0) {
518
438
  parts.push("## Notable Blunders");
519
439
  for (const b of blunders.slice(0, 10)) {
@@ -664,16 +584,16 @@ function buildQueryOptions(systemPrompt, opts, limits, mcpServers = {}) {
664
584
  disallowedTools: ["Edit", "Write", "Bash", "NotebookEdit", "MultiEdit"]
665
585
  };
666
586
  }
667
- async function runGradingStep(taskId, phase, systemPrompt, userPrompt, limits, opts) {
587
+ async function runCombinedGradingStep(taskId, userPrompt, limits, opts) {
668
588
  const harness = createHarness();
669
589
  const events = harness.executeQuery({
670
590
  prompt: userPrompt,
671
- options: buildQueryOptions(systemPrompt, opts, limits)
591
+ options: buildQueryOptions(COMBINED_GRADING_SYSTEM_PROMPT, opts, limits)
672
592
  });
673
593
  const response = await collectResponseFromEvents(events, opts.connection, opts.requestId, taskId);
674
- if (!response.text) throw new Error(`No response from ${phase} grading step`);
594
+ if (!response.text) throw new Error("No response from combined grading step");
675
595
  return {
676
- result: extractGradingResult(response.text, phase),
596
+ result: extractCombinedGradingResult(response.text),
677
597
  costUsd: response.costUsd,
678
598
  model: response.model
679
599
  };
@@ -688,12 +608,12 @@ async function runHumanStep(taskId, userPrompt, limits, opts) {
688
608
  if (!response.text) throw new Error("No response from human evaluation step");
689
609
  return { result: extractHumanResult(response.text), costUsd: response.costUsd };
690
610
  }
691
- async function runAnalysisStep(task, planningResult, buildingResult, humanResult, projectId, suggestionIds, opts) {
611
+ async function runAnalysisStep(task, gradingResult, humanResult, projectId, suggestionIds, opts) {
692
612
  const wrappedTool = buildTrackedSuggestionTool(opts.connection, projectId, suggestionIds);
693
613
  const harness = createHarness();
694
614
  const mcpServer = harness.createMcpServer({ name: "conveyor", tools: [wrappedTool] });
695
615
  const events = harness.executeQuery({
696
- prompt: buildAnalysisPrompt(task, planningResult, buildingResult, humanResult),
616
+ prompt: buildAnalysisPrompt(task, gradingResult, humanResult),
697
617
  options: buildQueryOptions(
698
618
  ANALYSIS_SYSTEM_PROMPT,
699
619
  opts,
@@ -711,7 +631,7 @@ async function runAnalysisStep(task, planningResult, buildingResult, humanResult
711
631
  return { result: extractAnalysisResult(response.text), costUsd: response.costUsd };
712
632
  }
713
633
  var EMPTY_STEP = { result: null, costUsd: null, model: null };
714
- var GRADING_LIMITS = { maxTurns: 8, maxBudgetUsd: 1 };
634
+ var GRADING_LIMITS = { maxTurns: 24, maxBudgetUsd: 3 };
715
635
  async function executeStepSafely(stepLabel, requestId, taskId, fn) {
716
636
  try {
717
637
  const step = await fn();
@@ -725,47 +645,22 @@ async function executeStepSafely(stepLabel, requestId, taskId, fn) {
725
645
  return EMPTY_STEP;
726
646
  }
727
647
  }
728
- async function executePlanningStep(taskPayload, planningTrace, opts) {
729
- if (planningTrace.length === 0) return EMPTY_STEP;
648
+ async function executeCombinedGradingStep(taskPayload, opts) {
649
+ if (taskPayload.agentTrace.length === 0) return EMPTY_STEP;
730
650
  reportProgress(
731
651
  opts.connection,
732
652
  opts.requestId,
733
653
  taskPayload.taskId,
734
654
  "status",
735
- "Step 1/4: Auditing planning..."
655
+ "Step 1/3: Auditing full workflow..."
736
656
  );
737
657
  return await executeStepSafely(
738
- "Planning audit",
658
+ "Combined grading audit",
739
659
  opts.requestId,
740
660
  taskPayload.taskId,
741
- () => runGradingStep(
661
+ () => runCombinedGradingStep(
742
662
  taskPayload.taskId,
743
- "planning",
744
- PLANNING_AUDIT_SYSTEM_PROMPT,
745
- buildPlanningAuditPrompt(taskPayload, planningTrace),
746
- GRADING_LIMITS,
747
- opts
748
- )
749
- );
750
- }
751
- async function executeBuildingStep(taskPayload, buildingTrace, opts) {
752
- if (buildingTrace.length === 0) return EMPTY_STEP;
753
- reportProgress(
754
- opts.connection,
755
- opts.requestId,
756
- taskPayload.taskId,
757
- "status",
758
- "Step 2/4: Auditing building..."
759
- );
760
- return await executeStepSafely(
761
- "Building audit",
762
- opts.requestId,
763
- taskPayload.taskId,
764
- () => runGradingStep(
765
- taskPayload.taskId,
766
- "building",
767
- BUILDING_AUDIT_SYSTEM_PROMPT,
768
- buildBuildingAuditPrompt(taskPayload, buildingTrace),
663
+ buildCombinedGradingPrompt(taskPayload),
769
664
  GRADING_LIMITS,
770
665
  opts
771
666
  )
@@ -778,7 +673,7 @@ async function executeHumanStep(taskPayload, opts) {
778
673
  opts.requestId,
779
674
  taskPayload.taskId,
780
675
  "status",
781
- "Step 3/4: Auditing human contributions..."
676
+ "Step 2/3: Auditing human contributions..."
782
677
  );
783
678
  return await executeStepSafely(
784
679
  "Human audit",
@@ -792,40 +687,26 @@ async function executeHumanStep(taskPayload, opts) {
792
687
  )
793
688
  );
794
689
  }
795
- async function executeAnalysisStep(taskPayload, planning, building, human, projectId, suggestionIds, opts) {
690
+ async function executeAnalysisStep(taskPayload, grading, human, projectId, suggestionIds, opts) {
796
691
  reportProgress(
797
692
  opts.connection,
798
693
  opts.requestId,
799
694
  taskPayload.taskId,
800
695
  "status",
801
- "Step 4/4: Generating analysis & suggestions..."
696
+ "Step 3/3: Generating analysis & suggestions..."
802
697
  );
803
698
  return await executeStepSafely(
804
699
  "Analysis",
805
700
  opts.requestId,
806
701
  taskPayload.taskId,
807
- () => runAnalysisStep(
808
- taskPayload,
809
- planning.result,
810
- building.result,
811
- human.result,
812
- projectId,
813
- suggestionIds,
814
- opts
815
- )
702
+ () => runAnalysisStep(taskPayload, grading.result, human.result, projectId, suggestionIds, opts)
816
703
  );
817
704
  }
818
- async function reportAuditResult(connection, requestId, taskPayload, steps, planningTraceLength, suggestionIds) {
705
+ async function reportAuditResult(connection, requestId, taskPayload, steps, suggestionIds) {
819
706
  let totalCostUsd = null;
820
- for (const step of [steps.planning, steps.building, steps.human, steps.analysis])
707
+ for (const step of [steps.grading, steps.human, steps.analysis])
821
708
  totalCostUsd = addCosts(totalCostUsd, step.costUsd);
822
- const merged = mergeStepResults(
823
- steps.planning.result,
824
- steps.building.result,
825
- steps.human.result,
826
- steps.analysis.result,
827
- planningTraceLength
828
- );
709
+ const merged = mergeStepResults(steps.grading.result, steps.human.result, steps.analysis.result);
829
710
  await connection.call("reportTaskAuditResult", {
830
711
  projectId: connection.projectId,
831
712
  requestId,
@@ -839,24 +720,21 @@ async function reportAuditResult(connection, requestId, taskPayload, steps, plan
839
720
  ...computeGradeCounts(merged.turnGrades),
840
721
  suggestionIds,
841
722
  auditCostUsd: totalCostUsd,
842
- model: steps.planning.model ?? steps.building.model ?? null
723
+ model: steps.grading.model ?? null
843
724
  });
844
725
  }
845
726
  async function auditSingleTask(taskPayload, request, connection, projectDir, model) {
846
727
  const { requestId, projectId } = request;
847
728
  const suggestionIds = [];
848
729
  const opts = { connection, requestId, projectDir, model };
849
- const { planningTrace, buildingTrace } = sliceTrace(taskPayload.agentTrace);
850
- const planning = await executePlanningStep(taskPayload, planningTrace, opts);
851
- const building = await executeBuildingStep(taskPayload, buildingTrace, opts);
852
- if (!planning.result && !building.result && (planningTrace.length > 0 || buildingTrace.length > 0)) {
853
- throw new Error("All grading audit steps failed");
730
+ const grading = await executeCombinedGradingStep(taskPayload, opts);
731
+ if (!grading.result && taskPayload.agentTrace.length > 0) {
732
+ throw new Error("Grading audit step failed");
854
733
  }
855
734
  const human = await executeHumanStep(taskPayload, opts);
856
735
  const analysis = await executeAnalysisStep(
857
736
  taskPayload,
858
- planning,
859
- building,
737
+ grading,
860
738
  human,
861
739
  projectId,
862
740
  suggestionIds,
@@ -866,8 +744,7 @@ async function auditSingleTask(taskPayload, request, connection, projectDir, mod
866
744
  connection,
867
745
  requestId,
868
746
  taskPayload,
869
- { planning, building, human, analysis },
870
- planningTrace.length,
747
+ { grading, human, analysis },
871
748
  suggestionIds
872
749
  );
873
750
  logger.info("Task audit complete", {
@@ -903,4 +780,4 @@ async function handleTaskAudit(request, connection, projectDir) {
903
780
  export {
904
781
  handleTaskAudit
905
782
  };
906
- //# sourceMappingURL=task-audit-handler-Z3TBS4EN.js.map
783
+ //# sourceMappingURL=task-audit-handler-6XWYK6KZ.js.map