Skip to content

fix(responses): clear stripped service tier from logs - #1368

Merged
Wibias merged 2 commits into
lidge-jun:devfrom
luvs01:agent/fix-stripped-service-tier-logging
Aug 10, 2026
Merged

fix(responses): clear stripped service tier from logs#1368
Wibias merged 2 commits into
lidge-jun:devfrom
luvs01:agent/fix-stripped-service-tier-logging

Conversation

@luvs01

@luvs01 luvs01 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Clear requestedServiceTier and its speed label after the final provider capability gate strips an unsupported service_tier.
  • Add a live DeepSeek regression proving the upstream body and request-log context agree.
  • Preserve configured-tier provenance and the tri-state behavior for supported and unclassified providers.

The request log captured caller tier metadata before final route normalization. DeepSeek and Volcengine correctly removed the unsupported wire field later, but the earlier log metadata still described the request as Fast/priority.

Verification

  • bun test tests/service-tier-capability.test.ts — 13 passed.
  • bun run typecheck — passed.
  • bun run privacy:scan — passed.
  • git diff --check — passed.
  • Independent two-file review found no diff-introduced P0-P3 issues.
  • The previous exact head completed full GitHub CI successfully; this update only rebases the same patch onto the latest dev.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected request handling for providers that do not support service tiers.
    • Service-tier settings are now consistently removed from outgoing requests and request logs when unsupported.
  • Tests
    • Added regression coverage to verify service-tier data is cleared across the request flow.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 126d5f54-a100-4947-b818-95efbc8ecdb9

📥 Commits

Reviewing files that changed from the base of the PR and between aead7d6 and c444365.

📒 Files selected for processing (1)
  • src/server/responses/core.ts

📝 Walkthrough

Walkthrough

The Responses adapter now clears unsupported service-tier metadata from request logging. A DeepSeek integration test verifies removal from the outbound request and logging context.

Changes

Service-tier capability handling

Layer / File(s) Summary
Clear unsupported service-tier metadata
src/server/responses/core.ts
At lines 991–994, the adapter clears requestedServiceTier and requestedSpeedLabel when the finalized provider does not support service tiers.
Validate outbound and logging cleanup
tests/service-tier-capability.test.ts
The test imports RequestLogContext and verifies that a DeepSeek request removes service_tier from the outbound body and both service-tier fields from the logging context.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • lidge-jun/opencodex#860: This PR extends the Responses service-tier capability handling by clearing unsupported service-tier metadata from request logging.

Suggested reviewers: ingwannu, lidge-jun, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: clearing unsupported service-tier data from request logs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu @Wibias

Wibias commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Please rebase this PR onto the latest dev (e8ce2b93dd3ef8074d96dee407704c5dc06e2699) before merge, then rerun the exact-head CI checks.

@luvs01
luvs01 force-pushed the agent/fix-stripped-service-tier-logging branch from a41938a to a8751d5 Compare August 9, 2026 23:25
@Wibias
Wibias marked this pull request as ready for review August 9, 2026 23:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/service-tier-capability.test.ts`:
- Around line 150-152: Update the test around the outbound request assertions to
first require that bodies[0] is defined, then check that its body does not
contain service_tier. Remove the (bodies[0] ?? {}) fallback so the test cannot
pass without handleResponses capturing a fetch request; preserve the existing
logCtx.requestedServiceTier and requestedSpeedLabel assertions.
🪄 Autofix

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a96af793-9a15-4467-ad70-e3a6f832e248

📥 Commits

Reviewing files that changed from the base of the PR and between d517161 and a8751d5.

📒 Files selected for processing (2)
  • src/server/responses/core.ts
  • tests/service-tier-capability.test.ts

Comment thread tests/service-tier-capability.test.ts Outdated
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] I will review the current PR head.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness gate is complete. I will review the current PR head.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
github-actions Bot marked this pull request as draft August 10, 2026 00:07
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

An unexpected error occurred while generating fixes: Not Found - https://docs.github.com/rest/git/refs#get-a-reference

@luvs01
luvs01 force-pushed the agent/fix-stripped-service-tier-logging branch from a8751d5 to eb5fdfb Compare August 10, 2026 00:32
@Wibias
Wibias marked this pull request as ready for review August 10, 2026 00:39
@github-actions
github-actions Bot marked this pull request as draft August 10, 2026 00:39
@Wibias
Wibias marked this pull request as ready for review August 10, 2026 00:40
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@github-actions[bot] have exceeded the limit for the number of chat messages per hour. Please wait 5 minutes and 42 seconds before sending another message.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@github-actions[bot] have exceeded the limit for the number of chat messages per hour. Please wait 5 minutes and 19 seconds before sending another message.

@luvs01
luvs01 force-pushed the agent/fix-stripped-service-tier-logging branch from eb5fdfb to aead7d6 Compare August 10, 2026 01:11
@github-actions
github-actions Bot marked this pull request as draft August 10, 2026 01:11
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== HEAD and base ancestry =='
git rev-parse HEAD
git merge-base --is-ancestor e8ce2b93dd3ef8074d96dee407704c5dc06e2699 HEAD && echo 'required dev commit is an ancestor of HEAD'
git merge-base HEAD e8ce2b93dd3ef8074d96dee407704c5dc06e2699

echo '== Changed files relative to required dev commit =='
git diff --name-status e8ce2b93dd3ef8074d96dee407704c5dc06e2699...HEAD

echo '== Relevant file outlines =='
ast-grep outline src/server/responses/core.ts --items all --match 'service|tier|request|log' || true
ast-grep outline tests/service-tier-capability.test.ts --items all --match 'service|tier|DeepSeek|request|log' || true

echo '== PR diff =='
git diff --unified=80 e8ce2b93dd3ef8074d96dee407704c5dc06e2699...HEAD -- \
  src/server/responses/core.ts \
  tests/service-tier-capability.test.ts

echo '== Service-tier and request-log references =='
rg -n -C 5 --glob '*.ts' \
  '(requestedServiceTier|requestedSpeed|service_tier|serviceTier|applyServiceTier|supportsServiceTier)' \
  src/server/responses/core.ts tests/service-tier-capability.test.ts

Length of output: 57200


🏁 Script executed:

#!/bin/bash
set -euo pipefail

completed="eb5fdfbea39194a9d64a5e0a4eafa1b0e12bdac8"
head="HEAD"

echo '== SHA existence and relationship =='
git rev-parse "$completed"
git rev-parse "$head"
if git merge-base --is-ancestor "$completed" "$head"; then
  echo 'completed gate SHA is an ancestor of current HEAD'
else
  echo 'completed gate SHA is NOT an ancestor of current HEAD'
fi
if git merge-base --is-ancestor "$head" "$completed"; then
  echo 'current HEAD is an ancestor of completed gate SHA'
else
  echo 'current HEAD is NOT an ancestor of completed gate SHA'
fi

echo '== Commits after completed gate SHA =='
git log --oneline --decorate "$completed..$head"

echo '== Files changed after completed gate SHA =='
git diff --name-status "$completed..$head"

echo '== Current PR metadata =='
gh pr view 1368 --json number,url,headRefName,headRefOid,baseRefName,baseRefOid,isDraft,mergeable,reviewDecision,statusCheckRollup

Length of output: 3680


@github-actions[bot] The readiness gate is stale.

The gate completed at eb5fdfbea39194a9d64a5e0a4eafa1b0e12bdac8. The current PR head is aead7d64cb2dec3c0127cbe3cb647e387fc95850. Neither commit is an ancestor of the other.

GitHub also reports that PR #1368 is still a draft. The CodeRabbit status is pending.

Do not mark this PR ready from the completed gate result. Run the exact-head checks for aead7d64cb2dec3c0127cbe3cb647e387fc95850, then remove the draft state after those checks pass.

You are interacting with an AI system.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/server/responses/core.ts (1)

1714-1731: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Cover Claude main-auth stripping on noncanonical forward routes.

stripClaudeMainAuthForNoncanonicalForward is only set from src/server/claude-messages.ts:735 and tested in tests/service-tier-capability.test.ts, whose cases do not exercise the branch. Add a flat Bun test that injects Claude-origin authorization/chatgpt-account-id, routes through a noncanonical openai-responses forward provider with authMode: "forward", and asserts selectedForwardHeaders no longer contains those internal credentials and Codex runtime fields are removed. Also include a canonical forward route case that keeps its normal authentication path unchanged in the same regression coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/server/responses/core.ts` around lines 1714 - 1731, Add flat Bun
regression coverage for the response flow that sets
stripClaudeMainAuthForNoncanonicalForward, using Claude-origin authorization and
chatgpt-account-id headers with a noncanonical openai-responses forward provider
in authMode "forward"; assert selectedForwardHeaders removes both credentials
and route/adapter Codex runtime fields are cleared. Include a canonical
forward-provider case in the same test that preserves the existing
authentication path.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/server/responses/core.ts`:
- Around line 1714-1731: Add flat Bun regression coverage for the response flow
that sets stripClaudeMainAuthForNoncanonicalForward, using Claude-origin
authorization and chatgpt-account-id headers with a noncanonical
openai-responses forward provider in authMode "forward"; assert
selectedForwardHeaders removes both credentials and route/adapter Codex runtime
fields are cleared. Include a canonical forward-provider case in the same test
that preserves the existing authentication path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9865b677-6b1f-4bc2-bff6-4d1ac10246fc

📥 Commits

Reviewing files that changed from the base of the PR and between a8751d5 and aead7d6.

📒 Files selected for processing (2)
  • src/server/responses/core.ts
  • tests/service-tier-capability.test.ts

@luvs01
luvs01 marked this pull request as ready for review August 10, 2026 01:18
@github-actions
github-actions Bot marked this pull request as draft August 10, 2026 01:21
@luvs01
luvs01 marked this pull request as ready for review August 10, 2026 01:28
@github-actions
github-actions Bot marked this pull request as draft August 10, 2026 01:29
@Wibias
Wibias marked this pull request as ready for review August 10, 2026 02:19
@github-actions
github-actions Bot marked this pull request as draft August 10, 2026 02:19
@Wibias Wibias self-assigned this Aug 10, 2026
@Wibias
Wibias force-pushed the agent/fix-stripped-service-tier-logging branch from aead7d6 to c444365 Compare August 10, 2026 03:12
@github-actions
github-actions Bot marked this pull request as ready for review August 10, 2026 03:14
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

required_dev="e8ce2b93dd3ef8074d96dee407704c5dc06e2699"
gate_head="c444365786b0656ea7bfb30dddad99a39ad22bd9"

echo '== Local head and ancestry =='
current_head="$(git rev-parse HEAD)"
printf 'current HEAD: %s\n' "$current_head"
printf 'gate head: %s\n' "$gate_head"
if git merge-base --is-ancestor "$gate_head" HEAD; then
  echo 'gate head is an ancestor of current HEAD'
else
  echo 'gate head is NOT an ancestor of current HEAD'
fi
if git merge-base --is-ancestor "$required_dev" HEAD; then
  echo 'required dev commit is an ancestor of current HEAD'
else
  echo 'required dev commit is NOT an ancestor of current HEAD'
fi
printf 'merge-base(required dev, HEAD): %s\n' "$(git merge-base "$required_dev" HEAD)"

echo '== Commits and files after gate head =='
git log --oneline "${gate_head}..HEAD" || true
git diff --name-status "${gate_head}..HEAD" || true

echo '== GitHub PR state =='
gh pr view 1368 --json number,url,headRefOid,baseRefOid,baseRefName,isDraft,mergeable,reviewDecision,labels,statusCheckRollup

Length of output: 10067


@github-actions[bot] The readiness gate applies to the exact current head: c444365786b0656ea7bfb30dddad99a39ad22bd9.

The required dev commit, e8ce2b93dd3ef8074d96dee407704c5dc06e2699, is an ancestor of this head.

The PR is not a draft. The PR targets dev. The PR is mergeable. The review-ready label is present.

Do not treat the PR as fully ready yet. GitHub still reports these jobs as IN_PROGRESS:

  • Cross-platform CI: test 1/4 through test 4/4
  • Cross-platform CI: gates
  • Cross-platform CI: macos
  • Cross-platform CI: keyring ubuntu
  • Cross-platform CI: keyring windows
  • Cross-platform CI: npm-global jobs

The CodeRabbit status is also PENDING. Wait for these exact-head checks to complete successfully before merge.

You are interacting with an AI system.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

pr=1368
required_dev='e8ce2b93dd3ef8074d96dee407704c5dc06e2699'
gate_sha='c444365786b0656ea7bfb30dddad99a39ad22bd9'

echo '== GitHub PR metadata =='
gh pr view "$pr" --json \
  number,url,isDraft,headRefName,headRefOid,baseRefName,baseRefOid,mergeable,reviewDecision,labels,statusCheckRollup \
  --jq '{
    number, url, isDraft, headRefName, headRefOid, baseRefName, baseRefOid,
    mergeable, reviewDecision,
    labels: [.labels[].name],
    checks: [.statusCheckRollup[] | {
      name, status, conclusion, workflowName,
      headSha: (.detailsUrl // "")
    }]
  }'

echo
echo '== Local commit relationships =='
head="$(git rev-parse HEAD)"
printf 'local HEAD: %s\n' "$head"
printf 'gate SHA: %s\n' "$gate_sha"
printf 'required dev SHA: %s\n' "$required_dev"

for pair in "gate_to_head:$gate_sha:$head" "dev_to_head:$required_dev:$head"; do
  IFS=: read -r name ancestor descendant <<<"$pair"
  if git merge-base --is-ancestor "$ancestor" "$descendant"; then
    printf '%s: ancestor\n' "$name"
  else
    printf '%s: not-ancestor\n' "$name"
  fi
done

echo
echo '== Commits after gate SHA, if comparable =='
if git merge-base --is-ancestor "$gate_sha" "$head"; then
  git log --oneline "$gate_sha..$head"
elif git merge-base --is-ancestor "$head" "$gate_sha"; then
  git log --oneline "$head..$gate_sha"
else
  echo 'Gate SHA and local HEAD have diverged.'
fi

Length of output: 7536


@github-actions[bot] The gate SHA now matches the current PR head: c444365786b0656ea7bfb30dddad99a39ad22bd9.

The required dev commit e8ce2b93dd3ef8074d96dee407704c5dc06e2699 is an ancestor of this head. The PR is not a draft and has the review-ready label.

However, the exact-head CI checks are still running. These jobs are IN_PROGRESS:

  • test 1/4 through test 4/4
  • gates
  • macos
  • keyring windows
  • npm-global windows-latest

Do not mark the PR as fully ready yet. Wait for these exact-head checks to complete successfully.

You are interacting with an AI system.

@Wibias
Wibias merged commit dc4dd45 into lidge-jun:dev Aug 10, 2026
28 of 29 checks passed

Wibias commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks @luvs01 — merged. 🙌 This is a useful correctness fix: when a provider strips unsupported service_tier, the request log now reflects the request that was actually sent upstream instead of incorrectly reporting Fast/priority. The DeepSeek regression is especially helpful because it locks the wire body and log context together and prevents this mismatch from quietly returning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants