Packages

Secure BEAM sandbox runtime for LLM code mode and MCP aggregation. Run concurrent LLM/tool clients safely while agents orchestrate approved tools, call upstream MCP/OpenAPI servers, and transform data.

Current section

Files

Jump to
ptc_runner lib ptc_runner lisp tool_execution_error.ex
Raw

lib/ptc_runner/lisp/tool_execution_error.ex

defmodule PtcRunner.ToolExecutionError do
@moduledoc """
Exception raised when a tool execution fails.
Carries the eval context so that tool calls can be properly recorded in traces
even when the tool fails.
## Fields
- `message`: Error message from the tool
- `eval_ctx`: The evaluation context at time of failure (contains recorded tool_calls)
- `tool_name`: Name of the tool that failed
"""
defexception [:message, :eval_ctx, :tool_name]
@impl true
def exception(term) do
case term do
attrs when is_map(attrs) ->
msg = attrs[:message] || "Tool execution failed"
%__MODULE__{
message: msg,
eval_ctx: attrs[:eval_ctx],
tool_name: attrs[:tool_name]
}
attrs when is_list(attrs) ->
msg = Keyword.get(attrs, :message, "Tool execution failed")
%__MODULE__{
message: msg,
eval_ctx: Keyword.get(attrs, :eval_ctx),
tool_name: Keyword.get(attrs, :tool_name)
}
msg when is_binary(msg) ->
%__MODULE__{message: msg, eval_ctx: nil, tool_name: nil}
end
end
end