Skip to content

chore(coding-agent): remove the unused getPiUserAgent helper - #359

Open
liuedcson wants to merge 1 commit into
mainfrom
chore/remove-unused-pi-user-agent
Open

liuedcson wants to merge 1 commit into
mainfrom
chore/remove-unused-pi-user-agent

Conversation

@liuedcson

Copy link
Copy Markdown
Collaborator

What

Deletes packages/coding-agent/src/utils/pi-user-agent.ts, its test, and the re-export at packages/coding-agent/src/index.ts.

Why

The repo carries two different getPiUserAgent functions with the same name and different output:

Location Output
packages/coding-agent/src/utils/pi-user-agent.ts stepcode/0.84.4 (darwin; node/v24.21.0; arm64)
packages/providers/src/utils/pi-user-agent.ts stepcode (darwin 25.5.0; arm64)

Only the second one is ever sent over the wire. Every adapter builds its User-Agent from it:

  • packages/providers/src/api/openai-completions.ts:749
  • packages/providers/src/api/openai-responses.ts:219
  • packages/providers/src/api/anthropic-messages.ts:232

The coding-agent one is called by nothing but its own test:

$ grep -rn "getPiUserAgent" --include=*.ts apps/ packages/ | grep -v node_modules | grep -v /dist/
packages/coding-agent/test/step-user-agent.test.ts:2   ← only caller
packages/coding-agent/src/utils/pi-user-agent.ts:1
packages/coding-agent/src/index.ts:930                 ← re-export
packages/providers/src/utils/pi-user-agent.ts:17
packages/providers/src/api/openai-responses.ts:22,219
packages/providers/src/api/anthropic-messages.ts:36,232
packages/providers/src/api/openai-completions.ts:44,749

Both were touched in the same commit to align branding (943e624b fix: brand the user agent as stepcode), but their formats were never unified — that commit only changed step → stepcode in both.

The result is a trap: the dead function is the one exported from the public package entry, so it reads as the canonical helper. A reader looking for "the user agent" finds two candidates and no signal about which one the product actually sends. Removing the dead one is cheaper than documenting the distinction.

Safety

  • packages/coding-agent/package.json is "private": true — nothing is published to npm, so no external consumer loses an export.
  • check:coding-agent-entry-freeze screens bin keys and exports subpaths; neither changes here. It passed.
  • No production code imported it, so no call sites need updating.

Verification

pnpm check                          ✅ all pre-commit checks passed
tsgo --noEmit                       ✅ exit 0
biome check                         ✅ clean
coding-agent tests                  5372 passed | 59 skipped

The 6 failing tests are pre-existing and unrelated to this change — they live in completion-check-cli.test.ts (offline-provider CLI dispatch) and fail identically on main. A baseline run before this branch showed 8 failures (adding footer-data-provider reftable timing and subagent-invocation), so this branch introduces none and the flaky pair merely did not reproduce.

`packages/coding-agent/src/utils/pi-user-agent.ts` formatted
`stepcode/<version> (<platform>; <runtime>; <arch>)`, and
`packages/providers/src/utils/pi-user-agent.ts` formats
`stepcode (<platform> <os-release>; <arch>)`. Only the second one is ever sent:
every adapter under `packages/providers/src/api/` builds its `User-Agent` from
it, and the first is called by nothing but its own test.

It stays reachable through the package entry, though, so a reader looking for
"the user agent helper" finds two functions with the same name, different
formats, and no indication which one the product actually uses. Remove the dead
one rather than document the trap.

`packages/coding-agent/package.json` is private, so no published package loses
an export. `check:coding-agent-entry-freeze` screens `bin` keys and `exports`
subpaths, neither of which changes here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant