fix: bill Step Plan search_web to the plan endpoint - #177
Merged
Merged
Conversation
Step Plan logins sent `search_web` to `https://api.stepfun.com/v1/mcp/web_search/mcp`, the open-platform path, which charges a pay-as-you-go API account instead of the Step Plan credit pool. The credential itself resolved correctly, so the search succeeded and the charge landed on the wrong account without any error. - Give each login profile its own endpoint: `step_plan` and `step_plan_oversea` use `/step_plan/v1/mcp/web_search/mcp`, `platform_cn` and `platform_oversea` keep `/v1/mcp/web_search/mcp`. The table is a `Record<StepLoginProfileId, string>`, so a new profile is a compile error instead of silently inheriting another account's billing path. - An origin-only `STEPCODE_SEARCH_WEB_MCP_URL` now inherits the profile's path instead of a hardcoded `/v1`. That was the same bug by a second route: redirecting only the host moved a plan login onto the platform path. - Credentials with no profile (`--api-key`, `STEPCODE_SEARCH_API_KEY`, a hand-written `auth.json`) stay on the platform endpoint. A plan credential cannot reach that branch: it only comes from `/login`, which always records a profile, and a plan login from before profiles existed still resolves through the legacy `step` mapping in `readStepLoginProfile`. - Search failures now name the endpoint that was used, so a profile/endpoint mismatch surfaces in the error instead of on a bill. Checked with a mainland Step Plan key: the `initialize` handshake (which bills nothing) returns HTTP 402 `quota_exceeded` on `/v1` and HTTP 200 on `/step_plan/v1`, and an end-to-end `search_web` call now goes to `/step_plan/v1` and returns results.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A Step Plan login sent
search_webtohttps://api.stepfun.com/v1/mcp/web_search/mcp— the open-platform path, which charges a pay-as-you-go API account instead of the
Step Plan credit pool. The credential resolved correctly, so the search succeeded and
the charge silently landed on the wrong account.
step_plan_overseahad the sameproblem on
api.stepfun.ai.Fix
step_plan/step_plan_overseause/step_plan/v1/mcp/web_search/mcp,platform_cn/platform_overseakeep/v1/mcp/web_search/mcp. The table is aRecord<StepLoginProfileId, string>, soadding a profile is a compile error rather than a silent inheritance of another
account's billing path.
STEPCODE_SEARCH_WEB_MCP_URLnow inherits the profile's pathinstead of a hardcoded
/v1— the same bug by a second route.--api-key,STEPCODE_SEARCH_API_KEY, a hand-writtenauth.json) stay on the platform endpoint. A plan credential cannot reach thatbranch: it only comes from
/login, which always records a profile, and apre-profile plan login still resolves through the legacy
stepmapping inreadStepLoginProfile.shows up in the error instead of on a bill.
Verification
With a real mainland Step Plan key, using the free
initializehandshake (no searchis billed):
https://api.stepfun.com/v1/mcp/web_search/mcp→ HTTP 402quota_exceededhttps://api.stepfun.com/step_plan/v1/mcp/web_search/mcp→ HTTP 200profile: "step_plan"inauth.json, the resolver picks the/step_plan/v1endpoint and a real
search_webcall returns results through it.npm run checkpasses.packages/coding-agent/test/step-search-web.test.tscovers allfour profiles, the legacy
stepprofile, the profile-less fallback and the origin-onlyoverride.