struct

Crig::AgentBuilder(M)

Inherits Struct < Value < Object

Builder for the core agent runtime. AgentBuilder is the main ergonomic surface for composing preambles, context, tools, dynamic retrieval, output schemas, and generation parameters before producing a concrete Agent.

Constructors

new(model : M, name_value : String | Nil = nil, description_value : String | Nil = nil, preamble_value : String | Nil = nil, static_context_value : Array(Crig::Completion::Request::Document) = [] of Crig::Completion::Request::Document, dynamic_context_value : Array(DynamicContextSource) = [] of DynamicContextSource, static_tools_value : Array(Crig::Completion::ToolDefinition) = [] of Crig::Completion::ToolDefinition, dynamic_tools_value : Array(DynamicToolSource) = [] of DynamicToolSource, tool_server_handle_value : ToolServerHandle | Nil = nil, additional_params_value : JSON::Any | Nil = nil, max_tokens_value : Int64 | Nil = nil, default_max_turns_value : Int32 | Nil = nil, temperature_value : Float64 | Nil = nil, tool_choice_value : Crig::Completion::ToolChoice | Nil = nil, output_schema_value : JSON::Any | Nil = nil, memory_value : Crig::Memory::ConversationMemory | Nil = nil, default_conversation_id_value : String | Nil = nil, hook_value : AgentHook | Nil = nil)
Source

Instance methods

additional_params(params : JSON::Any) : self
Source
additional_params_value
Source
append_preamble(doc : String) : self
Source
build
Source
context(doc : String) : self

Add static context that will be normalized into request documents.

Source
conversation_id(id : String) : self

Set a default conversation id used when none is provided per-request. Can be overridden per-request via PromptRequest#conversation.

Source
default_conversation_id_value
Source
default_max_turns(default_max_turns : Int32) : self
Source
default_max_turns_value
Source
description(description : String) : self
Source
description_value
Source
dynamic_context(sample : Int32, dynamic_context) : self

Register a dynamic context source queried at prompt time.

Source
dynamic_context_value
Source
dynamic_tools(sample : Int32, dynamic_tools, tools : Array(Crig::Completion::ToolDefinition)) : self

Register a dynamic tool source queried from vector search at prompt time.

Source
dynamic_tools(sample : Int32, dynamic_tools, toolset : Crig::ToolSet) : self

Register a dynamic tool source queried from vector search at prompt time using the same ToolSet-oriented surface as the upstream Rust builder.

Source
dynamic_tools_value
Source
hook(hook : AgentHook) : self
Source
hook_value
Source
max_tokens(max_tokens : Int64) : self
Source
max_tokens_value
Source
memory(memory : Crig::Memory::ConversationMemory) : self

Attach a ConversationMemory backend. When set, the agent will automatically load prior conversation history before sending a prompt and append new messages after a successful turn. A conversation_id must be supplied either via #conversation_id on the builder or per-request via PromptRequest#conversation. If neither is set, memory is silently bypassed.

Source
memory_value
Source
model
Source
name(name : String) : self
Source
name_value
Source
output_schema(output_schema : JSON::Any) : self
Source
output_schema(type : T.class) : self forall T

Build a JSON schema from a Crystal type for structured output requests.

Source
output_schema_value
Source
preamble(preamble : String) : self
Source
preamble_value
Source
retrieved_tools(sample : Int32, index, tools : Array(Crig::Completion::ToolDefinition)) : self

Upstream alias: dynamic_tools → retrieved_tools (v0.41.0)

Source
retrieved_tools(sample : Int32, index, toolset : Crig::ToolSet) : self

Upstream alias: dynamic_tools → retrieved_tools for ToolSet variant (v0.41.0)

Source
rmcp_tool(tool : MCP::Protocol::Tool, client : MCP::Client::Client) : self
Source
rmcp_tools(tools : Array(MCP::Protocol::Tool), client : MCP::Client::Client) : self
Source
static_context_value
Source
static_tools_value
Source
temperature(temperature : Float64) : self
Source
temperature_value
Source
tool(tool : Crig::Agent(T)) : self forall T

Add a nested agent as a callable tool (upstream into_tool).

Source

Add a tool definition directly without an executable runtime implementation.

Source
tool(tool : Crig::ToolDyn) : self

Add an executable tool and route it through the shared tool server runtime.

Source
tool_choice(tool_choice : Crig::Completion::ToolChoice) : self
Source
tool_choice_value
Source
tool_server_handle(handle : ToolServerHandle) : self
Source
tool_server_handle_value
Source
tools(tools : Array(Crig::Agent(T))) : self forall T

Deprecated: use repeated .tool(...) calls instead.

Source

Deprecated: use repeated .tool(...) calls instead. tools(Vec) was removed in upstream v0.41.0 — prefer .tool(...) for clarity.

Source
tools(tools : Array(Crig::ToolDyn)) : self

Deprecated: use repeated .tool(...) calls instead.

Source
without_preamble
Source