Skip to content

MaxCode: Integrate MergeAgent into PrimaryAgent pipeline and update conversion tools#27

Open
gvanica wants to merge 1 commit intomainfrom
split/5-pipeline-integration
Open

MaxCode: Integrate MergeAgent into PrimaryAgent pipeline and update conversion tools#27
gvanica wants to merge 1 commit intomainfrom
split/5-pipeline-integration

Conversation

@gvanica
Copy link
Copy Markdown
Collaborator

@gvanica gvanica commented Apr 22, 2026

Summary

Updates the core pipeline orchestration so that directory-mode conversions now use MergeAgent to merge and filter repository files before converting, instead of processing each file independently. Also updates the migration tool to handle the new output format and auto-run verification.

Key changes

primary_agent.py (+632 / -221 lines) — Major rewrite

  • Directory path: Now calls MergeAgent.run() to produce a single merged model file + optional utils file, then converts the merged output in one shot. Previously processed each file independently, leading to inconsistent cross-file references.
  • Single-file path: Unchanged — still converts individual files directly.
  • Debug loop: Integrated iterative debug loop with syntax checking and AST validation of converted output.
  • Imports new agents: maxtext_conversion_agent, validation_agent.

model_conversion_agent.py (+47 lines modified)

  • Updated to accept merged multi-file input alongside single-file input.
  • Passes RAG context through to conversion prompts.

single_file_agent.py (+62 lines modified)

  • Tightened single-file conversion path with improved error handling.
  • Better markdown stripping for LLM output.

repo_agent.py (2 lines)

  • Minor fix to repository cloning logic.

migration_tool.py (+136 lines modified)

  • Handles the new model + utils dual-output format from PrimaryAgent.
  • Auto-runs verification scorecard after conversion completes.
  • Improved output path handling.

Files

File Change Lines
agents/migration/primary_agent.py Modified +632 / -221
agents/migration/model_conversion_agent.py Modified +47
agents/migration/single_file_agent.py Modified +62
agents/migration/repo_agent.py Modified +2 / -2
tools/migration_tool.py Modified +136

Dependencies

This PR references MergeAgent, ValidationAgent, and MaxTextConversionAgent which are introduced in sibling PRs (#24, #25, #27). It also uses the updated prompts from #26.

Test plan

  • Run PrimaryAgent.run() on a directory containing multiple model files — verify it merges before converting
  • Run PrimaryAgent.run() on a single file — verify single-file path still works
  • Verify convert_code tool returns model + utils output and prints verification scorecard
  • Confirm debug loop catches syntax errors and retries

Split from #17 — PR 5 of 8

… tools

Updates PrimaryAgent to use MergeAgent for directory-mode conversions
instead of processing files independently. Updates migration_tool to
handle the new model+utils output format and auto-run verification.

- primary_agent.py: directory path now merges files before conversion
- model_conversion_agent.py: updated for multi-file merged input
- single_file_agent.py: tightened single-file conversion path
- migration_tool.py: handles model+utils output, runs scorecard

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 22, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

1 participant