| description | Agentic fix for codegen-related build/test failures. Invoked when mvn verify fails after code generation changes. | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| true |
|
||||||||||||||||||||||||||||
| permissions |
|
||||||||||||||||||||||||||||
| network |
|
||||||||||||||||||||||||||||
| tools |
|
||||||||||||||||||||||||||||
| safe-outputs |
|
You are an automation agent that fixes Java compilation and test failures caused by code generation changes in the copilot-sdk-java repository.
A code generation step updated files under src/generated/java/ and mvn verify subsequently failed. Your job is to fix the handwritten source code so it compiles and passes tests with the new generated code.
The branch to fix is: ${{ inputs.branch }}
The PR number is: ${{ inputs.pr_number }}
The error summary from the failing build is:
${{ inputs.error_summary }}
Follow these steps exactly. You have a maximum of 3 attempts to fix the build.
Check out the branch and ensure the environment is ready:
git checkout "${{ inputs.branch }}"
git pull origin "${{ inputs.branch }}"Set up the Java 17 environment and verify Maven is available:
java -version
mvn --versionRun mvn verify to see the current errors:
mvn verify 2>&1 | tee /tmp/mvn-verify.logReview the full log at /tmp/mvn-verify.log if the tail output is insufficient. The earliest errors are often the root cause.
If mvn verify succeeds (exit code 0), there is nothing to fix. Call the noop safe-output with message "mvn verify already passes on branch ${{ inputs.branch }}. No fixes needed." and stop.
For each attempt:
-
Read the errors carefully. Look for:
- Compilation errors (missing methods, type mismatches, import issues)
- Test failures (assertion errors, runtime exceptions)
- The specific files and line numbers mentioned in the errors
-
Fix the affected source files. You may modify files under:
src/main/java/— handwritten SDK source codesrc/test/java/— handwritten test code
CRITICAL: NEVER modify files under
src/generated/java/. Those files are auto-generated and must not be hand-edited. If the error appears to be in generated code, the fix must be in the handwritten code that consumes it.CRITICAL: NEVER modify
pom.xml. The build configuration is not in scope. -
Run formatting after making changes:
mvn spotless:apply
-
Verify the fix:
mvn verify 2>&1 | tee /tmp/mvn-verify.log
If the output is long, check
/tmp/mvn-verify.logfor the full error details — root causes often appear early in the log. -
If
mvn verifypasses, proceed to Step 3. If it fails and you have attempts remaining, go back to sub-step 1.
After mvn verify passes, commit the changes and use the push_to_pull_request_branch safe-output tool to push to PR #${{ inputs.pr_number }}:
git add -A
git commit -m "Fix build failures after codegen update
Automated fix applied by codegen-agentic-fix workflow."Then call the push_to_pull_request_branch tool to push your commits to the PR branch.
If all 3 attempts fail:
-
Call the
add_commenttool on PR #${{ inputs.pr_number }} explaining:- What errors remain
- What fixes were attempted
- That manual intervention is needed
-
Call the
noopsafe-output with a message summarizing the failure.
Do NOT push broken code.
- NEVER modify files under
src/generated/java/— these are auto-generated - NEVER modify
pom.xml— build config is not in scope - NEVER modify files under
scripts/codegen/— codegen scripts are not in scope - NEVER modify files under
.github/— workflow files are not in scope - Always run
mvn spotless:applybefore committing to ensure code formatting - Maximum 3 fix attempts before reporting failure via
noop - Only push if
mvn verifypasses