597 Commits
Author SHA1 Message Date
Chenyme 155ebba7d5 fix(cli): alias Codex view_image tool for Grok Build 2026-09-02 13:42:02 +08:00
Chenyme 9b80510055 Merge branch 'main' into fix/web-free-video-duration-cap 2026-09-01 11:17:26 +08:00
Chenyme eadfece376 fix: cap free-tier video duration before upstream 2026-09-01 11:16:49 +08:00
Chenyme 08de857a75 Merge branch 'main' into pr/1029
# Conflicts:
#	backend/internal/transport/http/inference/handler_test.go
2026-09-01 10:20:27 +08:00
Chenyme c25705e106 Merge branch 'main' into fix/audit-output-loop-error-code 2026-08-31 23:48:16 +08:00
Chenyme 44807b28ac fix: avoid allocation size overflow in schema normalization 2026-08-31 23:48:02 +08:00
Chenyme d3ba8ff6d5 fix: safely normalize Build function parameter root unions 2026-08-31 23:41:13 +08:00
Chenyme f97be4e553 fix: preserve output-loop code across audits and SSE 2026-08-31 20:49:01 +08:00
Chenyme c6acb00e0f Merge branch 'main' into pr/1027
# Conflicts:
#	backend/internal/application/gateway/service_test.go
#	backend/internal/transport/http/inference/handler.go
2026-08-31 18:53:19 +08:00
Chenyme b3c4024c73 Merge branch 'main' into fix/semantic-idle-pause-when-not-reading 2026-08-31 18:32:51 +08:00
Chenyme f082e6cb96 fix: guard semantic idle against stale timer callbacks 2026-08-31 18:32:36 +08:00
Chenyme 95722d2992 Merge pull request #1025 from buddhism5080/fix/reasoning-replay-cross-account-no-content-null
fix(cli): share reasoning replay across accounts and omit content:null
2026-08-31 18:19:19 +08:00
Chenyme 543f675522 fix: decouple reasoning replay from credential ID 2026-08-31 17:50:01 +08:00
Chenyme 7f71372be0 Merge branch 'main' into fix/live-reasoning-first-wins 2026-08-31 16:04:27 +08:00
buddhism5080 f0044b76b6 fix: cap Grok Web free-account video duration before upstream
Free Web accounts 429 when duration exceeds 6s, which then rotates
accounts without changing the payload. Add a Grok Web setting
(freeVideoDurationCap, default 6) and clamp duration for free-tier
accounts at the Web adapter so retries are not wasted.
2026-08-31 16:04:05 +08:00
buddhism5080 5efc09a29f fix: lift Build function parameter root unions for xAI grammar
Codex/OpenAI Responses tools often send a root oneOf/anyOf whose
branches are $ref or nested unions. xAI/Build grammar requires a
root object or a root union of inline objects. Lift only the root
union, keep property $ref/$defs, and fail locally if the result is
still illegal.

Also treat streamed 400 JSON as ClassifyUpstreamHTTPError instead of
copyStream, so invalid-argument is request-scoped and does not rotate
accounts. Compatibility warning is function_parameters_root_normalized.
2026-08-31 16:04:05 +08:00
Chenyme fd6f5c8c7d Merge branch 'main' into pr/1023
# Conflicts:
#	backend/internal/infra/provider/conversation/stream.go
2026-08-31 15:56:37 +08:00
Chenyme ce8897ed8a Merge branch 'main' into pr/1022
# Conflicts:
#	backend/internal/infra/provider/cli/responses_reasoning_recovery.go
2026-08-31 15:36:34 +08:00
Chenyme b0ea8efdaa Merge branch 'main' into pr/1022
# Conflicts:
#	backend/internal/infra/provider/cli/responses_reasoning_recovery.go
#	backend/internal/infra/provider/cli/responses_reasoning_recovery_test.go
2026-08-31 15:31:07 +08:00
Chenyme 2645f5ef01 Merge branch 'main' into fix/audit-client-vs-upstream-stream-interrupt 2026-08-31 15:08:22 +08:00
Chenyme e42b2ef7d5 Merge branch 'main' into fix/selector-skip-credential-material-errors 2026-08-31 14:59:10 +08:00
Chenyme db8378e1d3 fix: skip accounts on transient credential-material load failures 2026-08-31 14:58:01 +08:00
Chenyme b086d759c5 fix: record hidden recovery and classify pinned-account failures 2026-08-31 14:39:20 +08:00
Chenyme c92dea8b06 Merge branch 'main' into pr/1019
# Conflicts:
#	backend/internal/application/gateway/attempt.go
#	backend/internal/infra/provider/cli/adapter.go
#	backend/internal/infra/provider/cli/responses_reasoning_recovery.go
2026-08-31 14:09:16 +08:00
Chenyme 22587daac6 Merge pull request #1018 from buddhism5080/fix/audit-retry-stream-failure
fix(audit): record stream failure after a prior 429 retry
2026-08-31 11:33:32 +08:00
Chenyme cf13fe1a2d fix: limit stream failure attempts to 2xx responses 2026-08-31 11:28:07 +08:00
Chenyme 95915fad28 refactor: enhance quality hold logic and replay safety across accounts 2026-08-31 10:34:58 +08:00
Chenyme d139aa5b39 Merge remote-tracking branch 'origin/main' into pr/1015 2026-08-31 10:21:50 +08:00
Chenyme 653d912dfb Merge pull request #1013 from lij768423-svg/feat/encrypted-thinking-floor-upstream
fix: withhold fake encrypted thinking (ciphertext floor + burst dump)
2026-08-31 10:11:06 +08:00
Chenyme b3d4c972c5 fix: make encrypted-thinking hold split-safe 2026-08-31 10:05:25 +08:00
Chenyme 7caa52c14f fix: preserve upstream outcomes during reasoning recovery 2026-08-31 09:40:39 +08:00
buddhism5080 5b3e7efa1f fix(inference): classify output-loop guard as upstream_output_loop
Doom-loop aborts were wrapped as a generic stream read failure, so audits
and SSE trailers reported upstream_stream_interrupted. Keep the sentinel
distinct so a model repeating the same delta is not mixed with a transport
cut.
2026-08-29 20:22:00 +08:00
buddhism5080 cb11a9f5f2 fix(cli): pause semantic idle while not reading upstream
Idle must only run while Read is waiting on Build. ConvertResponseStream
uses an unbuffered pipe, so a slow Anthropic client can block the
translator and stop those Reads; the old background timer then killed a
live summary stream as upstream_stream_idle_timeout. Client write
deadline still bounds how long we can leave upstream unread.
2026-08-29 17:22:31 +08:00
buddhism5080 2d0b621034 fix(cli): share reasoning replay across accounts and omit content:null
Encrypted reasoning is portable across accounts, so the server cache key
is session+plane only. Injected items drop content:null; xAI treats that
extra key as a modified compaction blob and 400s.
2026-08-29 15:53:01 +08:00
buddhism5080 4793b092f8 fix(conversation): stream first-wins reasoning live to Chat and Anthropic
Emit summary or raw as soon as the first source arrives and drop the
other, so Claude Code is not starved while a reasoning item is still
open. Forward encrypted_content as signature_delta the moment it
appears. Native Responses SSE is already a passthrough.
2026-08-29 07:38:05 +08:00
buddhism5080 990bd7bea0 fix(cli): forward original compact blobs and surface decode 400s
Client compaction items without the g2a_compact_v1 prefix are treated as
upstream original state and sent to Build unchanged. Compact blob decode
rejections are returned to the client instead of being recovered as
opaque reasoning. Gateway-owned g2a blobs still expand locally.
2026-08-29 06:54:26 +08:00
buddhism5080 acc0fb5361 fix(audit): distinguish client vs upstream stream interrupts
After a 2xx SSE handoff, a client hangup is client_stream_interrupted and keeps the upstream status. upstream_stream_interrupted is only for an upstream cut. Pre-header 499 request_canceled is unchanged.
2026-08-29 05:57:47 +08:00
buddhism5080 7cc10b1190 fix(gateway): skip accounts whose credential material fails to load
A timeout or lock on GetCredentialMaterial used to abort the whole
selector as no available accounts. Treat those per-account failures
like a stale claim so the rest of the pool can still be used. Request
cancellation still stops selection. Missing credentials still invalidate
the routing snapshot.
2026-08-29 04:59:59 +08:00
buddhism5080 6f5f99c2d8 fix(audit): keep hidden reasoning recovery and pinned-account 503s
Compaction-blob 400s recovered inside the Build adapter were returned as
200 with no audit attempts. Record each hidden upstream call (stage +
what the retry did) on the successful response.

Pinned conversation acquire treated a missing/disabled owning account as
an empty pool (upstream_unavailable) even when other accounts existed.
Return upstream_pinned_account_unavailable, skip bot-flag scheduling
exclusion for pinned acquire, and persist the selection failure plus
owning account id on the audit row.
2026-08-29 02:24:20 +08:00
buddhism5080 c7805f823c fix(audit): record stream failure after a prior 429 retry
When the first account returns 429 and the next account's 2xx stream
later fails, diagnostics previously kept only the 429 row. Always
append a response_stream attempt for the handed-off account unless
one is already present.
2026-08-28 22:43:50 +08:00
lij768423-svg 7b2cba3f43 fix: withhold floor-met thinking that dumps a short answer in under 1s
Encrypted_content can clear the byte floor while usage still bills hundreds
of reasoning tokens against a few visible tokens. Treat that fast dump as
missing thinking even before the hold deadline.
2026-08-28 11:36:30 +08:00
lij768423-svg 318c2dacd7 fix: withhold stub-only thinking when hold expires with enough output
A reasoning item start plus visible tokens at the deadline is not late
ciphertext. Treat it as missing thinking and rotate, matching the TUI
dump after 30s.
2026-08-28 11:36:30 +08:00
lij768423-svg ffaa2c7ba2 fix: hold TUI follow-ups and hosted-tool turns
Do not skip missing-thinking intercept on previous_response_id or hosted
tools. TUI always declares those. First attempt stays pinned; withhold
unpins and rotates. Compaction with no reasoning is held unless the
gateway set skipQualityHold.
2026-08-28 11:36:30 +08:00
lij768423-svg f343670fa7 fix: treat short encrypted_content stubs as missing thinking
Non-empty ciphertext is not proof of reasoning. HasThinking now requires
encrypted_content / Anthropic signature to meet max(256B, 4 bytes per
usage reasoning token). A hold-expired short greeting billed as heavy
thinking, or a barely-over-floor flush in under a second, is withheld.

Recommended requestRetry values stay 30s / minOutput 8 / 6 attempts /
fail_closed / 12h / 15m idle, plus the new floor knobs. enabled remains
false so stock installs do not intercept.
2026-08-27 19:03:27 +08:00
haswysa 2408b67ddb fix(gateway): keep portable reasoning summaries during compaction recovery
Same-account recovery now strips ciphertext while rewriting readable
summaries as developer messages, continues to session reset when the
stripped retry still returns 400, and only rotates accounts after
reasoning_recovery_failed. Drop Diagnostic substring matching so
unrelated 400s do not scan the account pool.
2026-08-26 08:05:37 +08:00
haswysa 1de4c8152d fix(gateway): failover account on reasoning recovery failure and strip unportable reasoning
In multi-account pools, server-side encrypted compaction blobs and reasoning states can fail to decode when a session drifts across accounts or upstream nodes, causing xAI to return HTTP 400 ("Could not decode the compaction blob").

Previously, isRetryable(400) evaluated to false in the gateway service, treating all 400 responses as non-retryable client errors. When provider reasoning recovery failed on the active account, the gateway immediately propagated the 400 to the client instead of attempting other healthy accounts in the candidate pool.

Fixes:
1. Gateway failover: Recognize reasoning_recovery_failed in isRetryableResponse so the gateway excludes the failing account and attempts the next candidate within the request attempt loop.
2. Reasoning recovery: Completely strip all reasoning items and convert compaction items to compatibility boundary messages during downgrade retries.
3. History normalization: Convert unencrypted reasoning items without portable content to developer boundary messages.
4. Error markers: Add compaction decode patterns to reasoningDecodeFailureMarkers.

Tested:
- Added TestRecoverReasoningDecodeFailureCompactionBlob
- Updated TestReasoningWithoutEncryptedContentBecomesBoundary
- All backend packages pass (go test ./...)
2026-08-26 06:37:08 +08:00
Chenyme d7fca59d68 fix: cool accounts after non-streaming idle responses 2026-08-25 18:10:57 +08:00
Chenyme f819f298a8 fix: quarantine runtime-selected account leases 2026-08-25 17:37:48 +08:00
Chenyme 57c66d7fe5 perf: paginate nodes and reduce status polling overhead 2026-08-25 17:10:54 +08:00
Chenyme af5dec368d fix: reconcile stale Grok Console quota after 429 2026-08-24 16:48:13 +08:00