Skip to content

fix(coding-agent): restore the first-party x-session-id attribution - #383

Merged
liuedcson merged 1 commit into
mainfrom
fix/restore-first-party-x-session-id
Dec 2, 2026
Merged

liuedcson merged 1 commit into
mainfrom
fix/restore-first-party-x-session-id

Conversation

@liuedcson

Copy link
Copy Markdown
Collaborator

Why

Requests to Step's own hosts (https://api.stepfun.com, https://api.stepfun.ai) stopped carrying the session id as x-session-id. The session id fell back to the allowlisted x-step-session-id name, so a first-party request no longer identified its session at all, and every host used a name the product no longer documents.

This is a regression from #370 (01adb40e), not an intentional change.

How it happened

01adb40e was cut from 4701f964, which already contained #368 (d4138803). Its first commit 47ed3be3 nevertheless replaced four files with byte-identical copies of their pre-#368 state:

File Blob written by #370 Blob at d4138803^
packages/coding-agent/src/step/trace-headers.ts 23468cd8 23468cd8
packages/coding-agent/src/features/step.ts e684f6c8 e684f6c8
packages/coding-agent/test/step-extension.test.ts b2d98339 b2d98339
packages/coding-agent/test/step-trace-headers.test.ts 7710b4f7 7710b4f7

Those are #368's four files and nothing else, inside a 45-file config-schema commit, and #370's description never mentions trace headers. Deleting the implementation together with its 49 lines of tests in one commit is why no check failed: there was no assertion left to fail.

Because the names exist only inside coding-agent, nothing broke at compile time either.

What

Restore #368 as merged, on top of the client-identity work that landed later:

  1. STEP_FIRST_PARTY_TRACE_HOSTS and isStepFirstPartyTraceUrl in packages/coding-agent/src/step/trace-headers.ts: https only, exact hostname match, so api.stepfun.com.example, api.stepfun.com@evil.example, and other.stepfun.com do not match.
  2. The unconditional first-party send. A request to a first-party host carries x-session-id independently of the allowlist and field policy — first-party attribution, not third-party egress. Every other field stays gated, and an empty or omitted field list still sends none of them.
  3. One name on every path. The allowlisted session-id path emits x-session-id too, so a host that is both first-party and allowlisted gets one header, not two.
  4. Tests. test/step-trace-headers.test.ts covers the three first-party URLs, a non-matching host, an absent session id, the https-only and userinfo cases, and the allowlisted overlap. test/step-extension.test.ts asserts the extension boundary sends x-session-id to the native Step endpoint and to an allowlisted product proxy.

The provider-header comment now describes URL-host keying instead of provider-id keying, and the queue test's placeholder header uses the current name.

Validation

  • pnpm run check passes (biome, tsgo --noEmit, layer/boundary/entry-freeze guards, check:config-schema, check:browser-smoke).
  • pnpm exec vitest --run test/step-trace-headers.test.ts test/step-extension.test.ts test/step-model-queue.test.ts from packages/coding-agent: 101 passed.
  • The restored test set fails against current main and passes here; isStepFirstPartyTraceUrl is asserted directly as well as through applyStepTraceHeaders.

Boundary

This restores behavior that github-opensource and the desktop branch already ship, so the trees agree again after this lands. No new header name is introduced and the client pair (x-step-client, x-step-client-version) is unchanged.

Requests to https://api.stepfun.com and https://api.stepfun.ai stopped carrying
the session id as x-session-id, and the session id fell back to the allowlisted
`x-step-session-id` name on every host.

That is a regression from #370 (01adb40): the config-schema branch replaced
`trace-headers.ts`, `features/step.ts`, and the two tests with byte-identical
copies of their pre-#368 state, while the branch was cut from a commit that
already contained #368. Deleting the implementation and its tests in the same
commit is why no check failed.

Restore #368 as it was merged, on top of the client-identity work that landed
later: `STEP_FIRST_PARTY_TRACE_HOSTS`, `isStepFirstPartyTraceUrl`, the
unconditional first-party `x-session-id`, and the single vendor-neutral name on
the allowlisted path. The tests cover the first-party hosts, the non-matching
hosts, an absent session id, and the allowlisted overlap.

The provider-header comment and the queue test's placeholder header name now
use the same `x-session-id` name the product actually sends.
@liuedcson
liuedcson merged commit 8ea3c76 into main Dec 2, 2026
2 checks passed
@liuedcson
liuedcson deleted the fix/restore-first-party-x-session-id branch December 2, 2026 07:18
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