fix: PR #13 browser UA + issues #14/#15 (remaining delta after #11/#12)#16
Conversation
- PR #13: browser User-Agent (UC_BROWSER_UA) for openai_compat upstreams - Issue #15: orchestrator_worker in /healthz, ultracode status, docs - Issue #14: tool-only assistant content=null, context-length error hints, tests PRs #11 and #12 were already merged to main; this branch carries only the delta. Co-authored-by: Cursor <cursoragent@cursor.com>
cbb14ed to
691ba02
Compare
|
|
||
|
|
There was a problem hiding this comment.
🟡 _context_length_hint matches rate-limit and auth errors due to overly broad "token" keyword
The _context_length_hint function uses bare substring matching for "token" which is far too broad. It matches not just context-length errors ("too many tokens") but also rate-limit responses (e.g. OpenAI's "Rate limit reached ... on tokens per minute (TPM)") and auth errors ("The provided authentication token is invalid"). This appends a misleading hint telling the user to compact their session or switch to a backend with a larger context window, when the actual issue is rate limiting or invalid credentials. Verified by running the function against realistic upstream error bodies — all three false-positive scenarios fire.
Verified false positives
- Rate limit 429:
"Rate limit reached for gpt-4o on tokens per minute (TPM): Limit 30000"→ hint fires - Auth error:
"The provided authentication token is invalid"→ hint fires - OpenAI JSON body type field:
'{"type":"tokens","code":"rate_limit_exceeded"}'→ hint fires
| if any(x in low for x in ("context length", "context_length", "maximum context", | |
| "too long", "too many tokens", "length exceeded")): |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Rebased onto
mainafter PRs #11 and #12 merged. This PR now contains only the remaining delta:UC_BROWSER_UA) for CF-protectedopenai_compatupstreamsorchestrator_workerin/healthz,ultracode status, Windows-Status, docscontent=null, context-length error hints, testsPRs #11 (advertise
[1m]) and #12 (preserve global model) are already onmain— not duplicated here.Test plan
python3 test_proxy.pypython3 scripts/doctor.py --no-test --cibash -n bin/ultracode