Skip to content

fix: MCP manageGateway/queryGateway 工具 envId 绑定失效,导致模型浪费大量轮次#671

Merged
binggg merged 1 commit intomainfrom
automation/attribution-issue-mojcryx3-5bwnmf-mcp-managegateway-querygateway-envid
Apr 29, 2026
Merged

fix: MCP manageGateway/queryGateway 工具 envId 绑定失效,导致模型浪费大量轮次#671
binggg merged 1 commit intomainfrom
automation/attribution-issue-mojcryx3-5bwnmf-mcp-managegateway-querygateway-envid

Conversation

@binggg
Copy link
Copy Markdown
Member

@binggg binggg commented Apr 29, 2026

Attribution issue

  • issueId: issue_mojcryx3_5bwnmf
  • category: tool
  • canonicalTitle: MCP manageGateway/queryGateway 工具 envId 绑定失效,导致模型浪费大量轮次
  • representativeRun: atomic-js-cloudbase-cli-routes-lifecycle/2026-04-29T00-52-22-ysuwfx

Automation summary

  • root_cause: The manageGateway and queryGateway tools used a synchronous ensureGatewayEnvId() function that only checked cloudBaseOptions?.envId directly. When cloudBaseOptions.envId was not set at tool registration time (common when envId is auto-resolved via login state, cache, or env vars), the tools threw "当前网关操作需要已绑定 envId" instead of resolving the envId. Other tools like manageFunctions correctly use the async getEnvId() which auto-resolves from multiple sources (cloudBaseOptions, cached envId, CLOUDBASE_ENV_ID env var, login state, or EnvironmentManager). This mismatch caused the model to waste many turns retrying gateway operations that always failed.
  • changes: In mcp/src/tools/gateway.ts, replaced the synchronous ensureGatewayEnvId() with the async getEnvId() from cloudbase-manager.js. Changed getGatewayEnvId()resolveEnvId() (returns Promise<string>), and updated all 5 call sites to await resolveEnvId(). Updated mcp/src/tools/gateway.test.ts to mock getEnvId with mockGetEnvId.mockResolvedValue("env-test").
  • validation: All 9 gateway unit tests pass. All 10 regression tests (build-skills-repo, build-compat-config, skill-quality-stan

Changed files

  • mcp/src/tools/gateway.test.ts
  • mcp/src/tools/gateway.ts

@binggg
Copy link
Copy Markdown
Member Author

binggg commented Apr 29, 2026

Attribution post-PR evaluation

  • visibility: internal identifiers, run ids, and private links are intentionally omitted
  • attempt: 1
  • eval_scope: primary_only
  • overall: PASSED
  • summary: all planned evaluation cases passed
  • updated_at: 2026-04-29T01:19:35.915Z

Cases

  • [PASSED] — primary — evaluation passed

Copy link
Copy Markdown
Member Author

@binggg binggg left a comment

Choose a reason for hiding this comment

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

OK

@binggg binggg merged commit 2dd7ac3 into main Apr 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant