Files
deepseek-v4-quant/memory/2026-04-30-extra-brace-parse-error.md
biondizzle f63eed5cfd Purge INT4 references — expert weights are FP4 (E2M1), not INT4
All docs and scripts updated. Historical memory entries annotated.
2026-05-08 02:33:46 +00:00

86 lines
5.2 KiB
Markdown

# Session: 2026-04-30 23:25:42 UTC
- **Session Key**: agent:main:main
- **Session ID**: 26a8d170-8454-4c51-8ad8-d892d6f5e090
- **Source**: webchat
## Conversation Summary
assistant: Final depth is -1 — an extra closing brace somewhere. Let me check the full brace balance:
assistant: There's an extra `}` at line 1195. Let me check:
assistant: That's the class closing brace — that's correct. The issue is somewhere earlier. Let me look more carefully. The depth goes to 0 at line 841 (end of `handleStreamingRequest`), then 0 again at 1083 (end of something). Let me look at what's between lines 841 and 844:
assistant: OK so the structure is right. The -1 at the end means there's one extra `}` total. But the depth analysis shows the class opens at 19 (0→1), and the final `}` at 1195 goes from 0→-1. But `sanitizePayloadForSentry` ends at 1194 (1→0). So the class closing brace at 1195 should be fine going 0→-1... wait, that doesn't make sense.
Let me recount:
assistant: One extra `}`. The parse error said line 778 - `unexpected catch`. Let me look at the streaming ServerException catch structure more carefully:
assistant: I see the issue — there's an extra closing brace. Lines 768-770 have `}` `}` `}` — that's closing the `while`, `foreach`, and the outer `if(empty content) continue` block... wait, let me look more carefully:
The structure is:
- `foreach ($this->httpClient->stream...)` — opens `{`
- `while` — opens `{`
- ...
- `}` closes while — line 768
- `}` closes foreach body — line 769
- `}` extra brace — line 770
The `foreach` chunk loop has: `foreach { ... while { ... } }` — that's 2 braces for foreach+while. But there's a 3rd `}` at line 770 that shouldn't be there. Let me check:
assistant: That's: `}` closes while, `}` closes foreach, `}` extra. The extra `}` closes the `try` block prematurely, making the `catch` unexpected. Let me remove it:
assistant: Same line. Let me look at the full structure around the retry try/catch:
assistant: I see — after the while/foreach close, the "If fallback closed without [DONE]" code is at wrong indentation. The `}` on line 771 closes the `try` block, then `catch` on line 775 should be at the same level. But the problem is the `try` block's `foreach` and `while` are correct, then there's code after the foreach that's inside the try — the "If fallback" section. Let me look at what the correct structure should be:
```
try {
$retryResponse = ...
foreach (stream) { // opens
while () { // opens
...
} // closes while
} // closes foreach
// If fallback closed without [DONE] <-- this is still inside try
...
return;
}
catch (\Exception $retryEx) {
```
But the current code has an extra `}` between the foreach close and the "If fallback" comment. Let me check:
assistant: I see the problem. Line 67 (`}`) closes the `try` block too early. The structure should be:
```
try { // line 704
$retryResponse = ...
foreach { // line 706
while { // line 714
...
} // line 768
} // line 769
// If fallback... // should still be inside try
...
return;
} // this closes try
catch (\Exception $retryEx) {
```
But line 67 (relative) = line 770 has `}` which prematurely closes the try. Then the "If fallback" code and its `}` are orphaned. I need to remove that extra `}` and add one after the "If fallback" return:
assistant: Clean. Let me do a final review of all the retry-related code:
assistant: All good. Here's the summary of changes:
1. **Added `use ServerException`** import
2. **Added `RETRY_ON_FAILURE` const** — maps `zai-org/GLM-5.1-FP8``MiniMaxAI/MiniMax-M2.7`
3. **Streaming handler (`handleStreamingRequest`)** — catches `ServerException` before the generic `\Exception`, retries with fallback model, replays the full streaming loop, replaces `$data->model` back to the original in every chunk
4. **Non-streaming handler (`handleNonStreamingRequest`)** — catches `ServerException`, retries with fallback, replaces `$content['model']` back to the original before returning
Both paths only retry once. If the fallback also fails, it falls through to the original error handling (Sentry + error response).
user: Sender (untrusted metadata):
```json
{
"label": "openclaw-control-ui",
"id": "openclaw-control-ui"
}
```
[Thu 2026-04-30 23:09 UTC] While testing the path, im just throwing `throw new ServerException();` but i get `Symfony\Contracts\HttpClient\Exception\ServerException`
assistant: Right — `Symfony\Contracts\HttpClient\Exception\ServerException` is an **interface**, not a concrete class. The actual thrown exception is the concrete one from the component. Let me fix the import:
assistant: The contract one (`Symfony\Contracts\HttpClient\Exception\ServerException`) is just an interface — can't instantiate it for testing, and while catching it would technically work at runtime (the concrete class implements it), using the concrete `Symfony\Component\HttpClient\Exception\ServerException` is the right move. Should match what actually gets thrown now.