Skip to content

build agent shows 0% completion across 133 invocations — legacy agent name leaking into telemetry #832

Description

@anandgupta42

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":

  1. packages/opencode/src/tool/plan.ts:56 — when a user exits plan mode via plan_exit, the synthetic user message it creates hardcodes agent: "build". Every plan-exit invocation in the 14-day window funnelled into the phantom build bucket. This is the dominant source.
  2. 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:

  1. tool/plan.ts:56 — write agent: "builder" (the current canonical name)
  2. session/prompt.ts:1153 — normalize agent at the telemetry-emit boundary: if sessionAgentName === "build", emit "builder". Belt-and-suspenders for any persisted-session that still references the old name.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions