Skip to content

fix_build_error refactoring - #498

Merged
opohorel merged 12 commits into
packit:mainfrom
opohorel:fix_build
May 19, 2026
Merged

opohorel merged 12 commits into
packit:mainfrom
opohorel:fix_build

Conversation

@opohorel

Copy link
Copy Markdown
Collaborator

Summary

This PR improves the fix_build_error iterative workflow for the backport agent by adding persistent memory across fix iterations and slimming down the prompts.

Changes

Persistent memory for fix iterations:

  • Build logs (builder-live.log, root.log) are now preserved in <upstream-repo>/build-logs/attempt-N/ directories across fix attempts, instead of being deleted after analysis.
  • A fix-attempts.md file is seeded and appended on each iteration with the build error, giving each fresh fix agent context on what was already tried.

Prompt optimization:

  • Replaced two verbose, nearly identical prompts (~290 lines total) with a single concise version (~55 lines) that instructs the agent to read fix-attempts.md before starting and not repeat failed strategies.

Misc:

  • Fixed restart: no YAML parsing bug in compose.yaml (interpreted as boolean False).

Commits

Commit Description
build_agent: stop deleting build logs after analysis Logs persist for the fix workflow
backport_agent: guard against missing upstream repo in fix_build_error Graceful fallback instead of crash
backport_agent: preserve build logs for fix iterations Move logs to build-logs/attempt-0/ on initial failure
backport_agent: seed fix-attempts.md as persistent memory across iterations Create/append fix history + per-attempt log dirs
backport_agent: slim fix_build_error prompts Replace verbose prompts with concise version
fix restart error of supervisor container Fix YAML restart: no → restart: "no"

opohorel added 6 commits May 19, 2026 09:28
Let log files persist in the working directory so the backport
fix workflow can preserve them for subsequent fix iterations.

Assisted-by: Claude Opus 4.6
Fall back to fork_and_prepare_dist_git (full reset) if the upstream
repository is missing when entering the incremental fix loop.

Assisted-by: Claude Opus 4.6
Move .log.gz files left by the build agent into the upstream repo's
build-logs/attempt-0/ directory so the fix agent can access them.

Assisted-by: Claude Opus 4.6
…ations

Write a structured log file before each fix agent invocation so
subsequent iterations can see what was already tried and avoid
repeating failed strategies.

Assisted-by: Claude Opus 4.6
Replace the verbose 143-line prompts with a concise 55-line version.
Remove git command examples, log-reading micromanagement, and
redundant rules. Add references to fix-attempts.md and build-logs.
ZSTREAM variant now references the same constant since both were
identical.

Assisted-by: Claude Opus 4.6

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the backport agent's ability to handle build failures by implementing a structured tracking system for fix attempts. Key changes include refactoring the backport agent's prompt for conciseness, organizing build logs into attempt-specific directories, and maintaining a historical log of fix attempts in a markdown file. Additionally, the build agent no longer deletes log files, and a YAML syntax fix was applied to the compose configuration. A review comment suggests refactoring the logic for writing to the fix-attempts log to reduce code duplication and improve maintainability.

Comment thread ymir/agents/backport_agent.py Outdated
@opohorel opohorel changed the title Fix build fix_build_error refactoring May 19, 2026
@TomasKorbar

Copy link
Copy Markdown
Collaborator

@opohorel hmm, how did you push this? :D the pre-push check should have stopped you, because you did not update the skill.

@TomasTomecek TomasTomecek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+89-267 love to see such PRs that reduce tech debt

Comment thread ymir/agents/backport_agent.py Outdated
f.write(
f"\n## Attempt {attempt_num}\n\n"
f"**Build error to fix:**\n```\n{state.build_error}\n```\n\n"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be a big hassle to cover this new code with a test case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I'll think about it. I would love to get some e2e testing for the backport agent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added tests for the helpers functions

@opohorel

Copy link
Copy Markdown
Collaborator Author

@opohorel hmm, how did you push this? :D the pre-push check should have stopped you, because you did not update the skill.

good question, simple answer. I force pushed into my fork as I was rewriting history. I'll regenerate the skills 😅

nforro
nforro previously approved these changes May 19, 2026

@nforro nforro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment thread ymir/agents/backport_agent.py Outdated
Comment thread ymir/agents/backport_agent.py Outdated
@nforro

nforro commented May 19, 2026

Copy link
Copy Markdown
Member

@opohorel hmm, how did you push this? :D the pre-push check should have stopped you, because you did not update the skill.

good question, simple answer. I force pushed into my fork as I was rewriting history. I'll regenerate the skills 😅

Even force push triggers pre-push hook. Do you have pre-commit properly installed?

opohorel added 2 commits May 19, 2026 10:21
Consolidate duplicated log-moving logic from run_build_agent and
fix_build_error into a single private helper, placed alongside the
other utility functions after the prompt definitions.

Assisted-by: Claude Opus 4.6
@opohorel

Copy link
Copy Markdown
Collaborator Author

@opohorel hmm, how did you push this? :D the pre-push check should have stopped you, because you did not update the skill.

good question, simple answer. I force pushed into my fork as I was rewriting history. I'll regenerate the skills 😅

Even force push triggers pre-push hook. Do you have pre-commit properly installed?

you are right, I remember installing it and using it, but somehow it didn't trigger here. I reinstalled it and now it warns me

@opohorel

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a structured tracking system for incremental build fix attempts. It introduces 'justification' and 'fix_version' parameters to the backport skill, refactors the build error fix prompt for conciseness, and adds logic to move build logs into versioned directories while maintaining a 'fix-attempts.md' log. Review feedback identifies a conflict between agent instructions and orchestrator logic regarding log locations, an off-by-one error in directory naming, and the need to use 'shutil.move' for cross-filesystem reliability. Additionally, improvements were suggested to reduce redundancy in the generated fix attempts log.

Comment thread ymir/agents/backport_agent.py Outdated
Comment thread ymir/agents/backport_agent.py Outdated
Comment thread ymir/agents/backport_agent.py
Comment thread ymir/agents/backport_agent.py
Comment thread ymir/agents/backport_agent.py
Assisted-by: Claude Opus 4.6
@opohorel
opohorel merged commit 5741d68 into packit:main May 19, 2026
9 checks passed
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.

4 participants