fix(proxy): log all Caido SDK errors as warnings

This commit is contained in:
Ian 2026-10-12 15:00:00 -04:00
parent b58d3ac3c6
commit 98707a785a
2 changed files with 7 additions and 9 deletions

View file

@ -13,6 +13,7 @@ from datetime import datetime
from typing import TYPE_CHECKING, Any, Literal
from agents import RunContextWrapper, function_tool
from caido_sdk_client import BaseError
from strix.runtime.caido_handle import CaidoBootstrapHandle
from strix.tools.nullish import clean_optional
@ -124,9 +125,9 @@ def _no_client() -> str:
def _err(name: str, exc: Exception) -> str:
# The Caido SDK wraps its GraphQL timeout in an error with an empty message.
if isinstance(exc.__cause__, TimeoutError):
logger.warning("%s timed out", name)
# Caido-side failures (timeouts, bad filters, ...) are returned to the model, not our bugs.
if isinstance(exc, BaseError):
logger.warning("%s failed", name, exc_info=True)
else:
logger.exception("%s failed", name)
return json.dumps(

View file

@ -13,6 +13,7 @@ from types import SimpleNamespace
from typing import TYPE_CHECKING, Any, cast
import pytest
from caido_sdk_client.errors import OperationUserError
from strix.runtime.caido_handle import CaidoBootstrapHandle
from strix.tools.proxy import caido_api, tools
@ -254,13 +255,9 @@ async def test_existing_request_ids_queries_current_project(
assert looked_up == ["1042", "1088"]
def test_err_logs_caido_timeout_as_warning(caplog: pytest.LogCaptureFixture) -> None:
exc = RuntimeError()
exc.__cause__ = TimeoutError()
def test_err_logs_caido_errors_as_warnings(caplog: pytest.LogCaptureFixture) -> None:
with caplog.at_level("WARNING", logger="strix.tools.proxy.tools"):
tools._err("list_requests", exc)
tools._err("list_requests", OperationUserError(""))
[record] = caplog.records
assert record.levelname == "WARNING"
assert record.exc_info is None