WardrikCore. Middleware behaviour
(wardrik_core v0.1.0-rc.3)
Copy Markdown
Wraps every step of a turn: the turn, each model call and each tool call.
defmodule MyApp.NoShell do
@behaviour WardrikCore.Middleware
@impl true
def call(%{step: {:tool_call, %{name: "shell"}}} = context, _next, _opts),
do: {:ok, %{context | response: {:error, "No shell."}}}
def call(context, next, _opts), do: next.(context)
endGive it to an agent as middleware: [MyApp.NoShell] or [{MyApp.NoShell, opts}]. The first runs
outermost.
Return values
next.(context)- carries on.{:ok, context}- answers the step withcontext.response.{:park, reason, context}- waits forWardrikCore.resume/3.{:error, reason}- ends the step.
Summary
Callbacks
Handles one step. Call next to carry on, or return a result to stop.