Generate gated code
generate_codeGenerate code with automatic validation gating, retrying rejected attempts and clearly marking unvalidated results.
Instructions
Generate code and gate it in one step: an LLM writes the implementation, then the same protection engine as validate_ai_output vets it — retrying generation when the gate rejects. If every attempt is vetoed you still receive the last attempt, clearly marked validated:false with the gate findings — rejected code is never presented as clean. Generation runs on our infrastructure; nothing executes in your environment.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | What to build, with any constraints worth enforcing — e.g. 'a rate-limited retry decorator with exponential backoff, stdlib only'. | |
| language | No | Target language for the generated code, e.g. 'python' (default), 'typescript', 'go', 'sql'. | python |
| max_tokens | No | Generation budget. The default 4000 fits most functions/classes; raise it for multi-file scaffolds. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | The generated implementation | |
| attempts | No | Generation attempts before approval or give-up | |
| provider | No | ||
| generated | Yes | False only when no provider returned code | |
| validated | No | True if the protection gates approved the final attempt; false means the gate findings in 'protection' explain the veto | |
| protection | No | Deterministic gate result. A veto here is final — the model review cannot override it. | |
| validation_score | No | Deterministic gate score, 0-100 |