Skip to main content

Reflexion Prompting

Reflexion is an agent prompting pattern in which, after a failed attempt, the agent generates a short verbal reflection on what went wrong and uses that reflection as additional context for its next attempt. It scales test-time compute by letting the agent learn within a single task without any weight updates — the "learning" lives in the prompt. Reflexion works well when the failure mode is inspectable (wrong tool call, wrong sub-plan, misread observation) and the agent can name the mistake. It works poorly when failures are opaque or when the root cause sits outside what the agent can observe.

Example

A coding agent attempts a refactor, runs the test suite, and sees 4 failures. Before retrying, it writes a reflection: "I assumed the old function signature was preserved, but the failing tests show it took a callback I removed. Next attempt: keep the callback parameter and route through the new implementation internally." The reflection is appended to the prompt for the next attempt, which passes.

Put this into practice

Build polished, copy-ready prompts in under 60 seconds with SurePrompts.

Try SurePrompts