Skip to content

Critique and Refinement Tool

The Critique and Refinement Tool lets an AI agent pause after completing an action and think critically about what happened. It checks whether the result matches the original goal, points out any mistakes or gaps, and suggests a clear next step. This helps the agent stay on track and improve its decisions over time.

How it Works

The component is built on top of CritiqueAndRefinementBase. When you add it to a workflow, you give it two pieces of information:

  1. Tool Description – a short paragraph that tells the AI why and when it should use this tool.
  2. Tool Name – a friendly name that will appear in the agent’s tool list.

When the agent calls the tool, the component creates a small “reflection” routine. It receives the last action’s goal and result, runs a quick analysis, and returns a structured JSON object that contains:

  • The original goal
  • The result that was obtained
  • A critical assessment of the result
  • A suggested next step

No external APIs are called; everything happens locally inside the Nappai system.

Inputs

  • Tool Description
    A concise instruction set that tells the AI agent how and when to use this reflection tool.
    Example:

    Use this tool AFTER executing an action (e.g., a web search) to critically evaluate the result. This is your moment to be a critic of your own work to ensure you are on the right path.
  • Tool Name
    The name that will appear in the agent’s tool list. Choose something descriptive, like “Post‑Action Critique”.

Outputs

  • Tool
    The component outputs a Tool object (created by the build_tool method). This object can be added to the agent’s toolset so that the agent can invoke it during a workflow.

Usage Example

  1. Add the component to your workflow.
  2. Set the inputs:
    • Tool Description:
      Use this tool AFTER executing an action (e.g., a web search) to critically evaluate the result. This is your moment to be a critic of your own work to ensure you are on the right path.
    • Tool Name: Post‑Action Critique
  3. Connect the output of the tool to the next step in your workflow (e.g., a decision‑making component).

Typical flow

  • The agent performs a web search.
  • It then calls the Post‑Action Critique tool.
  • The tool returns a JSON object like: json { “original_goal”: “Find the latest sales data for Q3”, “result”: “Retrieved a PDF with Q2 figures”, “assessment”: “The result does not match the goal; the PDF is from the wrong quarter.”, “next_step”: “Search again using the keyword ‘Q3 sales data’ and verify the date.” }

The agent can read this output and decide how to proceed.

  • Web Search Tool – Retrieves information from the internet.
  • Action Execution Tool – Performs actions such as clicking links or filling forms.
  • Decision‑Making Tool – Chooses the next action based on input data.

Tips and Best Practices

  • Keep the Tool Description short but clear; it should explain the purpose and trigger conditions.
  • Use a memorable Tool Name so the agent can easily reference it.
  • Invoke the tool after any action that could produce ambiguous or incorrect results.
  • Review the JSON output to ensure the agent’s next step is actionable.

Security Considerations

The Critique and Refinement Tool processes data locally and does not send any information outside the Nappai environment. It only evaluates the agent’s own actions, so there are no external data‑leak risks.