Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 20, 2026

Implements iterative agent execution where each iteration appends the previous result to the original prompt, enabling self-refinement and multi-pass analysis patterns.

Changes

  • Engine configuration: Added iterations field to EngineConfig struct and JSON schema

    • Accepts integer or string values (minimum 1)
    • Only activates when > 1 (single runs bypass loop overhead)
  • Loop implementation: Created run_agent_loop.sh in actions/setup/sh/

    • Saves original prompt, augments with previous outputs for subsequent runs
    • Per-iteration logging with timing and progress tracking
    • Stops on first failure, preserves all intermediate results
  • Engine integration:

    • Copilot, Claude, Codex: Wrapped execution commands with WrapCommandWithIterationLoop() helper
    • Custom engine: Exposes GH_AW_ITERATIONS environment variable for user-defined steps

Usage

---
engine:
  id: copilot
  iterations: 3
---

# Iteratively refine analysis

Review the codebase and suggest improvements.
On each iteration, build on previous findings.

The workflow executes 3 times, with iterations 2-3 receiving the original prompt plus all previous outputs in context.

Original prompt

Add support for specifying a number of iteration to run the agentic engine in a loop. On each iteration, the result of the previous exploration is appended to the original prompt and the agent is started again.

See reference https://github.com/anthropics/claude-plugins-official/tree/main/plugins/ralph-loop

  • implemented as a bash script in actions/setup/sh
  • extensive logging to support debugging
  • not activated unless the number of iteration is greater than 1
  • works for all agentic engine.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 20, 2026 02:43
- Add 'iterations' field to EngineConfig struct
- Create run_agent_loop.sh script for ralph-loop style iteration
- Integrate loop script in copilot, claude, codex engines
- Add GH_AW_ITERATIONS environment variable support
- Works when iterations > 1, skips for iterations = 1

Co-authored-by: pelikhan <[email protected]>
- Update main_workflow_schema.json to include iterations field
- Add test-iterations.md workflow to demonstrate the feature
- Rebuild binary to embed updated schema

Co-authored-by: pelikhan <[email protected]>
All tasks completed successfully:
- Added iterations field to EngineConfig and JSON schema
- Created run_agent_loop.sh with extensive logging
- Integrated loop script in all engines (copilot, claude, codex, custom)
- Test workflow demonstrates the feature working correctly

Co-authored-by: pelikhan <[email protected]>
Copilot AI changed the title [WIP] Add support for specifying number of iterations for agentic engine Add iterative agent loop support for ralph-loop style refinement Jan 20, 2026
@pelikhan pelikhan closed this Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants