Skip to content

feat(executor): region-qualified model prefixes and -auto/ qualifier - #311

Merged
caigee-cmd merged 5 commits into
caigee-cmd:mainfrom
favoroo:feat/executor-region-prefix
Oct 19, 2026
Merged

caigee-cmd merged 5 commits into
caigee-cmd:mainfrom
favoroo:feat/executor-region-prefix

Conversation

@favoroo

@favoroo favoroo commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds explicit region control over model-name prefixes for multi-region providers (WorkBuddy, Qoder).

  • workbuddy-cn/model / workbuddy-gl/model route to CN or Global accounts.
  • A bare provider prefix (qoder/…, workbuddy/…) is unchanged: no region is pinned and the pool auto-picks across regions, so international-only deployments keep working.
  • New -auto/ qualifier (qoder-auto/…, workbuddy-auto/…): kept as an explicit spelling of the bare-prefix behavior (provider pinned, region auto-picked, session-affinity latch reused). Chosen over deleting it so users can write the intent explicitly; it is documented as equivalent to the bare prefix.
  • Threads the model-name region through the route loop (WithRegionFilter), overriding key-grant and pin-derived regions while still enforcing both filters independently.

Review follow-ups (2026-10-19)

  • Dropped the bare-prefix-defaults-to-CN commit (defaultRegionForProvider is gone); bare prefix and -auto/ are now equivalent.
  • compat_test.go, s01_protocol_contract_test.go, regression_test.go expectations are back to their original form.
  • New tests: TestPickRouteBarePrefixMatchesGlobalOnlyPool (a global-only pool still routes a bare qoder/model; an explicit -cn/ pin does not match it) and TestPrepareBarePrefixSetsNoRegionFilter.
  • Changelog fragment reworded accordingly; rebased onto latest main.

Tests

  • go build ./..., go vet ./..., go test ./..., git diff --check
  • Executor prepare/route and API contract tests updated.

@caigee-cmd caigee-cmd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

感谢提交!显式区域前缀(workbuddy-cn/、workbuddy-gl/)以及 -auto/ 这个思路很好,把区域贯穿到路由循环(WithRegionFilter)、同时仍分别校验 key 授权和区域这一点也处理得很清楚。

合并前需要调整的核心问题:

  1. 不带区域的前缀(qoder/、workbuddy/)不能默认锁定为 cn。很多用户只有国际账号,合并后他们现有的 qoder/xxx 和 workbuddy/xxx 请求会直接找不到可用账号,属于破坏性变更。请保持不带区域的前缀行为不变,继续自动选区;-cn/ 和 -gl/ 只作为可选的显式限定。具体来说就是去掉 defaultRegionForProvider,或者让它默认为空。
  2. 这样一来 -auto/ 和不带区域的前缀行为一致。可以保留它作为显式写法,也可以删掉以减少概念,两种都可以接受,请在 PR 描述里说明你的选择。
  3. 请把 compat_test.go、s01_protocol_contract_test.go、regression_test.go 中因默认 cn 而改动的预期恢复原样,并补一个用例:只有国际账号时,qoder/model 仍能路由成功。
  4. 请同步更新 changelog 片段中关于默认 cn 的描述,并 rebase 到最新 main。

改完后 @ 我一下即可,谢谢!

…/, workbuddy-gl/)

- ResolveProviderFilter now returns (provider, region); the parsed region is
  applied as a region filter on the request context
- ProviderPrefix recognizes dash-suffixed region qualifiers; NormalizeRegion
  maps the shorthand "gl" to global
- changelog fragment (bilingual)
…egion

A bare provider prefix (qoder/, workbuddy/) now defaults to the CN region,
so a client that wants cross-region load spreading within one provider had
no way to say it. The new -auto/ form (qoder-auto/…, workbuddy-auto/…)
pins the provider family while keeping the region unqualified, which
triggers the pool's automatic region selection and reuses its
session-affinity latch so a route sticks to one region until it thins out.
One bilingual fragment per PR, per changelog/unreleased/README.md.
Add the WithRegionFilter/regionFilterFromContext context helpers and let newRouteLoop prefer an explicit model-name region over key-grant and pin-derived regions. These helpers were previously introduced alongside an unrelated quota change; they belong with the region-qualified prefix feature.
Per review on caigee-cmd#311: a bare prefix (qoder/, workbuddy/) must not default to
cn — international-only deployments would lose all routes. The default-cn
commit is dropped; bare prefix and -auto/ now behave identically (provider
pinned, region chosen by the pool), with -cn/ and -gl/ as the optional
explicit qualifiers.

The compat/s01/regression test expectations return to their original form
as a result. New coverage: TestPickRouteBarePrefixMatchesGlobalOnlyPool
(global-only pool routes a bare qoder/ request; explicit -cn/ does not) and
TestPrepareBarePrefixSetsNoRegionFilter.
@favoroo
favoroo force-pushed the feat/executor-region-prefix branch from 46e54d9 to 79839f0 Compare October 19, 2026 04:51
@favoroo favoroo changed the title feat(executor): region-qualified model prefixes, CN default, and -auto/ qualifier feat(executor): region-qualified model prefixes and -auto/ qualifier Oct 19, 2026
@favoroo

favoroo commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

@caigee-cmd 已按 review 调整完毕:

  1. 裸前缀不再默认 cn:defaultRegionForProvider 已移除(整个提交从分支里 drop 掉),qoder/…、workbuddy/… 保持原有行为——不锁定区域,由池自动选区,只有国际账号的部署不受影响。
  2. -auto/ 保留:作为裸前缀行为的显式写法保留(两者语义一致),已在 PR 描述和 changelog 里说明这一选择。如果你更倾向删掉以减少概念,我再移除。
  3. 测试:compat_test.go、s01_protocol_contract_test.go、regression_test.go 的预期随默认 cn 的移除自动恢复原样(这三份文件现在与 main 无 diff)。新增两个用例:TestPickRouteBarePrefixMatchesGlobalOnlyPool(只有国际账号时裸 qoder/model 仍能路由成功,且显式 -cn/ 不会误匹配)和 TestPrepareBarePrefixSetsNoRegionFilter。
  4. changelog 中关于默认 cn 的描述已改写;分支已 rebase 到最新 main,go test ./... 全绿。

麻烦再看一下,谢谢!

@caigee-cmd caigee-cmd left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM. Bare prefixes keep auto region selection; -cn/-gl/-auto work as documented; tests and changelog updated. Merging.

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.

2 participants