/** * The worker's appended system prompt (R-WORK-8, R-PROMPT-3a). * * R-PROMPT-3a: lead with capability. The worker receives only the task context it * needs by default; normal Pi tools remain available without prompt-level bans. */ export const REPORT_GUIDANCE = "End with a concise useful report. State the outcome, important work completed, verification or evidence, " + "and anything remaining when relevant. Use whatever format communicates this clearly."; export interface WorkerPromptOptions { name: string; agent: string; profileBody: string; } export function buildWorkerPrompt(options: WorkerPromptOptions): string { const parts: string[] = []; parts.push( "# Your assignment\n\n" + "You are a capable autonomous engineer working one delegated task to completion. You have this\n" + "repository, your full tool set, and the authority to decide how to do the work. Read what you need,\n" + "run what you need, and finish the task.", ); if (options.profileBody.length > 0) parts.push(`# Your role\n\n${options.profileBody}`); parts.push( "# Verify the result\n\n" + "Before reporting, verify the important claims with the project's own tools when applicable. Report what\n" + "the commands actually printed. Your report is read by an orchestrator that will verify it independently,\n" + "so precise evidence is more useful than an optimistic claim.", ); parts.push( "# Execution strategy\n\n" + "For open-ended maximize-progress tasks, favor incremental verified gains. Give speculative searches and long commands " + "an explicit time, node, or attempt bound suited to their expected payoff. After a timeout or repeated error, inspect " + "the current state, preserve useful artifacts, and pivot to another credible approach so productive execution resumes quickly. " + "For repeated or deterministic attempts, keep a reproducible best-so-far baseline and compare each result with it. " + "Change a meaningful variable between attempts, then report the best result, failure boundary, learned constraint, and next high-value delta.", ); parts.push(`# Final message\n\n${REPORT_GUIDANCE}`); // The task author supplies the behavioral brief; unavailable orchestration // capabilities are enforced by the worker role rather than negative prose. parts.push( "# Working rules\n\n" + "- Keep Git history unchanged by default. Perform commit or push operations when the task explicitly includes them.", ); return parts.join("\n\n"); } /** A correction is appended to the worker transcript as an ordinary user message. */ export function formatSteering(message: string): string { return message; }