Skip to content

fix: surface merge conflicts before invoking Codex#812

Merged
stranske merged 4 commits intomainfrom
fix/surface-merge-conflicts-before-codex
Jan 12, 2026
Merged

fix: surface merge conflicts before invoking Codex#812
stranske merged 4 commits intomainfrom
fix/surface-merge-conflicts-before-codex

Conversation

@stranske
Copy link
Copy Markdown
Owner

@stranske stranske commented Jan 12, 2026

Source: Issue #123

Automated Status Summary

Scope

After merging PR #103 (multi-agent routing infrastructure), we need to:

Context for Agent

Design Decisions & Constraints

    1. Clean up comment patterns to avoid a mix of old UI-agent and new CLI-agent comments
  • The keepalive loop now:
  • | <!-- keepalive-loop-summary --> | github-actions[bot] | NEW: CLI agent iteration tracking | ✅ Keep for CLI agents |
  • | <!-- keepalive-state:v1 --> | agents-workflows-bot[bot] | State tracking | ⚠️ Multiple copies accumulate |
  • | <!-- keepalive-round: N --> | stranske | OLD: Instruction comment | ❌ CLI agents dont need this |
  • The goal: For CLI agents (agent:* label), we should have exactly one updating comment (<!-- keepalive-loop-summary -->) instead of accumulating 10+ comments per PR.
  • Requires PR #103 to be merged first
  • This round you MUST:
  • Review the Scope/Tasks/Acceptance below, identify the next incomplete task that requires code, implement it, then post a reply comment with the completed items using their exact original text.

Related Issues/PRs

References

Blockers & Dependencies

  • After merging PR #103 (multi-agent routing infrastructure), we need to:
    1. Mark a task checkbox complete ONLY after verifying the implementation works.

Tasks

  • 1. Validate the CLI agent pipeline works end-to-end with the new task-focused prompts
  • 2. Add GITHUB_STEP_SUMMARY output so iteration results are visible in the Actions UI
  • 3. Streamline the Automated Status Summary to reduce clutter when using CLI agents
  • 4. Clean up comment patterns to avoid a mix of old UI-agent and new CLI-agent comments

Acceptance criteria

  • CLI agent receives explicit tasks in prompt and works on them
  • Iteration results visible in Actions workflow run summary
  • PR body shows checkboxes but not workflow clutter when using CLI agents
  • UI Codex path (no agent label) continues to show full status summary
  • CLI agent PRs have ≤3 bot comments total (summary, one per iteration update) instead of 10+
  • State tracking is consolidated in the summary comment, not scattered

The keepalive loop detects conflicts and routes to fix_merge_conflicts.md,
but Codex was checking git status and reporting 'no conflicts' because the
merge hadn't been attempted yet.

The prompt instructs 'Do NOT check git status first, run git merge', but
Codex checks git status anyway and exits early.

Solution: Add workflow step that runs git merge BEFORE invoking Codex.
This surfaces conflicts in the workspace so they're visible when Codex
checks git status, regardless of whether Codex follows the prompt order.

Fixes conflict resolution flow end-to-end:
1. Keepalive detects conflicts (✓ already working)
2. Workflow allows Codex to run for action='conflict' (✓ PR #773)
3. Workflow surfaces conflicts in workspace (✓ this fix)
4. Codex sees conflicts and resolves them (✓ with this fix)

Ref: Trend_Model_Project PR #4339
Copilot AI review requested due to automatic review settings January 12, 2026 00:24
@stranske stranske added the agent:codex Agent-created issues from Codex label Jan 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 12, 2026

🤖 Keepalive Loop Status

PR #812 | Agent: Codex | Iteration 0/5

Current State

Metric Value
Iteration progress [----------] 0/5
Action run (agent-run-failed)
Agent status ❌ AGENT FAILED
Gate success
Tasks 0/10 complete
Timeout 45 min (default)
Timeout usage 2m elapsed (6%, 43m remaining)
Keepalive ✅ enabled
Autofix ❌ disabled

Last Codex Run

Result Value
Status ❌ AGENT FAILED
Reason agent-run-failed
Exit code unknown
Failures 1/3 before pause

🔍 Failure Classification

| Error type | infrastructure |
| Error category | transient |
| Suggested recovery | Capture logs and context; retry once and escalate if the issue persists. |

⚠️ Failure Tracking

| Consecutive failures | 1/3 |
| Reason | agent-run-failed |

@stranske stranske temporarily deployed to agent-high-privilege January 12, 2026 00:26 — with GitHub Actions Inactive
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b9061517e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical issue in the conflict resolution workflow where Codex was checking git status before attempting a merge, seeing a clean state, and incorrectly reporting no conflicts. The fix adds a pre-processing step that surfaces merge conflicts in the workspace before invoking Codex.

Changes:

  • Adds a new "Surface merge conflicts" workflow step that runs before Codex invocation
  • Conditionally executes only when the conflict resolution prompt is being used
  • Attempts git merge --no-commit --no-ff origin/main to surface conflicts in the working tree

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…tection dynamic

Addresses three critical review comments:

1. **Codex P1 (CRITICAL)**: Move merge step AFTER dependency installation
   - Problem: If conflicts touch requirements*.txt or pyproject.toml, pip install
     fails when trying to parse files with conflict markers
   - Solution: Moved 'Surface merge conflicts' step from before Python setup
     (line 236) to just before 'Run Codex' (line 485)
   - This ensures dependencies are installed cleanly before conflicts are surfaced

2. **Copilot**: Dynamic base branch detection instead of hardcoded 'origin/main'
   - Added logic to detect base branch from GITHUB_BASE_REF, workflow input,
     origin/HEAD, or fallback to 'main'
   - Makes workflow portable across repos with different default branches

3. **Copilot**: Simplified error handling
   - Removed unnecessary set +e / set -e toggling
   - Use 'merge_exit=0; git merge ... || merge_exit=$?' pattern
   - Maintains set -euo pipefail throughout for consistency
@stranske stranske temporarily deployed to agent-high-privilege January 12, 2026 00:40 — with GitHub Actions Inactive
@github-actions github-actions bot added the autofix Opt-in automated formatting & lint remediation label Jan 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Status | ✅ no new diagnostics
History points | 1
Timestamp | 2026-01-12 00:41:02 UTC
Report artifact | autofix-report-pr-812
Remaining | 0
New | 0
No additional artifacts

@stranske stranske merged commit 2872d66 into main Jan 12, 2026
37 checks passed
@stranske stranske deleted the fix/surface-merge-conflicts-before-codex branch January 12, 2026 00:41
@stranske-automation-bot
Copy link
Copy Markdown
Collaborator

🤖 Bot Comment Handler

  • Agent: codex
  • Bot comments to address: 3

The agent has been assigned to this PR to address the bot review comments.

Instructions for agent

  1. Implement suggested fixes that improve the code
  2. Skip suggestions that don't apply (note why in your response)

The bot comment handler workflow has prepared context in the artifacts.

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

Labels

agent:codex Agent-created issues from Codex autofix Opt-in automated formatting & lint remediation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants