Skip to content
Search is loading.

Implementation and review example

Available now This example uses released workflow primitives and verified catalog values.

This workflow implements one request. Claude and pi review each implementation attempt in parallel.

A gate step in the workflow reads both reviews after each attempt. The gate can return review feedback to a new Codex attempt, and it stops after approval or three attempts.

Authenticate Codex, Claude, and the selected pi provider. This example calls all three backends.

Run the live catalog probe:

Codex, Claude, and pi · catalog probe

npx -y @automatalabs/workflows config codex claude pi

The result must include each model, mode, option name, and option value used in this section.

Save this source as implementation-review.workflow.js in the project that you want to change.

implementation-review.workflow.js · workflow script

export const meta = {
name: 'implementation-review',
description:
'Implement a request, review it independently, and revise until approved',
phases: [{ title: 'Implement' }, { title: 'Review' }],
};
const input =
typeof args === 'string'
? JSON.parse(args)
: args && typeof args === 'object' && !Array.isArray(args)
? args
: {};
if (typeof input.request !== 'string' || !input.request.trim()) {
throw new Error("args.request must contain the user's request");
}
const VERDICT = {
type: 'object',
additionalProperties: false,
required: ['ok', 'feedback'],
properties: {
ok: {
type: 'boolean',
description: 'True only when the implementation satisfies the request',
},
feedback: {
type: 'string',
description: 'Specific evidence-backed changes required when ok is false',
},
},
};
const approved = await checkpoint(
`Start the implementation and review workflow for this request?\n${input.request}`,
{ kind: 'confirm', default: true },
);
if (!approved) return { validated: false, reason: 'not approved' };
phase('Implement');
const outcome = await gate(
(feedback, attempt) =>
agent(
`User request:\n${input.request}\n\n` +
`Implement attempt ${attempt + 1}. Run the relevant checks.` +
(feedback ? `\n\nReview feedback:\n${feedback}` : ''),
{
label: `implementation:${attempt + 1}`,
model: 'codex/gpt-5.6-sol',
mode: 'agent',
configOptions: { reasoning_effort: 'max' },
retries: 1,
},
),
async (implementation) => {
if (!implementation) {
return {
ok: false,
feedback: 'The implementation call did not complete.',
};
}
phase('Review');
const reviews = (
await parallel([
() =>
agent(
`Review this implementation for correctness.\nUser request:\n${input.request}\n\nImplementation report:\n${implementation}`,
{
label: 'review:correctness',
model: 'claude/opus[1m]',
mode: 'plan',
configOptions: { effort: 'max' },
schema: VERDICT,
},
),
() =>
agent(
`Review this implementation for product truth.\nUser request:\n${input.request}\n\nImplementation report:\n${implementation}`,
{
label: 'review:product-truth',
model: 'pi/moonshotai/kimi-k3',
configOptions: { thinkingLevel: 'max' },
schema: VERDICT,
},
),
])
).filter(Boolean);
if (reviews.length !== 2) {
return {
ok: false,
feedback: 'An independent review call did not complete.',
};
}
const changes = reviews.filter((review) => !review.ok);
return changes.length
? {
ok: false,
feedback: changes.map((review) => review.feedback).join('\n'),
}
: { ok: true, feedback: '' };
},
{ attempts: 3 },
);
return {
validated: outcome.ok,
attempts: outcome.attempts,
result: outcome.value,
};

The script has four parts: the meta export, a confirmation checkpoint, a gate that pairs each Codex attempt with parallel Claude and pi reviews, and a structured return value.

The workflow can change files through the Codex call. Before you run it, review the request and the working directory.

Run this command from the project directory:

implementation-review.workflow.js · validation command

npx -y @automatalabs/workflows validate implementation-review.workflow.js \
--args '{"request":"Add a unit test for the parser error path."}'

Validation uses a mock agent backend. It does not make the requested changes.

Send this payload through the workflow tool:

workflow tool · background run request

{
"action": "run",
"scriptPath": "/absolute/path/to/implementation-review.workflow.js",
"args": {
"request": "Add a unit test for the parser error path."
},
"maxAgents": 9,
"concurrency": 2,
"agentRetries": 1,
"tokenBudget": 120000,
"background": true
}

Replace the absolute path and the request with your values. Use the same request value in the validation command and the run request.

Keep the returned runId. Await the run in bounded intervals.

workflow tool · bounded await request

{
"action": "await",
"runId": "mabc1234-k9x2pq",
"waitMs": 20000,
"lastN": 10,
"labelGlob": "review:*",
"logLines": 20
}

The workflow result reports validated, attempts, and the implementation report from the last attempt. Review the changed files and run the project tests.

These sources contain more examples: