mirror of
https://github.com/usestrix/strix.git
synced 2026-09-06 08:15:56 +00:00
Failure messages were echoing the raw requests-exception text — for an empty query the model would see "API request failed: 400 Client Error: Bad Request for url: https://api.perplexity.ai/chat/completions" and learn the upstream URL, the HTTP status, and the literal word "API" none of which it has any use for or right to. Same pattern in every except branch: KeyError leaked internal field names, generic exceptions leaked library exception text, etc. Two fixes: - Pre-flight reject empty/whitespace queries so the trivial misuse case never hits the network at all and gets a "Query cannot be empty." result immediately. - Sanitize every failure path: split RequestException into HTTPError (4xx → "rejected the query — refine and retry", 5xx → "service unavailable"), Timeout, ConnectionError, response-shape (KeyError / IndexError / ValueError), and a generic catch-all. Each path returns a short actionable message and logs the full traceback via logger.exception so operator-side observability is preserved. The model sees no URLs, no status codes, no library exception text. While in here: the missing-API-key message keeps the env var name because that's operator-actionable, and the dead "results": [] field the failure paths used to carry is dropped (success path never had it either, so the shape was inconsistent). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| agents_graph | ||
| finish | ||
| notes | ||
| proxy | ||
| reporting | ||
| thinking | ||
| todo | ||
| web_search | ||
| __init__.py | ||