Repository navigation
Conversation
Routing stability for cache affinity: - Retry a transient upstream hiccup once on the same account before spending a failover hop. An empty stream, a first-byte timeout, or a stream that dies before the first event usually recovers on the same worker, and switching accounts throws away the prompt cache. The retry has its own per-request budget, keeps the in-flight slot, and skips any non-transient failure. - Stop the exponential ladder from multiplying a cooldown the upstream declared itself. Transient failures are capped at 60s; a quota reset reported in the response body is used verbatim (>=1m, <=24h) instead of being clamped to the 10-minute rate-limit window, which would have retried a dead account every ten minutes. Durable failures (auth, unhinted rate limits) still escalate. - Keep a session binding through a short cooldown: failover no longer clears the anchor when the account is only cooling, and bindSession/CommitSession leave the anchor alone while its remaining cooldown is 5 minutes or less, so the next turn returns to the cache-warm account. - Default session-affinity TTL 1h -> 4h, with CLI2API_AFFINITY_TTL and CLI2API_AFFINITY_CAPACITY overrides (48h / 1M bindings hard caps). - Classify exhausted routing (503 no_accounts) and undecodable upstream bodies (502 upstream_decode_error) instead of leaking a bare 502 upstream_error. Observability, so the change can be measured: - SessionAffinityStats gains miss_reasons / escape_reasons distributions alongside the existing last-value fields. - RequestUsageTotals gains cache_hit_rate (hit / (hit + miss)), nil when no cache accounting was reported. - SeedComponents reports per-component session-seed hashes; Prepare logs them under CLI2API_AFFINITY_DEBUG so a chat that re-anchors every turn can be traced to a volatile system prefix or a changed first message.
Two remaining cache-hit leakers: - Normalize the tools array before hashing the session seed. Tool definitions are a set, but clients such as Claude Code and Cline rebuild the array per turn; an order change used to move the seed, scatter the chat across accounts and invalidate the upstream cached prefix. NormalizeToolsOrder sorts by tool name plus the compact body so identical sets hash identically, returns input byte-identical when already sorted, and leaves invalid/empty/unnamed input untouched. Payload reordering is opt-in via CLI2API_TOOLS_NORMALIZE because some models notice the array order; the fingerprint side is always on. - Escape a sticky provider binding when the whole provider is cooling for a real reason (quota, or a retry hint of two minutes or more) and a different provider family can serve the model. Previously only concurrency saturation could escape, so a quota-exhausted provider answered 429 while a healthy supplier sat idle. capacityOutsideProvider deliberately excludes same-family region hops (Qoder global/CN are isolated upstreams), and the escape keeps stickyEscape so a successful turn does not steal the anchor while the bound account is merely cooling; short cooldowns still return a Retry-After.
Conflict resolution: - keep upstream's standalone const pathCheckinStatus in checkin.go and drop the duplicate declaration from credential.go (upstream caigee-cmd#586 shipped the probe). - drop the duplicated checkin-status tests from client_test.go; upstream caigee-cmd#586 already carries them in checkin_status_test.go. Verified on the merged tree: go build ./..., go test ./..., go vet ./...
docs: archive changelog for v0.7.46
- config: read UPDATE_GITHUB_REPO (default caigee-cmd/cli2api) and feed it to the release checker instead of a hardcoded repository. - updater: add -github-repo so a host updater self-updates from the same fork; ExecutorConfig already falls back to the upstream default when empty. - deploy: pass UPDATE_GITHUB_REPO through compose, document it in .env.example, and let install-updater.sh / install-updater.ps1 honor CLI2API_IMAGE_REPOSITORY and CLI2API_GITHUB_REPOSITORY. - tests: cover the config default/override and executor repository resolution.
The create dialog rendered its error alert at the top of the scrollable body, so a validation failure was invisible once the member list was scrolled; the client also accepted ids the server rejects (dots, underscores, spaces). - validate the model id in the dialog with the same character set the backend enforces and explain the failure in place. - pin the form error above the footer so it stays on screen. - return a precise backend message for a malformed id instead of "required". - cover valid/invalid ids and the message with tests; refresh static assets.
- config: UPDATE_GITHUB_REPO now defaults to guyu233/cli2api and normalizes owner/repo, GitHub URLs and .git suffixes; the console shows the resolved repository. - updater: -image-repository/-github-repo default to the fork image and releases so a host updater pulls and self-updates from the same place. - deploy: compose image, .env.example and both installers follow the fork; README documents UPDATE_GITHUB_REPO and the installer overrides. - console: the update panel names the release source and, when no host updater is connected, explains that deploy/install-updater.sh has to be installed once instead of reporting a generic outage; failed prepares name the missing daemon too. - sync rebuilt frontend static; full go test/vet and npm lint pass.
…release A fork that only carries tags used to compute v0.1.0; release.yml now falls back to the highest semantic tag reachable from the release commit, so the first fork release continues the version line.
docs: archive changelog for v0.7.47
Keep the changelog fragments and drop the archived 0.7.47 section so the next release publishes as v0.7.45; the following bump becomes v0.7.46.
docs: archive changelog for v0.7.45
…ent upstream releases - trae: X-Ide-Version-Code 20260212 -> 20261117. Trae gates the model catalog and chat on the build date; the old value collapsed the catalog to the legacy six models and rejected current ones with 4001. Adds a cohort guard test. UG check-in/quota live-verified unchanged. - workbuddy: CLI segment 2.176.0 -> 2.186.0 (CN desktop 5.11.3 / Global 5.11.4 stay). Live A/B: same 57-model CN catalog and streaming chat; billing check-in / user-resource untouched. - kiro: IDE fallback 1.4.236 -> 1.5.37. codex: UA 0.172.0. command: CLI 1.93.3. kimi: CLI 2.7.3. devin: CLI 3000.14.30821.
The wire version string was 3.4.24, a number that does not appear in trae.cn's public release line (3.4.21 shipped 2026-11-17, and nothing newer is published). Trae does not gate the catalog on this string, but reporting an unpublished build still misdescribes the client, so it now carries the same 3.4.21 release as the 20261117 build code. Re-audited every other pin against its public source on 2026-11-25: Kiro IDE 1.5.37 (stable metadata), Codex 0.172.0 (published 11-24), Command 1.93.3 (published today), Kimi 2.7.3, Devin 3000.14.30821 (11-17), WorkBuddy CLI 2.186.0 with desktop 5.11.3/5.11.4, QwenWork 2.1.0/26111906. All are the newest published builds and stay unchanged.
…uilds Meta Muse: chat now sends muse-build/1.4.14 with build dec7d749... (the pair captured from Muse Code 1.4.14-R7309.1 and still shipped by CLIProxyAPI main), tbh:exec and the host platform, replacing the stale 1.3.0 / tbh:tui identity. The 1.4.25 client exists but has no published build hash, and a new version with an old hash is an inconsistent fingerprint. MiniMax: the check-in query reports desktop_version=0.7.9, the current MCode TUI release (npm @minimax-ai/code, 2026-11-20), instead of 0.7.2. The route signs the exact path+query, so this only changes the attribution field.
Qoder: check-in reports the desktop release per edition (CN 0.5.18, 2026-11-24; global 0.5.3, 2026-11-03) instead of 0.4.8. CodeArts: login reports snap_vscode / 26.11.300. Both the IDE 26.11.200 package (bundled huaweicloud.codearts-snap) and the 26.11.300 VSIX build plugin-name as \_vscode and send the raw extension version; neither contains snap_AIIDE or 5.2.0. Kiro: KAS moves to 0.66.123, the @kiro/agent version bundled in IDE 1.5.37 (kiro.kiro-agent 1.1.1168, commit 03cd03a). Doubao Work: account query reports sdk_version 2.2.10, the value doubao.com requests today; version_code 20800 is kept because the official page still sends it.
- Model pool editor can pin context window, max output, reasoning levels and default effort for an aggregated model; /v1/models advertises exactly those values. - Aggregations without overrides advertise the conservative intersection of their members (smallest window and output, shared reasoning levels) instead of the first member's numbers, and members resolve by provider and region rather than by model name alone. - A request that carries no reasoning intent uses the aggregation default level; each member provider still maps and clamps it to what its own model allows.
… concurrent - Check-in all and refresh credits fan out to every account in one pass: the new bulk endpoints return one result per account with the verbatim upstream error, and the console no longer batches or queues requests. - GET /api/events streams the runtime event bus (account / accounts / quota / checkin / refresh / bulk) with sequence replay. Console pages patch rows live and fall back to a 5s poll when the stream is unavailable. - Check-in results carry the real reward credits plus code and HTTP status, and a provider that reports no status stays "unknown" instead of "success". - Quota is persisted as the real upstream snapshot; force-ready overrides only enter the routing pool and the console badges them. Each quota snapshot states its age, and the synthetic inflight demo board plus its login showcase are gone. - Video, audio and file content parts are refused with a real 400 invalid_request instead of being dropped during prompt assembly, and a shared head timeout makes Trae streams fail over when the upstream accepts a request and stays silent.
docs: archive changelog for v0.7.46
Select account cards, confirm, and the console authorizes them one at a time: start the provider login, show the authorization page, poll status, and advance automatically. Cancel stops the walkthrough; every row keeps its own state and the verbatim upstream message.
The implicit max-output default changed what every client asked for without its knowledge. Similar gateways do not do this: one-api passes the request body through, and LiteLLM only fills a default where the upstream protocol requires max_tokens. Keep the catalog limits in /v1/models and let the client size its own request.
Renumbering a released build needs a version number that sits below the latest tag. Guard it behind allow_rewind so the default still refuses to move backwards, and require the target tag to be deleted first.
0.45.x sorts above 0.7.45 in SemVer, so the console kept offering 0.45.2 as the newest release after the renumbering. Read /releases/latest and let the marked release decide the update target; fall back to the highest tag only when no marker is available.
|
Not merging this as one pull request. The branch is BlockingThe defaults that decide where an installation pulls images and checks for updates are changed from
Merged here, a stock deploy would pull the fork's image and follow the fork's releases. Please split out, these change request behaviorWorth taking, but each one moves routing, billing, or what the client is told, so they need their own review:
Fine once the above is split outProvider version pins, per-region check-in windows, bounded Happy to review those as separate PRs. |
|
补充一下具体可以怎么改。上面提到的功能本身大多是想要的,卡的是「整支 1. 发布源改回这个仓库这几处默认值现在指向
2. 会改变请求行为的部分,请各自开一个 PR这几块各自改的是路由、配额或客户端拿到的结果,放在一起很难单独回退。建议从现在这个分支上按主题拆出去,每支都基于最新的
3. 这些拆出来就可以直接过供应商版本号对齐、按区域学习签到窗口、 操作上不必改这次提交的历史。从现有分支切出上面的小分支,各自开到本仓库 |
The console asked the operator to flip a Max switch per model before Trae would send is_max_mode. Every other provider simply advertises one context size, so derive the tier from the catalog: models with a real Max window now ask upstream for it on every request, /v1/models advertises the larger window, and the console renders a single value. An explicit client is_max_mode=false still falls back to the default window.
|
看过最新的 head( 新加的 |
|
Splitting this branch per the review. The fork no longer changes the default release identity (defaults stay caigee-cmd/cli2api / ghcr.io/caigee-cmd/cli2api; a fork overrides via UPDATE_GITHUB_REPO / CLI2API_IMAGE_REPOSITORY / CLI2API_GITHUB_REPOSITORY). This PR is replaced by the core PR plus #598 (tool-call arguments), #599 (reasoning levels), #600 (executor affinity/retry/quota); aggregation caps, console SSE and bulk re-login follow separately. |
What this changes
Everything the fork accumulated since
5861ffe, consolidated into one PR: CC Switch-aligned parameter handling, console/runtime hardening, a stream idle watchdog, and the fork's release-line reset.Parameter handling
internal/providers/reasoning.go,workbuddy/mapping.go): a level the client sends is forwarded untouched whenever the model declares it; an undeclared level degrades to the nearest lower declared tier; a request below the floor lands on the cheapest declared tier; an omitted level is the only case that uses the model default. A reasoning mismatch never moves the request to another provider, andnoneon a model that cannot disable thinking no longer falls back to a possibly higher default.internal/executor,internal/gateway,internal/translate):max_tokens/max_output_tokensare forwarded exactly as sent. No implicit default is injected, so a request that omits the field keeps the upstream's own decision. The models the gateway serves advertisecontext_length/max_output_tokensin/v1/models, and the client sizes its own request from that.internal/accounts,frontend): the arbitrary 1024 floor and the "max output ≤ context" cross-field rule are gone; both values are validated only as non-negative integers with a sane upper bound, matching the optional, unconstrained columns CC Switch exposes.Runtime and reliability
internal/executor/stream_idle.go): a stream that returns 200, emits its first event, then goes silent is now bounded by a five-minute idle deadline (CLI2API_STREAM_IDLE_MS, clamped to 30s minimum). The timer only runs while a read is actually waiting on the upstream body, so a blocked client write cannot kill a healthy stream. On expiry the inner body is closed, the in-flight slot is released, and the failure is classified asstream_idle_timeout(unavailable, 10s cooldown, no failover, transient).internal/store,internal/app): process startup closes request logs left instarted/streamingby the previous process aserror/stream_abandoned, so the console no longer shows multi-hour ghost streams.Console and runtime
Release tooling
release.ymlaccepts an explicitx.y.zonly when it is exactly the next patch after the latest published release; line changes go throughbump=minor/bump=major, andallow_rewindis only for a deliberate reset with the old tag deleted first.0.7.52vsv0.7.52).Fork release-line reset
v0.7.46–v0.7.61(16 releases and tags; release notes backed up locally), keepingv0.7.44(upstream) andv0.7.45.0.7.46from currentmain(d68bf36): imageghcr.io/guyu233/cli2api:0.7.46, marked Latest; the live host runsv0.7.46. WithdrawnCHANGELOG.mdsections were removed so the archive job can write the new notes under the same number.0.7.47,0.7.48, … with no gaps.Verification
go test ./...passes (api, app, console, control, executor, gateway, logs, runtime, store, update, updater and every provider package).go build ./...passes;gofmtreports no changes in the files touched by this PR.v0.7.46release run: prepare, assets, draft, image, promote, publish, aliases and changelog — all eight jobs succeeded./healthreturnsversion: v0.7.46,commit: d68bf36; containerUp (healthy); console/returns 200; nopanic/fatal/level=errorlines since the switch;/api/system/updatereportscurrent_version: v0.7.46,has_update: false, rollback onlyv0.7.45.python scripts/release-notes.py validateexits 0; bilingual fragments live underchangelog/unreleased/.Notes
stream_idle_timeoutis covered byinternal/executor/stream_idle_test.go(silent stream fires, active stream survives, blocked consumer is not killed, slot released on close, classification) andinternal/store/request_logs_abandoned_test.go.cd frontend && npm run sync, sointernal/webui/staticmatchesfrontend/dist.