Additional features: Reflection
When to use
Enable Reflection for checks an LLM can verify without fetching new context—then auto-fix the draft if needed. Ideal for:
- Format & structure: validates JSON/YAML/Markdown sections, headings present, table columns, code fences.
- Counts & ranges: list has ≥ N items, word/character limits, numeric fields within bounds.
- Language/style: reading level, tone, banned phrases, inclusive language, tense/voice consistency.
- Required fields: keys present, non-empty values, citation stubs included, filename/ID included.
Not for fact-checking against external sources. If you need retrieval or tool data, use KB/tools first, then reflect on form and criteria only.
What it does
- After the agent drafts a reply, it runs a self-review pass (or several) using a Reflection prompt.
- If issues are found, the agent rewrites the reply and repeats until it passes or hits the Maximum Reflection Runs limit.
- This happens before delivery to the user, improving correctness, completeness, tone, and formatting.
Trade-off: more reflection runs = higher latency and token usage.
Enable in the UI
- Open your agent → Edit.
- In Additional features, click Add and toggle Reflection ON.
- Click Configuration to set:
- Maximum Reflection Runs (slider).
- Custom Reflection Prompt (textarea, with Reset to Default).
Recommended settings
- 0: Off (fastest).
- 1–2: Good default for most agents (balanced).
- 3–5: High-stakes or long-form outputs (PRDs, policy answers with citations).
- >5: Rare; expect noticeable latency.
A strong Reflection prompt (starter)
Use or adapt this checklist:
Review the draft and fix issues without changing meaning. Check: (1) accuracy vs. provided context/KB; (2) completeness and direct answer; (3) clarity, structure, and tone; (4) contradictions or leaps in logic; (5) required fields/format (JSON/Markdown). If unsure, propose the briefest clarifying question.
If citations are used, ensure they support each claim. Output only the improved final answer.
Variants by task
- Policy/KB Q&A: “Do not invent facts. If the KB doesn’t cover it, say so and suggest next steps.”
- Structured JSON: “Validate against this schema; if invalid, correct and re-emit valid JSON only.”
- Code: “Ensure runnable, add minimal comments; avoid unsafe operations; include example usage.”
- Tickets/Forms: “Verify all required fields present and consistent; surface missing fields as a short checklist.”
Best practices
- Keep the Reflection prompt short and specific to your domain.
- If you use Artifacts or tool citations, include them in the checklist (“preserve artifact structure”, “verify tool-sourced data is labeled”).
- For strict formats, ask reflection to validate and re-emit in the exact format.
- If responses become verbose, include “avoid repetition; remove filler language.”
Troubleshooting
- Too slow → lower Maximum Reflection Runs or tighten the prompt.
- Still incorrect → emphasize “do not invent” and “defer to KB/citations”; ensure the base answer actually had access to the right KB/tools.
- Breaks JSON/format → add explicit schema/format validation to the Reflection prompt.
- Over-editing tone → remove style-heavy checks; focus on accuracy/completeness.