tinyhumansai/openhuman · error · SpecError

branch id segment "${m[1]}" does not match agent id "${agent

Error message

branch id segment "${m[1]}" does not match agent id "${agent.id}"

What it means

After BRANCH_RE matches, capture group 1 (the id segment of the branch) must equal the agent's id field exactly. This keeps branch names self-describing so tooling can map a checked-out branch back to its agent without a lookup table. The mismatched pair is printed as "<branchSegment> vs <agentId>" with path "agents[i].branch" — note the path is .branch, not .id, because the branch is considered the wrong side.

Source

Thrown at scripts/agent-batch/lib.mjs:124

    if (!Number.isInteger(agent.issue) || agent.issue <= 0) {
      throw new SpecError("issue must be a positive integer", `${at}.issue`);
    }
    if (seenIssue.has(agent.issue)) {
      throw new SpecError(`duplicate issue #${agent.issue}`, `${at}.issue`);
    }
    seenIssue.add(agent.issue);
    if (typeof agent.title !== "string" || agent.title.trim().length === 0) {
      throw new SpecError("title must be a non-empty string", `${at}.title`);
    }
    const m = BRANCH_RE.exec(agent.branch);
    if (!m) {
      throw new SpecError(
        `branch must match cursor/<id>-<issue>-<slug> (got "${agent.branch}")`,
        `${at}.branch`,
      );
    }
    if (m[1] !== agent.id) {
      throw new SpecError(
        `branch id segment "${m[1]}" does not match agent id "${agent.id}"`,
        `${at}.branch`,
      );
    }
    if (Number(m[2]) !== agent.issue) {
      throw new SpecError(
        `branch issue segment "${m[2]}" does not match agent issue ${agent.issue}`,
        `${at}.branch`,
      );
    }
    if (seenBranch.has(agent.branch)) {
      throw new SpecError(`duplicate branch "${agent.branch}"`, `${at}.branch`);
    }
    seenBranch.add(agent.branch);
    if (!Array.isArray(agent.owned_paths) || agent.owned_paths.length === 0) {
      throw new SpecError(
        "owned_paths must be a non-empty array",
        `${at}.owned_paths`,

View on GitHub (pinned to a221052e0d)

Solutions

  1. Edit the branch's id segment to equal the agent's id: cursor/a02-... → cursor/a01-...
  2. Alternatively fix the agent's id if the branch was the correct one
  3. Derive branches programmatically: `cursor/${a.id}-${a.issue}-${slugify(a.title)}` so they can never drift

Example fix

// before
{ "id": "a01", "issue": 5312, "branch": "cursor/a02-5312-fix-ci-timeout" }

// after
{ "id": "a01", "issue": 5312, "branch": "cursor/a01-5312-fix-ci-timeout" }
Defensive patterns

Strategy: validation

Validate before calling

import { BRANCH_RE } from "./scripts/agent-batch/lib.mjs";
for (const [i, a] of spec.agents.entries()) {
  const m = BRANCH_RE.exec(a.branch);
  if (!m || m[1] !== a.id) console.error(`agents[${i}].branch id segment must equal agent.id`);
}

Try / catch

try {
  validateSpec(spec);
} catch (e) {
  if (e instanceof SpecError && /branch id segment/.test(e.message)) {
    console.error(`regenerate the branch from the agent fields: ${e.message}`);
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Agent {"id": "a01", "branch": "cursor/a02-5313-fix-ci"} — branch cut from another agent's template without updating the id segment; renumbering ids (e.g. a1 → a01, error 188 fix) without regenerating branches.

Common situations: Duplicating an agent entry and updating id but not branch, or vice versa; inserting a new agent at the top and shifting ids without touching branch strings.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16). Data as JSON: /api/errors/f3e69272827a5e64. Report an issue: GitHub.