552 Commits
Author SHA1 Message Date
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
Chenyme f8eb3d100f fix: refresh Statsig on stale-page media rejection 2026-08-24 16:15:04 +08:00
Chenyme 470ac4afbc fix: preserve provider prefixes in public model names 2026-08-24 15:14:05 +08:00
Chenyme eca3ef14fa Merge branch 'main' into auth 2026-08-24 14:12:26 +08:00
Chenyme 1006d6cb3d fix: add a scoped access-cookie fallback for stripped bearer auth 2026-08-24 14:11:44 +08:00
Chenyme 3116c15beb fix: prevent transient upstream failures from cascading into cooldown 429s 2026-08-24 13:43:23 +08:00
Chenyme 5c8e26ce9f Merge branch 'main' into usages 2026-08-24 11:12:48 +08:00
Chenyme 4ae50ecf98 fix: support shared weekly limits for Grok Web Imagine 2026-08-24 11:12:09 +08:00
Chenyme efc82e7d9e Merge branch 'main' into feat/recognize-supergrok-plus 2026-08-24 10:34:11 +08:00
Chenyme f49b030e63 fix: enforce output loop guards across all stream paths 2026-08-24 10:26:03 +08:00
afeer123andCursor 59ddc6e27d fix(accounts): treat SuperGrok Plus as a paid billing plan
xAI now reports SuperGrokPlus with zero weekly numeric limits, so the
allowlist missed it and Build routing classified those accounts as unknown.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-23 00:43:54 +08:00
Sofwan 4f384fe4be feat: terminate model output loops with split content/reasoning thresholds
A looping upstream stream burns account quota and the client context window
until the response budget is exhausted. Track consecutive identical deltas
and terminate the stream once a channel exceeds its ceiling.

Content and reasoning keep separate counters. high/xhigh effort reasoning
legitimately repeats the same short marker ("so", "hmm", "wait", list
bullets) far more often than visible output does, so a single shared
counter truncates valid deep-thinking responses. Reasoning is therefore
allowed a higher ceiling (256) than visible content (128).

The content ceiling also has to clear legitimate visible repetition:
markdown horizontal rules and ASCII table borders stream as long runs of
an identical single-character delta ("-", "=", "|").
2026-08-22 03:12:50 +08:00
Chenyme 46cfa374af fix: align video generation with current mediaGenInput protocol 2026-08-20 20:48:59 +08:00
Chenyme 017d94a065 Merge remote-tracking branch 'origin/main' into pr/989
# Conflicts:
#	backend/internal/application/gateway/quality_retry.go
#	backend/internal/application/gateway/quality_retry_scan.go
#	backend/internal/application/gateway/quality_retry_test.go
#	backend/internal/infra/config/config.go
#	backend/internal/infra/config/config_test.go
#	backend/internal/transport/http/account/handler.go
#	backend/internal/transport/http/account/handler_test.go
#	backend/internal/transport/http/inference/handler.go
#	backend/internal/transport/http/inference/handler_test.go
#	config.example.yaml
2026-08-20 20:25:02 +08:00
Chenyme 2aace693e9 fix: avoid withholding late-thinking streams after the quality hold deadline 2026-08-20 20:19:22 +08:00
Chenyme 1316ed730b feat: add privacy-safe request diagnostics and bounded retention 2026-08-20 19:45:35 +08:00
Chenyme c07fa0b61e Merge remote-tracking branch 'origin/main' into pr/983
# Conflicts:
#	backend/internal/transport/http/inference/handler.go
2026-08-20 19:40:37 +08:00
lij768423-svg 6b288f209c fix: lengthen requestRetry hold so grok-4.6 thinking is not withheld
3s hold cuts encrypted thinking that arrives at end-of-stream, which
fills audits with HTTP 200 · error and quality_degraded retries.
Match the production lab defaults: 30s hold, minOutput 8, 12h
missing-thinking cooldown, 15m idle cooldown, grok-4.6 probe model.

requestRetry.enabled stays false in built-in Go defaults so existing
configs do not flip on upgrade; config.example.yaml now recommends it on.
2026-08-20 17:18:05 +08:00
Chenyme 68e3399821 Merge branch 'main' into guard 2026-08-20 16:38:56 +08:00
Chenyme 5f4bbc68b4 Merge branch 'main' into fix/responses-abort-failed 2026-08-20 16:31:06 +08:00
Chenyme 868b836ae5 fix: emit protocol-safe response.failed events for empty streams 2026-08-20 16:30:52 +08:00
Chenyme 0772fb1c7a Merge branch 'main' into fix/clear-account-cooldown 2026-08-20 16:10:15 +08:00
Chenyme 0fb3a04124 fix: preserve quality strikes when clearing cooldown 2026-08-20 16:09:58 +08:00
Chenyme 7dd96657dd Merge branch 'main' into pr/980
# Conflicts:
#	backend/internal/application/gateway/quality_retry_scan.go
2026-08-20 15:38:29 +08:00
Chenyme a2f2687b33 fix: retry terminal empty streams without misclassifying tool output 2026-08-20 15:32:25 +08:00
Chenyme 7e71bf09ae Merge branch 'main' into fix/hold-tools-schema 2026-08-20 15:15:47 +08:00
Chenyme d93547dc19 fix: avoid replaying hosted tools during quality retries 2026-08-20 15:15:31 +08:00
Chenyme e6b39bdf88 Merge pull request #978 from lij768423-svg/fix/responses-annotations
fix: fill required output_text.annotations for Grok CLI serde
2026-08-20 15:03:53 +08:00
Chenyme 5f156cd3f5 fix: preserve real thinking evidence across protocol conversion 2026-08-20 14:56:31 +08:00
lij768423-svg 24ce972b37 fix: emit response.failed with required model for Grok TUI serde
TUI 0.2.93 treats any response.incomplete as fatal max_tokens_truncation,
ignoring incomplete_details.reason, so stream aborts killed the turn.
serde also requires model on response.failed / completed; a missing key
fails deserialization. Always emit response.failed and fill model from
stream metadata or the last seen response event.
2026-08-20 11:43:29 +08:00
lij768423-svg 9bb6b48549 fix: hold TUI after-tool turns instead of skipping in-flight results
Grok TUI tools run locally. The next /v1/responses body already contains
function_call_output; retrying it on another account only regenerates the
model turn and does not re-execute tools. Skipping hold on that body let
0-thinking dumps through on the common agent loop.
2026-08-20 11:43:29 +08:00
lij768423-svg c560c495e2 fix: emit response.failed with required model for Grok TUI serde
TUI 0.2.93 treats any response.incomplete as fatal max_tokens_truncation,
ignoring incomplete_details.reason, so stream aborts killed the turn.
serde also requires model on response.failed / completed; a missing key
fails deserialization. Always emit response.failed and fill model from
stream metadata or the last seen response event.
2026-08-20 11:43:23 +08:00
lij768423-svg dcb687ad69 fix: hold TUI after-tool turns instead of skipping in-flight results
Grok TUI tools run locally. The next /v1/responses body already contains
function_call_output; retrying it on another account only regenerates the
model turn and does not re-execute tools. Skipping hold on that body let
0-thinking dumps through on the common agent loop.
2026-08-20 11:43:23 +08:00
Jeik 86010fc55c feat(audit): add response body recording, stream reassembly, and audit log retention settings 2026-08-20 10:36:07 +08:00
Jeik 9d841a2757 feat(audit): capture complete client HTTP request headers, metadata and fix audit detail inspection 2026-08-20 10:22:46 +08:00
lij768423-svg bb2dc424d0 fix: allow clearing account cooldown and configure empty-stream penalty
Empty SSE idle timeouts currently write a hardcoded 24h cooldown via
qualityIdleAccountCooldown. Toggling enabled does not reset health, so a
single-account pool stays on 429 upstream_cooling until the operator
edits sqlite and restarts.

Add POST /api/admin/v1/accounts/:id/clear-cooldown (API + UI) which
zeros failure_count/cooldown_until/last_error. UpdateHealth already
publishes InvalidationAccountHealthChanged, so runtimeStore=memory
selector overlays are replaced.

Expose qualityGuard.requestRetry.idleAccountCooldown (1m–168h, default
24h) independently of missing-thinking accountCooldown. PATCH enabled
while cooling returns enabledDoesNotClearCooldown so the UI can warn.

Closes #976
2026-08-20 09:11:24 +08:00
lij768423-svg ac37721db2 fix: retry empty completed streams instead of waiting for idle
response.completed / [DONE] with zero tokens used to keep the quality
hold in Wait until the idle timeout. The client already had HTTP 200
headers and saw a 50–120s Retrying spinner.

Finish the peek immediately and surface errQualityEmptyStream so the
attempt loop rotates. Open empty hangs still wait for idle and do not
fail-open as HTTP 200.
2026-08-20 09:11:24 +08:00
lij768423-svg b411d041d4 fix: hold TUI tool-schema turns, skip only in-flight tool results
Grok TUI declares a tools array on every agent request, including the
first thinking turn. Skipping hold on that schema forwarded
missing-thinking streams as HTTP 200.

Keep the replay-safety skip for in-flight tool output
(function_call_output, tool_result, role=tool). Compact skip and
previous_response_id pinning are unchanged.
2026-08-20 09:11:24 +08:00
lij768423-svg 78ff3b6ac1 fix: fill required output_text.annotations for Grok CLI serde
Grok CLI treats annotations as a required field. A missing key fails
deserialization with "missing field annotations" and the TUI retries
the turn. Keep existing citation arrays untouched.
2026-08-20 09:11:24 +08:00
lij768423-svg d1aeb775d0 fix: treat only streamed thinking as quality-hold evidence
Usage.reasoning_tokens, empty reasoning items, and the Chat SSE stub
are not proof of thinking. Degraded upstreams fill those fields and
then dump visible tokens, so the hold used to fail-open as 200.

Require reasoning/summary deltas or encrypted_content before delivering.
An empty stub waits until terminal so ciphertext that arrives at the end
is not withheld.
2026-08-20 09:11:24 +08:00
lij768423-svg 78c17a83b3 fix: allow clearing account cooldown and configure empty-stream penalty
Empty SSE idle timeouts currently write a hardcoded 24h cooldown via
qualityIdleAccountCooldown. Toggling enabled does not reset health, so a
single-account pool stays on 429 upstream_cooling until the operator
edits sqlite and restarts.

Add POST /api/admin/v1/accounts/:id/clear-cooldown (API + UI) which
zeros failure_count/cooldown_until/last_error. UpdateHealth already
publishes InvalidationAccountHealthChanged, so runtimeStore=memory
selector overlays are replaced.

Expose qualityGuard.requestRetry.idleAccountCooldown (1m–168h, default
24h) independently of missing-thinking accountCooldown. PATCH enabled
while cooling returns enabledDoesNotClearCooldown so the UI can warn.

Closes #976
2026-08-20 02:38:32 +08:00
lij768423-svg dc87764154 fix: retry empty completed streams instead of waiting for idle
response.completed / [DONE] with zero tokens used to keep the quality
hold in Wait until the idle timeout. The client already had HTTP 200
headers and saw a 50–120s Retrying spinner.

Finish the peek immediately and surface errQualityEmptyStream so the
attempt loop rotates. Open empty hangs still wait for idle and do not
fail-open as HTTP 200.
2026-08-20 01:14:32 +08:00
lij768423-svg 68e5881433 fix: fill required output_text.annotations for Grok CLI serde
Grok CLI treats annotations as a required field. A missing key fails
deserialization with "missing field annotations" and the TUI retries
the turn. Keep existing citation arrays untouched.
2026-08-20 01:14:24 +08:00
lij768423-svg 731e95b924 fix: hold TUI tool-schema turns, skip only in-flight tool results
Grok TUI declares a tools array on every agent request, including the
first thinking turn. Skipping hold on that schema forwarded
missing-thinking streams as HTTP 200.

Keep the replay-safety skip for in-flight tool output
(function_call_output, tool_result, role=tool). Compact skip and
previous_response_id pinning are unchanged.
2026-08-20 01:14:24 +08:00
lij768423-svg c9c10a3fbd fix: treat only streamed thinking as quality-hold evidence
Usage.reasoning_tokens, empty reasoning items, and the Chat SSE stub
are not proof of thinking. Degraded upstreams fill those fields and
then dump visible tokens, so the hold used to fail-open as 200.

Require reasoning/summary deltas or encrypted_content before delivering.
An empty stub waits until terminal so ciphertext that arrives at the end
is not withheld.
2026-08-20 01:07:01 +08:00
Chenyme c0d7c94e2c feat: isolate account-bound proxy leases 2026-08-19 16:59:53 +08:00
Chenyme d76c74f407 feat: record trusted client IPs 2026-08-19 15:06:17 +08:00