fix: [#832] build agent 0% completion — legacy name leaking into telemetry
What does this PR do?
Fixes the phantom agent: "build" 0%-completion bucket flagged in the May 21 telemetry triage (133 invocations, 0/133 completed).
It's not a routing bug. The build agent was renamed to builder and Agent.get("build") aliases through to it, so execution works. But two places still write the literal "build" to user messages, which then flows verbatim into the agent_outcome telemetry event — creating a phantom dashboard row with no completions to its name. Real builder work is recorded correctly under the builder bucket.
The dominant source is plan_exit: every time a user approves a plan and exits plan mode, the synthetic user message hardcodes agent: "build". 133 plan-exits in 14 days, all funnelled into the wrong bucket.
Three fixes:
tool/plan.ts:56writesagent: "builder"instead of"build"session/prompt.ts:1153normalizes at the telemetry-emit boundary —agent === "build" ? "builder" : agent— belt-and-suspenders for persisted sessions still carrying the legacy valuecli/cmd/github.ts:954updates a stale comment
Type of change
- Bug fix (non-breaking change which fixes an issue)
Issue for this PR
Closes #832
How did you verify your code works?
tsgo --noEmit: passbun test test/session/plan-layer-e2e.test.ts test/telemetry/plan-skill-telemetry.test.ts test/altimate/plan-refinement.test.ts: 95 pass / 0 failbun test test/altimate/ test/agent/ test/tool/: 3,242 pass / 0 fail (1 unrelated flake — registry.test.ts timeout under parallel load; passes in isolation)- Updated
test/session/plan-layer-e2e.test.tsto allow both the normalized and original forms in the agent_outcome block, and pinned that"builder"appears so the normalization isn't accidentally removed - Marker check: pass —
altimate_changemarkers added on every changed line in upstream-shared files
Checklist
- My code follows the project's code style
- I have performed a self-review of my own code
- My changes generate no new warnings
- I have added tests that prove my fix is effective
- New and existing unit tests pass locally with my changes
- Marker check passes
- Linked to issue #832
Files changed (4):
packages/opencode/src/tool/plan.ts— write canonical "builder" + title/output text updatepackages/opencode/src/session/prompt.ts— normalize agent at emit boundarypackages/opencode/src/cli/cmd/github.ts— fix stale "build" commentpackages/opencode/test/session/plan-layer-e2e.test.ts— update assertion to allow normalized form
Expected telemetry impact: the phantom agent: "build" 0%-completion row disappears. Plan-exit invocations fold back into builder's real completion rate.
Related P0 series:
- Issue #827 / PR #828: finops_* 100% failure rate
- Issue #830 / PR #831: project_scan 32% errors (437 users)
- Issue #832 / this PR: build agent 0% completion measurement artifact
P0-3 in the May 21 triage (classifier 100% empty) was investigated and determined to be a telemetry-analysis schema mismatch (the analyst queried task_type/complexity fields that don't exist in the schema; the actual intent/confidence fields are populated correctly). No code change needed.
P0-5 (PII masker shredding error messages to ?) was addressed structurally by #831 — fixing the root cause (project_scan crashing) eliminated the dominant case where the masker was hiding diagnostic info. A broader masker change would risk leaking actual PII; leaving as-is.
Summary by cubic
Canonicalizes the agent name to builder and normalizes it (case-insensitive) at telemetry emit time to remove the phantom 0% build bucket. Closes #832.
- Bug Fixes
tool/plan.ts: writeagent: "builder"and update dialog/title/output to say “builder”.session/prompt.ts: addnormalizeAgentName()(case-insensitive) and use it insession_startandagent_outcome.cli/cmd/tui/routes/session/index.tsx: setlocal.agentto"builder"onplan_exit.config/config.ts: updatedefault_agentfallback description tobuilder.- Tests: anchored checks for the shared normalizer,
session_startparity, single-normalizer invariant, and case-folding.
Summary by CodeRabbit
-
Bug Fixes
- Unified agent naming from "build" to "builder" in UI text and messaging to ensure consistent messaging and telemetry
- Updated plan-exit messaging to reference "builder agent"
-
Tests
- Expanded end-to-end tests to validate normalized agent reporting and telemetry routing
-
Chores
- Added normalization for legacy agent names and updated schema description to reflect the new default agent name