Phase 2: Create Conflict Resolver Foundational Agent

Overview

Create and configure the Conflict Resolver foundational agent that autonomously resolves conflicts by editing files, committing, and pushing changes with user approval.

Key Behavior Change

⚠️ This is NOT a guidance agent - The agent performs the actual conflict resolution:

  • Analyzes conflicts
  • Determines resolution strategy
  • Asks user for approval
  • Edits files to remove conflict markers
  • Creates commit with resolved changes
  • Pushes to source branch
  • Reports results to user

Tasks

Agent Creation in AI Catalog

  • Navigate to AI Catalog (https://gitlab.com/explore/ai-catalog)
  • Create new agent with reference conflict_resolver_agent
  • Write autonomous execution system prompt
  • Configure tools array with execution capabilities:
    • ID 20: get_merge_request
    • ID 88: get_merge_request_conflicts ⭐
    • ID 39: read_file
    • ID 10: edit_file ⭐ (for applying resolutions)
    • ID 3: run_git_command ⭐ (for commit/push)
    • ID 1: gitlab_blob_search
    • ID 24: grep
    • ID 9: create_merge_request_note
  • Configure agent privileges:
    • READ_WRITE_FILES (1) - Edit files
    • READ_WRITE_GITLAB (3) - GitLab API
    • USE_GIT (5) - Git operations
    • RUN_MCP_TOOLS (6) - Use tools
  • Set version to experimental
  • Note the global_catalog_id for monolith integration

System Prompt Requirements

The prompt MUST instruct the agent to:

1. Analyze & Plan:

  • Fetch conflicts using get_merge_request_conflicts
  • Determine resolution strategy
  • Assess confidence level

2. Get User Approval:

  • Present clear resolution plan
  • Explain what will be changed
  • Show confidence level
  • Wait for explicit approval before executing

3. Execute Autonomously:

  • Use edit_file to apply resolutions to each conflicting file
  • Remove conflict markers (<<<<<<<, =======, >>>>>>>)
  • Apply chosen resolution
  • Stage changes

4. Commit & Push:

  • Use run_git_command to create commit
  • Generate descriptive commit message
  • Push to source branch
  • Handle errors gracefully

5. Report Results:

  • Confirm successful resolution
  • Provide commit SHA
  • Link to updated MR
  • Report if any issues occurred

Example Interaction Flow

Agent: I analyzed 3 conflicts in this MR. Here's my resolution plan:

1. app/models/user.rb: Combine OAuth + 2FA methods (High confidence ✅)
2. config/routes.rb: Keep both route sets (High confidence ✅)
3. spec/models/user_spec.rb: Merge test suites (Medium confidence ⚠️)

I'll edit these files, commit with message 'Resolve conflicts: combine auth methods', and push to feature/oauth.

Approve to proceed?

User: Yes, go ahead

Agent: Executing resolution...
✅ Edited app/models/user.rb
✅ Edited config/routes.rb  
✅ Edited spec/models/user_spec.rb
✅ Created commit: abc1234
✅ Pushed to feature/oauth

Done\! Your MR is now mergeable. View commit: https://gitlab.com/.../commit/abc1234

Monolith Integration

  • Add agent definition to ee/lib/ai/foundational_chat_agents_definitions.rb (ID 5)
  • Include global_catalog_id from AI Catalog
  • Create feature flag: config/feature_flags/development/foundational_conflict_resolver_agent.yml
  • Update ee/app/graphql/resolvers/ai/foundational_chat_agents_resolver.rb to filter based on flag

Agent Testing

  • Test agent in AI Catalog interface
  • Verify agent can call all configured tools
  • Test agent actually edits files (not just suggests)
  • Test agent creates commits
  • Test agent pushes to branch
  • Test approval workflow
  • Test error handling (push fails, conflicts remain, etc.)
  • Verify agent respects branch protection

Acceptance Criteria

  • Agent exists in AI Catalog with proper configuration
  • Agent is registered in monolith definitions (ID 5)
  • System prompt emphasizes autonomous execution with approval
  • Agent has required privileges for file editing and git operations
  • Agent successfully resolves conflicts by editing files
  • Agent successfully commits and pushes resolutions
  • Agent asks for approval before executing
  • Agent handles errors gracefully
  • Feature flag exists and defaults to disabled

Safety Considerations

The agent MUST:

  • ✅ Get explicit user approval before executing
  • ✅ Show what will be changed before execution
  • ✅ Handle push failures gracefully
  • ✅ Respect branch protection rules
  • ✅ Never force push
  • ✅ Provide rollback guidance if needed
  • ✅ Log all actions for audit trail

Files Changed

  • Agent configuration in AI Catalog (external)
  • ee/lib/ai/foundational_chat_agents_definitions.rb
  • config/feature_flags/development/foundational_conflict_resolver_agent.yml
  • ee/app/graphql/resolvers/ai/foundational_chat_agents_resolver.rb

Timeline

2-3 days (additional time for autonomous execution logic)

Related to epic &20688

Edited Feb 03, 2026 by Kai Armstrong
Assignee Loading
Time tracking Loading