cyberine
UsageRun recipes

Result projection — configurable worker output fidelity (T328)

By default every worker returns a full Result: the complete output text, usage stats, and any raw provider payload. When a judge or downstream step only needs a summary (e.g. an LLM judge that scans a one-line verdict) or just the diff artifact (e.g. a DiffJudge that only reads result.raw.diff), forcing full transcripts into context wastes tokens and increases judge latency.

Set projection on a workflow step or directly on a Task to control how much of each assembled Result is materialised:

LevelWhat you getBest for
full (default)All fields — complete output, usage, raw payloadGeneral-purpose; backward-compatible default
summaryFirst 500 chars of output + [N chars omitted]; raw droppedLLM judges that scan short answers; chat summariser steps
artifact-onlyoutput cleared; raw (diff/artifact) kept; usage keptisolate: true build steps where the git diff is the deliverable
structuredFull output kept; raw droppedJSON-parsing judges that parse output text but do not need provenance

Workflow step — apply projection to all workers in a step:

// In a workflow definition (TypeScript):
const def: WorkflowDef = {
  name: 'implement-and-judge',
  steps: [
    {
      id: 'implement',
      prompt: '...',
      isolate: true,
      // Only the diff matters — drop full text output to keep context lean.
      projection: 'artifact-only',
    },
    {
      id: 'evaluate',
      prompt: 'Evaluate the diff from {{implement}}.',
      // Short summary is enough for the LLM judge.
      projection: 'summary',
    },
  ],
};

Programmatic Task — per-call override when dispatching adapters directly:

import { applyProjection } from './src/core/projection.ts';

const result = await adapter.run({
  id: crypto.randomUUID(),
  prompt: task,
  projection: 'structured',   // output kept, raw dropped
});
// result.projection === 'structured'
// result.raw === undefined

Reading truncation metadata — when projection: 'summary' trimmed the output:

if (result.projection === 'summary' && result.originalOutputLength !== undefined) {
  console.log(`Output was ${result.originalOutputLength} chars; judge saw ${result.output.length}`);
}

Backward compatibility — absent projection (the default) reproduces today's behavior exactly. Existing workflows, adapters, and judges are unaffected. The projection and originalOutputLength fields on Result are optional; their absence means the full result was returned.