class MiddlewareErrorError thrown when a middleware fails.
Use MiddlewareError.wrap() to create instances. The constructor is private
to ensure that GraphBubbleUp errors (like GraphInterrupt) are never wrapped.
The tool call that dispatched this subagent, as
{ type: "toolCall", tool_call_id }, or undefined when the originating
tool call could not be recovered (e.g. it was not triggered from a tool).
The message sent to the model explaining why the action was rejected.
The type or name of action being requested (e.g., "add_numbers").
Check if the error is a MiddlewareError.
Wrap an error in a MiddlewareError, unless it's a GraphBubbleUp error (like GraphInterrupt) which should propagate unchanged.