strix/strix/tools
0xallam fdd8b71f4e Stop web_search from leaking upstream details into tool results
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>
2026-05-25 02:13:43 -07:00
..
agents_graph Agents graph sweep: status taxonomy, stop_agent safety, skill validation 2026-05-25 01:35:57 -07:00
finish chore: remove generated migration docs 2026-04-26 14:36:58 -07:00
notes Align note IDs with todo IDs (6-char hex) 2026-05-24 18:10:57 -07:00
proxy Document HTTPQL footguns on list_requests 2026-05-25 00:29:27 -07:00
reporting chore: remove generated migration docs 2026-04-26 14:36:58 -07:00
thinking Tighten todo + think tool contracts 2026-05-24 16:58:09 -07:00
todo Tighten todo + think tool contracts 2026-05-24 16:58:09 -07:00
web_search Stop web_search from leaking upstream details into tool results 2026-05-25 02:13:43 -07:00
__init__.py refactor: nuke `strix_tool` shim + dead package re-exports 2026-04-25 15:17:46 -07:00