Work Chains

Learn how to batch-execute multiple issues in sequence using work chains -- create chains, use suggestedPrompts for precision execution, track progress, and manage sequential issue resolution.

6 min read
issueswork-chainsbatch-execution

Work chains are CodeCourier’s batch execution system for issues. Instead of running issues one at a time, you can group multiple issues into a work chain and execute them sequentially - each issue is resolved in order, with the next issue starting only after the previous one completes. This is ideal for related fixes that should be applied in a specific sequence, such as a series of security patches or a coordinated set of refactoring tasks.

What are Work Chains?

A work chain is an ordered list of issues linked to a single workflow and execution configuration. When you start a chain, CodeCourier processes each issue sequentially:

  1. The first issue is picked up and a workflow run is launched
  2. The run executes in a sandbox, applying code changes and creating a PR
  3. Once the run completes, the next issue in the chain is processed
  4. This continues until all issues are resolved or a failure occurs

Sequential Execution

Work chains execute issues one at a time in order. This ensures that code changes from earlier issues are committed before later issues begin, preventing merge conflicts and ensuring each fix builds on the previous one.

Work Chains vs. Sprint Chains

Work chains and sprint chains are distinct concepts in CodeCourier, though they share the idea of sequential execution:

Work ChainsSprint Chains
InputIssues (discovered or manual)Workflow runs from a sprint plan
Prompt sourceEach issue’s suggestedPrompt or descriptionSprint-level prompt and planning context
Use caseBatch-fixing discovered bugs or improvementsExecuting a planned multi-feature sprint
PR strategyOne PR per issueConfigurable per sprint

Use work chains when you have a set of discrete, independently-fixable issues to resolve. Use sprint chains when you have a planned sequence of feature builds.

How Prompts are Selected

The prompt passed to each workflow run in a chain is determined by the issue’s suggestedPrompt field. This field is typically populated by the AI Issue Agent during scanning - it contains specific, targeted fix instructions written for that exact issue rather than a generic description.

The resolution order is:

  1. If suggestedPrompt is set and non-empty, it is used as the run prompt. This gives the workflow run precise, AI-crafted instructions tailored to the specific fix required.
  2. If suggestedPrompt is not set, the issue’s description is used as a fallback.

Why suggestedPrompt Matters

Issues discovered by an Issue Session carry a suggestedPrompt that was written by the same AI agent that identified the problem - it knows exactly what needs fixing and how. This is why AI-discovered issues in a work chain tend to produce higher-quality workflow runs than manually created issues with only a description. When creating issues manually for use in work chains, take the time to write a precise suggestedPrompt.

Creating a Work Chain

To create a work chain from the Issues page:

  1. Select the issues you want to include using the checkboxes on the issues list.
  2. Click the Create Work Chain button.
  3. Configure the chain settings:
    • Workflow - Select the workflow blueprint for all issues in the chain
    • GitHub Repository URL (optional) - Target repository for PRs
    • Branch Name (optional) - Base branch for the work
  4. Submit to create the chain. The issues are assigned a workChainId and workChainOrder reflecting their position in the sequence.

Issue Order Matters

Arrange issues in the order you want them resolved. If issue B depends on changes from issue A, make sure issue A comes first in the chain. You can reorder issues during chain creation.

How Execution Works

Once a work chain is started, execution follows this pattern for each issue:

  1. The issue’s suggestedPrompt (or description if no prompt is set) is used as the run prompt.
  2. A workflow run is launched using the chain’s configured workflow, GitHub URL, and branch.
  3. The issue is linked to the run and its status changes to running.
  4. When the run completes, the issue status is updated to completed or failed.
  5. If the run succeeded, the chain advances to the next issue. If it failed, the chain pauses for review.

Chain Status Tracking

Work chains have their own lifecycle status:

StatusDescription
pendingThe chain has been created but execution has not started.
runningOne of the issues in the chain is currently being processed.
completedAll issues in the chain have been resolved successfully.
failedAn issue in the chain failed. The chain is paused at the failed issue.
cancelledThe chain was manually cancelled by the user.

Work Chain Fields

FieldTypeDescription
titlestringDisplay name for the work chain
descriptionstring (optional)Description of the chain’s purpose
issueIdsarray of IDsOrdered list of issues in the chain
workflowIdIDThe workflow blueprint used for all runs
githubRepoUrlstring (optional)Target GitHub repository URL
branchNamestring (optional)Base branch for code changes
statusenumCurrent chain status: pending, running, completed, failed, cancelled

Monitoring Chain Progress

Work chain progress is displayed in real time on the Issues page. You can see:

  • The overall chain status and completion percentage
  • Which issue is currently being processed
  • Individual issue statuses within the chain
  • Links to the workflow runs created for each issue
  • Pull requests generated from completed issues

If an issue in the chain fails, you can review the failure, edit the issue’s suggested prompt, and retry the chain from the failed issue.

Next Steps