AI review
The optional built-in reviewer reads an intent and its diff, then approves an eligible agent_review decision or escalates it to a person. Classification and policy routing still run deterministically in the Worker. External coding agents can review changes through the ordinary review API without enabling this feature.
Configure the Worker
Section titled “Configure the Worker”The Worker needs an AI binding. Its variables control when it calls the model:
| Variable | Behavior |
|---|---|
AI_REVIEW=off |
Refuses AI review with ai_unavailable; the change keeps waiting for an eligible reviewer. This is the self-hosting default. |
AI_REVIEW=manual |
Allows explicit requests and policy-requested AI review or advice. Hosted production uses this mode. |
AI_REVIEW=auto |
Also attempts review after an eligible proposal and advice for human-routed changes. |
AI_GATEWAY_ID |
Names an existing AI Gateway in the Worker’s account. An empty value calls Workers AI directly. |
AI_REVIEW_MODEL |
Selects the Workers AI model. An empty value uses @cf/meta/llama-4-scout-17b-16e-instruct. |
When self-hosting, scripts/selfhost.sh --ai-review manual enables explicit requests. Use the self-hosting guide for the deployment procedure. Changing a local variable does not change an already deployed Worker.
The implementation passes the gateway ID in the model call’s options, as described in Cloudflare’s Workers AI integration. Enable providers with AI_PROVIDERS (workers-ai, anthropic, openai, comma-separated). Third-party providers require a gateway with their key under the default BYOK alias or Unified Billing credit. AI_ANTHROPIC_MODEL and AI_OPENAI_MODEL override their models. The reviewer selects a different family from the author and may try another enabled provider if the first call fails. Hosted production currently enables Workers AI only.
Request a review
Section titled “Request a review”From the project’s checkout, propose the pushed change and inspect the resulting decision. If it is waiting for agent review, use its intent ID:
wayglass ai-review <intent-id> --jsonThe response includes decision, approvals, review and next. The review records the verdict, reason, concerns, model, gateway, latency, token usage when returned, and confidence. The Worker’s audit record identifies the caller who requested it.
An approval records <provider>:<model> as the reviewer, with identity source ai, through the normal decision path. It does not land the code: the author still runs wayglass land after approval. An escalation changes the action to human_approve and status to pending_human, retaining the reason and concerns in detail.escalation and the audit log.
The author and reviewer-family checks still apply. A human-routed decision returns needs_human; an off or missing binding returns ai_unavailable. Neither response grants approval. After escalation, a person must decide the change.
What the model receives
Section titled “What the model receives”The reviewer sends the goal, reason, declared paths, decision context and rendered diff to the model. It does not run the project’s tests. The implementation escalates on an incomplete or oversized diff, detected reviewer-directed instructions, malformed output, model errors, or an approval below its confidence threshold. These checks do not guarantee that a model will recognize unsafe code.
Model calls can incur charges. The reviewer caps the diff at 60 KB and reserves each model call against AI_DAILY_REVIEWS (default 200 per project per UTC day). Reviews and advice share the budget; a fallback consumes another call. Concurrent requests cannot exceed it. An interrupted request retains its reservation. Over budget, review escalates and advice is skipped with an audit record. A repository’s jurisdiction tag does not constrain the location of model processing or gateway logs. Review the provider and gateway settings before enabling it for sensitive code.
Policy and advisory input
Section titled “Policy and advisory input”An agent_review rule can set reviewer: ai, agent or any, plus ai.min_confidence and ai.model. reviewer: ai requests review on propose in manual or automatic mode; off still prevents calls. reviewer: agent refuses AI review. A human-routed rule can set ai: { advise: true }.
wayglass ai-advice <intent-id> --jsonAdvice records a summary, risks and questions in detail.ai_advice and the audit log. The decision stays pending for a person. Clients label the output advisory; a separate human approval is still required.
GET /v1/cost?project=<name> includes ai: calls, outcomes, aggregate tokens, estimated dollars, today’s usage and the remaining daily budget. The live check used 1,320 tokens in two model calls, estimated at $0.000433. Approval latency was 4,109 ms and advisory latency 2,396 ms. These are observations from that run, not performance guarantees. Unpriced calls are excluded from the dollar estimate.
The FAQ explains review mistakes, prompt injection and human authority. The policy documentation describes the decision rules.