> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Output Review with Retry Example

> Uses on_reject=OnReject.retry with reject(feedback=...) to send feedback to the agent on retry.

```python output_review_with_retry.py theme={null}
"""
Output Review with Retry Example

This example demonstrates the reject-with-feedback-and-retry pattern using
the HITL config:
1. Agent produces output
2. Human reviews and rejects with feedback ("too formal, make it casual")
3. Agent retries with the feedback
4. Human reviews again and approves

Uses on_reject=OnReject.retry with reject(feedback=...) to send
feedback to the agent on retry.
"""

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.workflow import OnReject
from agno.workflow.step import Step
from agno.workflow.types import HumanReview
from agno.workflow.workflow import Workflow

draft_agent = Agent(
    name="Drafter",
    model=OpenAIResponses(id="gpt-5.4"),
    instructions="You draft short professional emails. Keep it under 3 sentences.",
)

send_agent = Agent(
    name="Sender",
    model=OpenAIResponses(id="gpt-5.4"),
    instructions="You confirm sending the email. Summarize what was sent.",
)

workflow = Workflow(
    name="email_review_workflow",
    db=SqliteDb(db_file="tmp/output_review_retry.db"),
    steps=[
        Step(
            name="draft_email",
            agent=draft_agent,
            human_review=HumanReview(
                requires_output_review=True,
                output_review_message="Review the email draft before sending",
                on_reject=OnReject.retry,  # Re-run the step on rejection
                max_retries=3,  # Maximum 3 retry attempts
            ),
        ),
        Step(
            name="send_email",
            agent=send_agent,
        ),
    ],
)

run_output = workflow.run(
    "Draft an email to the team about the Friday standup being moved to Monday"
)

while run_output.is_paused:
    for requirement in run_output.steps_requiring_output_review:
        print(
            f"\nStep '{requirement.step_name}' output (attempt {requirement.retry_count + 1}):"
        )
        print(
            f"{requirement.step_output.content if requirement.step_output else 'N/A'}"
        )

        user_input = input("\nApprove? (yes/no): ").strip().lower()

        if user_input in ("yes", "y"):
            requirement.confirm()
        else:
            feedback = input("What should change? ")
            requirement.reject(feedback=feedback)
            print("Rejected with feedback. Retrying...")

    run_output = workflow.continue_run(run_output)

print(f"\nFinal status: {run_output.status}")
print(f"Final output: {run_output.content}")
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno fastapi openai sqlalchemy
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `output_review_with_retry.py`, then run:

    ```bash theme={null}
    python output_review_with_retry.py
    ```
  </Step>
</Steps>

Full source: [cookbook/04\_workflows/08\_human\_in\_the\_loop/output\_review/02\_output\_review\_with\_retry.py](https://github.com/agno-agi/agno/blob/main/cookbook/04_workflows/08_human_in_the_loop/output_review/02_output_review_with_retry.py)
