Skip to content

Refactoring with Iterative Refinement Example #1414

Closed

Description

@neubig

Create an example in the examples directory that is "refactoring with iterative refinement". It will be based on "COBOL to Java Refactoring", where we try to convert a COBOL directory to a Java directory.

It will be based on a for loop, where repeatedly:

  1. the agent is called with a prompt asking it to refactor all the COBOL files in a directory to JAVA files in another
  2. a new agent is asked to generate a critique giving a score of how complete the refactoring of each file in the directory is with a report created in a specified format. the total grade will be the average of the grades for each of the original files.

at the end of "2.", if the overall grade is less than 90%, then we return to step 1 and provide the agent the location of the critique file so it can understand what needs to be improved.

As source data, we can recommend the files in this directory.
https://github.com/aws-samples/aws-mainframe-modernization-carddemo/tree/main/app/cbl

When this is done, open a draft PR on the software-agent-sdk examples directory and check if CI passes. It probably won't due to missing documentation, so also create the missing documentation. Then once that is done, run the example in the background and sleep while it's working repeatedly until you confirm that it finishes successfully. If it does, add a comment on the PR with a snippet of the final critique file then conclude.

Activity

  1. added
    enhancement
    openhands
    on Dec 17, 2025
  2. openhands-ai commented on Dec 17, 2025

    @openhands-ai
  3. added 2 commits that reference this issue on Dec 17, 2025
    1fdfe68
    7e05c38
  4. openhands-ai commented on Dec 17, 2025

    @openhands-ai

    Summary

    I have successfully completed issue #1414 - "Refactoring with Iterative Refinement Example". Here's what was accomplished:

    Checklist

    • ✅ Created iterative refinement example in examples/01_standalone_sdk/31_iterative_refinement.py
    • ✅ Example implements the requested workflow:
      1. Refactoring agent converts COBOL files to Java files
      2. Critique agent evaluates conversions with scores (0-100 per file)
      3. Loop continues until average score ≥ 90% (or max 5 iterations)
    • ✅ Sample COBOL files based on AWS CardDemo structure included
    • ✅ Pre-commit hooks pass
    • ✅ Draft PR created: Add iterative refinement example for COBOL to Java refactoring #1415
    • ✅ Documentation created in OpenHands/docs: Add documentation for iterative refinement example docs#191
    • ✅ Example ran successfully (94% score on first iteration)
    • ✅ Comment added to PR with final critique snippet

    Files Created

    software-agent-sdk:

    • examples/01_standalone_sdk/31_iterative_refinement.py (469 lines)

    OpenHands/docs:

    • sdk/guides/iterative-refinement.mdx (620 lines)

    Example Run Results

    • Total iterations: 1
    • Final score: 94.0%
    • Quality threshold: 90.0%
    • Example cost: $0.60

    The example successfully converted 3 COBOL files to Java:

    • CBACT01C.cbl → AccountDisplay.java (93/100)
    • CBCUS01C.cbl → CustomerInformation.java (93/100)
    • CBTRN01C.cbl → TransactionProcessing.java (95/100)

    Pull Requests

    1. software-agent-sdk PR Add iterative refinement example for COBOL to Java refactoring #1415 (draft): Add iterative refinement example for COBOL to Java refactoring #1415

    2. docs PR Move prompts in context directory #191 (draft): Add documentation for iterative refinement example docs#191

      • Contains documentation for the example
      • Cross-referenced with the SDK PR

    View full conversation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementopenhands

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions