Skip to content

Preserve raised capability exceptions in private inspection #1288

Description

@andreasronge

Problem

Dispatcher.safely_invoke/3 collapses every raised callback exception to a closed marker:

rescue
  _exception -> {:raised, :exception}

The public Lisp envelope should remain bounded and closed, but the exception message and stacktrace are discarded from every observability plane. Diagnosing #1287 required patching the rescue clause and rerunning a live workload until the failure reproduced.

This affects any raising capability, not only ReqLLM or Finch.

Scope

Before returning {:raised, :exception}, capture the exception class, bounded message, and formatted stacktrace in a private inspection record correlated with the capability invocation.

Public behavior does not change:

  • Lisp still receives the existing closed provider_error / exception envelope.
  • Canonical events do not receive exception text or stacktraces.
  • No new retry or recovery policy is introduced.
  • The private payload remains bounded and is treated as potentially sensitive. The runtime must not append known credentials, transport configuration, or request payloads to it; arbitrary exception text cannot be reliably redacted, which is why this evidence exists only under private-inspection authority.

Acceptance criteria

  • A capability callback that raises produces a correlated private diagnostic containing a bounded exception class, message, and stacktrace.
  • The public capability result remains closed and byte-for-byte compatible in shape.
  • Inspection-disabled runs retain no exception details.
  • Inspection sink failure follows the existing terminal inspection-failure contract.
  • Tests cover raise, exit, and throw deliberately; only the exception path receives exception formatting unless a safe equivalent is explicitly designed for the others.
  • Trace and inspection documentation describe the disclosure boundary.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions