Error 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.
class MiddlewareErrorThe message sent to the model explaining why the action was rejected.
The name of the tool being called
Type guard to check if an object is an AIMessage. Preserves the MessageStructure type parameter when called with a typed BaseMessage. When called with a typed BaseMessage, preserves the TStructure type
Wrap an error in a MiddlewareError, unless it's a GraphBubbleUp error (like GraphInterrupt) which should propagate unchanged.