Skip to content

LangChain handlers fail open on API errors/QUARANTINE and skip non-string tool outputs #7

Closed

Description

@TARSDrakon

Residual behaviour in the LangChain integration after #3 (merged at ba0513fc), confirmed by an independent review of the v0.4.0 release PR #6 at 3b72e646d5e5e9aa1996c5cac382537c67143978. Both are documented honestly in the module docstring today; this issue tracks changing the behaviour.

  1. API errors and QUARANTINE let content through, even with raise_on_block=True. _http maps every non-2xx response to a ShieldCortexError subclass, and client.py / async_client.py wrap httpx.TimeoutException as ShieldCortexError. The callback handlers log and skip ShieldCortexError, so 401, 429, 5xx and timeouts all fail open. Only raw connection errors propagate. QUARANTINE verdicts are not acted on ("Only BLOCK verdicts act today").
  2. Non-string tool outputs are not scanned. on_tool_end scans only str output (integrations/langchain.py around lines 168-170 and 230-232), so a ToolMessage or other structured output passes unscanned.

Acceptance:

  • An explicit, documented choice for API-error handling when raise_on_block=True (for example a fail_closed option, or raising on errors when blocking is requested), with sync and async tests for 401, 5xx and timeout.
  • QUARANTINE either acted on or explicitly configurable, with tests.
  • ToolMessage / structured tool outputs reduced to text and scanned, with a test using a LangChain fake tool.
  • CHANGELOG states the behaviour change plainly.

Activity

  1. added
    bug
    on Oct 16, 2026
  2. TARSDrakon commented on Oct 17, 2026

    @TARSDrakon
    ContributorAuthor

    Picked up by the improvement loop (TARS).

  3. added
    loop:in-progress
    on Oct 17, 2026
  4. removed
    loop:in-progress
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions