pig/agent/effect
Effect types for the sans-IO agent core.
Effects are declarations of intent — the core describes what it wants done, and a runtime interprets these effects against the real world.
Two effects cover the entire agent loop:
CallProvider — send messages to the LLM
ExecuteTools — run tool calls
The on_response / on_results callbacks wrap results into the
core’s message type, closing the loop without the core knowing
how the effects were executed.
Types
An effect request from the pure core. The runtime interprets these.
pub type Effect(msg) {
CallProvider(
messages: List(message.Message),
tools: List(tool_definition.ToolDefinition),
on_response: fn(
Result(provider.InferenceResult, error.AiError),
) -> msg,
)
ExecuteTools(
calls: List(message.ToolCall),
on_results: fn(
List(#(message.ToolCall, Result(json.Json, tool.ToolError))),
) -> msg,
)
}
Constructors
-
CallProvider( messages: List(message.Message), tools: List(tool_definition.ToolDefinition), on_response: fn(Result(provider.InferenceResult, error.AiError)) -> msg, )Send messages and tool definitions to the LLM provider. The runtime calls the provider function, then feeds the response back via the
on_responsecallback. -
ExecuteTools( calls: List(message.ToolCall), on_results: fn( List(#(message.ToolCall, Result(json.Json, tool.ToolError))), ) -> msg, )Execute a list of tool calls. The runtime runs each tool (possibly in parallel), then feeds all results back via the
on_resultscallback.