build agent shows 0% completion across 133 invocations — legacy agent name leaking into telemetry
Problem
Telemetry from 2026-05-21 (memory/telemetry-analysis-2026-05-21.md, 2,503 machines, 14 days) shows agent_outcome events with agent: "build" reporting 0% completion across 133 invocations. This appears in the P0 triage as a possible routing/aliasing bug.
Root cause
The build agent was renamed to builder at some point. Agent.get() in packages/opencode/src/agent/agent.ts:408 has an alias so Agent.get("build") returns the builder agent — but the telemetry event in packages/opencode/src/session/prompt.ts:1153 records the literal sessionAgentName value, which comes from lastUser.agent. Two places still write "build" instead of the canonical "builder":
packages/opencode/src/tool/plan.ts:56— when a user exits plan mode viaplan_exit, the synthetic user message it creates hardcodesagent: "build". Every plan-exit invocation in the 14-day window funnelled into the phantombuildbucket. This is the dominant source.- Persisted sessions created before the rename may still carry
agent: "build"in their stored state.
The actual execution works fine (via the alias). The "0% completion" reading is a measurement artifact: the dashboard bucket is named after a defunct agent that nothing actively succeeds against. Real builder completion is recorded under the correct name.
Fix
Three changes:
tool/plan.ts:56— writeagent: "builder"(the current canonical name)session/prompt.ts:1153— normalizeagentat the telemetry-emit boundary: ifsessionAgentName === "build", emit"builder". Belt-and-suspenders for any persisted-session that still references the old name.cli/cmd/github.ts:954— update stale comment that referenced the old fallback name.
Expected telemetry impact
The phantom build bucket disappears. Plan-exit invocations now fold into builder's real completion rate. The "0% completion" reading vanishes.