Repository navigation
Agent Factory Controls
Model routing, capability-based GitHub API resolution, base-currency merge refusal and squash-subject normalisation in the JNode agent factory.
The agent issue pipeline (.github/scripts/) has two kinds of control surface that change independently of the ticket state machine:
- Model routing — which model runs the coding, review and triage roles, and at what reasoning-effort variant.
- Merge controls — how the factory talks to the GitHub API, refuses to merge a branch that is behind its base, and builds the squash-merge subject.
These were hardened in the 2026-11 round. The design rule is to keep the edit surface in one place (.github/scripts/model-config.js) and to resolve GitHub API routes by capability rather than by an assumed client shape.
| File / Function | Role |
|---|---|
.github/scripts/model-config.js |
ROLE_MODELS, MODEL_VARIANTS, DEFAULT_VARIANT, modelFor(), resolveModel(), allowedModels()
|
.github/scripts/orchestrator-helpers.js |
compareHeadToBase(), checkBaseCurrency(), baseCurrencyComment(), stripTitleDecorations(), mergeSubject()
|
.github/scripts/ticket-runner.js |
Per-ticket DEV/REVIEW loop; base-currency check before MERGE |
.github/scripts/orchestrator.js |
CI-gated auto-merge and human-approval path; same guard |
.github/scripts/tests/orchestrator-helpers.test.js |
Route-shape, base-currency and subject tests |
.opencode/skills/jnode-issue-resolver/SKILL.md |
Commit-subject hygiene rule |
ROLE_MODELS is the only place a role's model is named:
const ROLE_MODELS = {
coding: "opencode/beam-free",
review: "opencode/deepseek-v4.1-flash-free",
triage: "opencode/deepseek-v4.1-flash-free"
};From 2026-11-20:
-
coding moved to
beam-free, a coding-focused 501B sparse MoE (23B active, 1M context, effort ladder tomax). It replacedinkling-2-small-freeonly because the provider deprecated Inkling and the endpoint began answering "Model unavailable", which broke every DEV and/oc fixrun. Beam was chosen over the other active free models on status, coding/agentic positioning, structured output and the fastest multi-file tool-use probe. -
review stays on
deepseek-v4.1-flash-free, the known-good fallback. The independence the review slot exists for is preserved: Beam writes, DeepSeek checks. - triage is also DeepSeek, so review and triage are the same model. The reviewer is still independent of the writer, but no longer a third family independent of the triager.
MODEL_VARIANTS records the effort each model wants. Only models whose preference differs from DEFAULT_VARIANT ("high") are listed:
const MODEL_VARIANTS = {
"opencode/beam-free": "max",
"opencode/deepseek-v4.1-flash-free": "max"
};An unlisted model keeps the default rather than failing on a typo. A per-run <!-- MODEL: ... --> override is accepted only for allowedModels(); it lets a reviewer post a review on another known model when DeepSeek is quota-blocked, without editing the file.
resolveModel(body) picks review on /^\s*\/oc\s+review\b/, otherwise coding. triage.yml asks for triage by name. The workflow contains a default OPENCODE_MODEL, but the selected role model is exported into the job environment at run time.
checkBaseCurrency(prNumber) needs to compare a PR head with the current base tip. The GitHub client exposes the same operation under different names depending on the SDK generation:
github.rest.repos.comparegithub.rest.repos.compareCommits
compareHeadToBase(headSha, baseRef) probes typeof ... === "function" at call time, tries the available names in order, logs the chosen one, and finally falls back to a raw request:
github.request({
method: "GET",
url: "/repos/" + owner + "/" + repo + "/compare/" + headSha + "..." + baseRef
});The previous code called github.rest.repos.compare directly. That method was absent on the runner (is not a function), so every current branch was refused fail-closed. The unit tests had mocked the same assumed name, masking the mismatch. Route tests now model a runtime with only one spelling, the URL fallback, and an unreadable fallback.
checkBaseCurrency(prNumber) fetches the PR, its base.ref/head.sha, and the current base tip, then calls compareHeadToBase with headSha...baseRef. It returns:
{ current, base, lag, total }-
currentis true when the merge-base commit equals the base tip. -
lagis a list of{ sha, subject }for commits on the base that are not on the head. It is capped at the compare page size (250); a synthetic{ sha: "", subject: "... and N more" }covers the remainder. -
totalistotal_commitsand is the count to report, notlag.length. - Failure to read the PR, base, merge-base or compare returns
{ current: false, base: "", lag: [] }(fail-closed).
Refusal points:
-
ticket-runner.jschecks before the MERGE phase, including under--force. It recordsmerge_refused_base_stale, resets retries, returns the ticket to REVIEW and comments with the"human"remedy. -
orchestrator.jschecks only when CI is green. A stale auto-merge routes toHUMAN_REVIEWwith the"auto"remedy. - The human-approval path also checks; a stale branch returns to REVIEW and comments with the human remedy.
--force deliberately does not bypass the guard. The documented escape is GitHub's own merge button. baseCurrencyComment names up to 11 lag commits and varies the remedy for review, human and auto entries; an empty lag renders "base branch state could not be read".
mergeSubject(pr) builds #<issue> - <clean title> (#<PR>). It delegates to stripTitleDecorations(title, num, prNumber), which repeats until stable:
- strips a leading
#<digits>plus optional-,:, en-dash or whitespace - removes a trailing
(<n> chars)/(<n> char)(case-insensitive) - removes a trailing
(#<n>)only when<n>equals the resolved issue or PR number
Issue precedence is closingIssueNumber(body) → issueFromHeadRef(opencode/issueN-) → issueFromTitle(title). issueFromTitle accepts the same separators after the number.
Example: #963: FAT dirty-set flush; tests green (37 chars) becomes #963 - FAT dirty-set flush; tests green (#964).
mergeSubject cannot remove arbitrary status phrases. That is why the resolver skill separately forbids them (below).
The jnode-issue-resolver skill requires the commit subject to stay under 72 characters including the #<issue> - prefix, and forbids:
- the character count (
(37 chars)) - test status (
tests green,tests pass,all pass,N/N tests,PR pending)
Verification belongs in the PR body. The issue number must not be repeated after the #<N> - prefix. This keeps the squash subject a description of the change rather than a status report.
| Role | Model | Effort | Independence |
|---|---|---|---|
coding (DEV//oc fix) |
opencode/beam-free |
max |
writes the change |
review (/oc review) |
opencode/deepseek-v4.1-flash-free |
max |
different model from the writer |
triage |
opencode/deepseek-v4.1-flash-free |
max |
same model as review |
A model switch is a map edit plus a comment; it is not a workflow edit. The per-run override can only choose a model already accepted by allowedModels(), which keeps an experiment from silently disabling the independent-review guarantee.
A trigger comment may carry an HTML marker:
<!-- MODEL: opencode/beam-free -->resolveModel(body) still selects the role, then the override is accepted only if the requested model is in allowedModels(). An unknown or disallowed model is ignored in favour of the role default, so a typo cannot take the pipeline down. The override is recorded in the run's Assisted-by: trailer.
| Date | Coding | Review | Note |
|---|---|---|---|
| before 2026-11-06 | DeepSeek | DeepSeek | known-good fallback |
| 2026-11-06 | crouton | DeepSeek | first JFAT batch |
| 2026-11-09 | Inkling | DeepSeek | second JFAT round; review/triage same model |
| 2026-11-20 | Beam | DeepSeek | Inkling deprecated (Model unavailable); Beam is coding-focused |
crouton-alpha-free and inkling-2-small-free are no longer in MODEL_VARIANTS; an override naming them is rejected by allowedModels().
PR opened / updated
→ CI green
→ checkBaseCurrency(pr)
→ compareHeadToBase(head, base)
→ repos.compare | repos.compareCommits | GET /compare/
→ current? ──no──→ record merge_refused_base_stale, back to REVIEW/HUMAN_REVIEW
│yes
↓
→ verdict approve + diff budget + CI gate
→ mergePR()
→ mergeSubject(pr) → commit_title
→ squash merge (204 / empty body tolerated)
→ re-fetch PR, require merged === true
→ delete head branch (best effort)
The order matters: the base check runs before the merge call, so a stale branch never produces a merge commit that later needs to be replayed.
| Test area | Focus |
|---|---|
orchestrator-helpers.test.js compare route |
only repos.compare, only repos.compareCommits, raw URL fallback, unreadable fallback |
orchestrator-helpers.test.js base currency |
current head, behind base, pagination, fail-closed on unreadable PR/base |
orchestrator-helpers.test.js subject |
duplicate #N prefix, (37 chars) suffix, trailing (#PR), issue precedence |
ticket-runner.test.js |
refusal before MERGE, --force does not bypass, history event |
orchestrator.test.js |
auto-merge refusal and human-approval path |
Run the suite with node --test .github/scripts/tests/*.test.js (347 cases).
- Mocking the convenience API can hide a production failure. The compare-route tests must exercise the actual runtime client shape, including the raw URL fallback.
-
Fail-closed has no
total. History may recordundefinedandticket-runnermay loglag.length(possibly zero) rather than the true count. -
Compare paginates at 250. Use
total_commitsfor counters, not the synthetic lag entry. -
--forceis not a base-currency override. Only the GitHub UI merge button is. - Review and triage are the same model. Independence is preserved against the writer, not against the triager.
- A deprecated coding model breaks every DEV turn. Inkling was retired because the provider answered "Model unavailable"; the role model must be a model the provider still serves, not merely one that passed a probe earlier.
-
DeepSeek quota is a single point of failure for review; the per-run
<!-- MODEL: -->override is the escape hatch. -
mergeSubjectonly strips numeric decorations. A status phrase in the PR title survives into the squash subject unless the author removes it. - GitHub usually dismisses approvals after a branch update. The human remedy says to approve again.
- Agent-Issue-Pipeline — parent pipeline: phases, state, labels, recovery
- GitHub-Actions-Workflows — workflow wiring and model pins
- Code-Conventions — commit message trailers and subject conventions
-
Testing —
node:testsuites for the factory helpers