Repository navigation
Open
Labels
Description
Problem
Currently, the strategy / matrix support in gh-aw only applies to custom jobs defined under jobs: in the frontmatter (e.g., the BatchOps pattern). The agent job itself — the core AI execution job — does not support matrix strategy, meaning it always runs as a single instance per workflow run.
This is a limitation for use cases like randomized testing at scale, where you want to dispatch N parallel agent threads with different parameters (random seeds, test configs, shards) and have each agent instance work independently and concurrently.
Use Case
I want to run randomized test campaigns where:
- Multiple agent instances run in parallel as matrix jobs (e.g., 5–10 concurrent threads)
- Each instance receives different matrix parameters (e.g.,
seed,test-suite,scenario) - Each agent independently generates and executes randomized test scenarios using its own AI session
- Results from all parallel agents are aggregated at the end
Today, achieving this requires either:
- Running agents sequentially (slow, defeats the purpose)
- Using
workflow_dispatchfan-out with multiple workflow runs (wasteful, hard to coordinate, hits per-engine concurrency) - Custom jobs with matrix that call back into agent workflows (fragile, not a first-class pattern)
Proposed Solution
Allow strategy on the agent job, either at the top level or under engine:
---
on:
workflow_dispatch:
inputs:
threads:
default: "5"
strategy:
matrix:
thread: [0, 1, 2, 3, 4]
fail-fast: false
max-parallel: 5
engine:
id: copilot
concurrency:
group: "gh-aw-copilot-${{ github.workflow }}-${{ matrix.thread }}"
tools:
bash: ["pytest", "jq"]
---
# Randomized Test Runner — Thread ${{ matrix.thread }}
Run randomized test suite using seed derived from thread index ${{ matrix.thread }}.
Each thread independently selects and executes a random subset of tests.Key requirements:
- Matrix parameters available in markdown body via
${{ matrix.* }}expressions - Per-instance concurrency groups so parallel agent instances don't cancel each other
fail-fast: falsesupport so one failing agent doesn't kill the othersmax-parallelto cap concurrent AI sessions and manage token/API costs
Prior Art
- Issue [plan] Fix or remove unusable strategy schema definition for custom jobs #19402 removed the unusable
strategyschema from custom jobs (was an empty-object-only definition). The BatchOps pattern now shows working matrix on custom jobs, but not on the agent job. - Issue Bug: Per-engine job concurrency blocks workflow_dispatch issue workflows from running in parallel #18101 addressed per-engine concurrency blocking parallel runs.
- The
concurrency.job-discriminatorfeature already solves part of this (fan-out without cancellation), but doesn't provide matrix parameters or parallel agent instances within a single workflow run.
Alternatives Considered
| Approach | Limitation |
|---|---|
workflow_dispatch fan-out (dispatch N separate runs) |
No shared context, hard to aggregate, per-engine concurrency blocks |
job-discriminator with dispatch-ops |
No matrix parameters in the agent prompt |
Custom job with matrix + assign-to-agent safe output |
Fragile, adds a full extra job layer, not first-class |
Activity
kaovilai commentedon May 22, 2026
Note
Responses generated with Claude
Did some research into the compiler internals — this is purely a gh-aw implementation gap, not an API limitation. The
Jobstruct already has aStrategyfield andjobs.goalready renders it. Custom jobs use it today (lines 625-641 ofcompiler_jobs.go). The agent job just never sets it.Files that need changes:
pkg/parser/schemas/main_workflow_schema.json— Addstrategyto top-level properties (currently absent). Needsmatrix,fail-fast,max-parallelsub-fields.pkg/workflow/compiler_types.go— AddStrategy stringtoWorkflowDatastruct (same pattern asContainer,Services,Concurrency).strategy:from frontmatter and marshal to YAML string.pkg/workflow/compiler_main_job.go— AddStrategy: c.indentYAMLLines(data.Strategy, " ")to the agentJobconstruction (currently missing).pkg/workflow/concurrency.go—GenerateJobConcurrencyConfigneeds to incorporatematrix.*variables into the concurrency group when strategy is present, so matrix instances don't cancel each other.Already working (no changes needed):
Job.Strategyfield exists on the structjobs.gorendering handlesjob.StrategyoutputNon-trivial complications:
${{ matrix.* }}expressions in the markdown body need to survive template expansion into the agent promptneeds: [agent]— with matrix, agent becomes N parallel jobs requiring matrix-aware aggregationmax-runs,rate-limit, and per-engine ET budgets when matrix multiplies agent runspelikhan commentedon Oct 7, 2026
Status (2026-10-07; Contributor proposal): The May 22 discussion proposes compiler changes to support
strategy.matrixon the agent job; the issue also calls for matrix values in the prompt and independent concurrency for each agent instance. The next step is to review those requirements against the compiler and agree on a testable design before implementation.pelikhan commentedon Oct 16, 2026
Current-state refresher (2026-10-16): still relevant. On current default-branch snapshot
0d15bd1, the agent job builder configures concurrency, outputs and dependencies but does not assignJob.Strategy. The workflow schema supportsstrategyfor custom jobs, not as a top-level agent-job setting. Existing custom-job matrix support therefore does not satisfy this request.The May 22 discussion remains a useful starting point, but the remaining contract is broader than adding a field: prompt access to matrix parameters, independent per-instance concurrency, artifact/output aggregation across detection and safe-output jobs, and multiplied usage limits all need a defined design. The requested single-run parallel agent matrix has not been established by the current implementation. This assessment is static inspection, not a parallel runtime experiment.
pelikhan commentedon Oct 22, 2026
Relevance check — 2026-10-22: keep open; a single-run matrix of agent jobs is not supported. Checked live remote
mainatffdd9c9efe6a.The current agent job builder still constructs the agent job without
Strategy. The schema exposesjobs.<custom-job>.strategy, not a top-level agent strategy; custom-job matrices therefore do not satisfy this issue. Related compiler matrix proposals #39725 and #39737 are both closed and unmerged, despite their descriptions of matrix-aware job/aggregation work.Next concrete step: define and implement the agent matrix contract end to end: prompt access to matrix values, per-instance concurrency,
fail-fast/max-parallel, collision-free per-instance artifacts and safe-output/detection/conclusion aggregation, plus multiplied run/rate/cost limits. Acceptance should demonstrate N independent agent sessions inside one workflow run and correct aggregation; custom-job fan-out or separate dispatch runs are workarounds, not completion. Static/API review only; no workflow dispatched.