/Agent Strategy/Self-Refine Agent Strategy
app icon

Self-Refine Agent Strategy

Verified by Dify
No ratings yet
2
L
langgenius/self_refine_agent

Agent strategy with automatic self-critique and iterative refinement. Based on Self-Refine (NeurIPS 2023).

Agent

Self-Refine Agent Strategy

A Dify agent strategy plugin that improves output quality through iterative self-critique and refinement.

What It Does

Self-Refine Agent Strategy implements the Self-Refine (NeurIPS 2023) algorithm, enabling agents to automatically evaluate and improve their own outputs through multiple refinement cycles.

The strategy works by having the LLM act as its own critic:

  1. Execute - Agent generates an initial response
  2. Evaluate - LLM judges the output quality (0-100 score)
  3. Critique - LLM identifies specific issues and improvement opportunities
  4. Refine - Critique is injected into context for the next iteration
  5. Repeat - Process continues until quality threshold is met or max refinements reached

This approach is particularly effective for tasks requiring high-quality outputs such as writing, analysis, code generation, and complex reasoning.

Key Features

  • Automatic Quality Control - LLM evaluates its own outputs without human intervention
  • Iterative Improvement - Each refinement cycle builds on previous critiques
  • Transparent Process - All intermediate steps (execution, evaluation, critique) are visible
  • Configurable - Control maximum iterations and refinement cycles

Usage

Parameters

ParameterTypeDefaultDescription
model-selector-LLM model to use
array[tools]-Available tools for the agent
string-System instructions for the agent
string-User query to process
array[object]-Optional context information
number5Max iterations per agent execution
number2Max refinement cycles (0-5)

Configuration Example

When configuring the agent in Dify:

  1. Select Self-Refine Agent as your strategy
  2. Choose your preferred LLM model
  3. Set to control quality vs. speed tradeoff:
    • - No refinement (standard agent behavior)
    • - Balanced (recommended for most cases)
    • - High quality (best for critical outputs)

Local Development

To test the plugin locally:

  1. Create a file:
  1. Ensure Dify is running locally (via Docker Compose)

  2. Start the plugin:

How It Works

The refinement loop follows this pattern:

The agent automatically stops refining when:

  • Output quality score reaches 80 or above
  • Maximum refinement cycles are reached
  • No significant improvements are detected

Reference

Based on the paper:

Madaan, A., Tandon, N., Gupta, P., Hallinan, S., Gao, L., Wiegreffe, S., ... & Clark, P. (2023).
Self-Refine: Iterative Refinement with Self-Feedback.
NeurIPS 2023. arXiv:2303.17651

License

MIT License

CATEGORY
Agent Strategy
VERSION
0.0.5
langgenius·Updated 2 hours ago
REQUIREMENTS
LLM invocation
Tool invocation
Maximum memory
1MB
Access domain

Not scanned

Security
Security Rating
Give a rate
SHARE WITH