compose_prompt
Run an automated pipeline that clarifies, optimizes or grounds with sources, critiques, and auto-revises a prompt in a single call. Handles clarification questions and source grounding.
Instructions
Run the canonical ClarifyPrompt pipeline in ONE call: clarify (optional pre-stage) → ground OR optimize (core) → critique (optional post-stage) → optional auto-revise. Use this when you want the four-tool happy path without orchestrating five round-trips. Short-circuits if pre_clarify surfaces questions — caller answers and re-calls. When sources is non-empty the chain takes the strict ground_prompt branch; otherwise it goes through optimize_prompt. When auto_revise is true and critique returns a non-accept verdict with an improved rewrite, final_prompt is the rewrite. The stages array is a per-call audit log so callers can see exactly what ran.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | The prompt to compose. | |
| pre_clarify | No | 'auto' = run clarify only if analyzer confidence is low / prompt is short. 'always' = force clarify. 'never' = skip. When clarification questions surface, the chain stops; caller answers and re-calls. | auto |
| max_questions | No | ||
| sources | No | When non-empty, the chain takes the strict ground_prompt branch (caller-provided sources pinned at highest priority). | |
| post_critique | No | Run the critique judge against the optimized output. Adds ~3-5s on a local model. | |
| revise_threshold | No | ||
| critique_criteria | No | Override the default 5 critique criteria. | |
| auto_revise | No | When true AND post_critique is true AND verdict !== 'accept' AND there's an improvedPrompt: `final_prompt` becomes the rewritten version instead of the raw optimization. | |
| max_iterations | No | Max revise-loop iterations. With `auto_revise: true` AND `post_critique: true`, the engine can feed each iteration's improvedPrompt back through optimize+critique up to this cap. Stops early at verdict=accept or when there's no improvedPrompt. Default 1 (single-shot, no loop). Hard max 5 to prevent cost runaways. | |
| clarify_model | No | Override the LLM model for the clarify pre-stage. Default: env LLM_MODEL. Useful for per-stage cost/quality routing — e.g. run clarify on a cheap model while critique runs on a frontier one. | |
| optimize_model | No | Override the LLM model for the optimize/ground core stage. | |
| critique_model | No | Override the LLM model for the critique judge AND rewrite. | |
| category | No | ||
| platform | No | ||
| mode | No | ||
| enrich_context | No | ||
| session_id | No | ||
| file_path | No | ||
| file_language | No | ||
| file_excerpt | No | ||
| cwd | No | ||
| user_locale | No | ||
| user_pinned_instructions | No | ||
| skip_intent_resolution | No | ||
| include_bundle | No |