429 robustness

This commit is contained in:
Luxferre
2026-08-26 08:16:43 +03:00
parent 6366efb8bd
commit 5f23e9b61c
2 changed files with 621 additions and 104 deletions
+12 -6
View File
@@ -158,7 +158,11 @@ When the upstream model produces tool calls:
#### Streaming pipeline architecture
```
Stream Lines (0: "...", data: {...}, b: "...")
Chromium ReadableStream (window.th3istStreamChunk)
├─► CDP Runtime.bindingCalled Event
├─► StreamLineBuffer (Reassembles complete stream lines across TCP chunks)
├─► StreamThinkingFilter (Stateful sliding window)
│ ├─► Emits reasoning content to delta.reasoning_content
@@ -167,11 +171,13 @@ Stream Lines (0: "...", data: {...}, b: "...")
└─► StreamToolCallFilter (Stateful tool tag parser)
├─► Buffers & parses <tool_call>...</tool_call> blocks
├─► Emits structured OpenAI delta.tool_calls
└─► Emits clean assistant text to delta.content
└─► Emits clean assistant text to delta.content in real time
```
1. `StreamThinkingFilter`: Stateful filter intercepting `<think>...</think>` tags and routing to `reasoning_content`.
2. `StreamToolCallFilter`: Stateful filter intercepting `<tool_call>...</tool_call>` tags, preventing raw XML leaks in `content` and emitting OpenAI `delta.tool_calls`.
3. Flushes `data: [DONE]` on stream termination.
1. `Runtime.addBinding`: Exposes `window.th3istStreamChunk` to the browser context, relaying `ReadableStream` chunks over CDP in real time without buffering.
2. `StreamLineBuffer`: Reassembles partial TCP packets into complete protocol lines across chunk boundaries.
3. `StreamThinkingFilter`: Stateful filter intercepting `<think>...</think>` tags and routing to `reasoning_content`.
4. `StreamToolCallFilter`: Stateful filter intercepting `<tool_call>...</tool_call>` tags, preventing raw XML leaks in `content` and emitting OpenAI `delta.tool_calls`.
5. Flushes `data: [DONE]` on stream termination.
---
@@ -239,7 +245,7 @@ Because `th3ist` controls Chromium via CDP, `BrowserBridge.RotateIdentity()` mut
"confidence": 1
}
```
- **Zero-downtime auto-recovery**: If `ExecuteFetch()` receives an `HTTP 429 ratelimit_hit`, it automatically invokes `RotateIdentity()`, mints a fresh hCaptcha token, and retries the completion request transparently.
- **Zero-downtime auto-recovery**: If `ExecuteFetch()` receives an `HTTP 429` or rate limit error, it immediately invokes `RotateIdentity()`, mints a fresh hCaptcha token, resets session IDs, and retries the completion request transparently (up to 4 attempts) without returning 429 errors to the client right away.
#### 3. Bypassing guest limits via BYOK (bring your own key)
`th3ist` also supports passing custom provider API keys directly in standard OpenAI format: