#github.com/xulang-org/packages/agent
Xu 0.16.0 API
import: agent #github.com/xulang-org/packages/agent
counts: 51 functions, 140 methods, 32 types, 0 constants, 0 method sets
External package `agent #github.com/xulang-org/packages/agent`, provided by github.com/xulang-org/packages.
github.com/xulang-org/packages · 1.17.2 · Install and use
struct LocalTool
pub struct LocalTool {
pub name string
pub description string
pub parameters_json string
pub handler fn(&string) string
}
Purpose
Structure encapsulating name, description, parameters_json, handler.
Public fields
name string- name
description string- field (string)
parameters_json string- field (string)
handler fn(&string) string- field (function value; type fn(&string) string)
struct Step
pub struct Step {
pub turn int
pub tool_name string
pub arguments_json string
pub output string
pub is_error bool
}
Purpose
Structure encapsulating turn, tool_name, arguments_json, output, is_error.
Public fields
turn int- field (int)
tool_name string- field (string)
arguments_json string- field (string)
output string- field (string)
is_error bool- field (bool)
struct RunResult
pub struct RunResult {
pub content string
pub reasoning_content string
pub steps []Step
pub turns int
pub prompt_tokens int
pub completion_tokens int
pub total_tokens int
pub finish_reason string
}
Purpose
Structure encapsulating content, reasoning_content, steps, turns, prompt_tokens.
Public fields
content string- field (string)
reasoning_content string- field (string)
steps []Step- field ([]Step)
turns int- field (int)
prompt_tokens int- field (int)
completion_tokens int- field (int)
total_tokens int- field (int)
finish_reason string- field (string)
struct AgentEvent
pub struct AgentEvent {
pub kind string
pub turn int
pub text_delta string
pub reasoning_delta string
pub tool_name string
pub arguments_json string
pub tool_output string
pub is_error bool
pub finish_reason string
}
Purpose
Structure encapsulating kind, turn, text_delta, reasoning_delta, tool_name.
Public fields
kind string- kind tag
turn int- field (int)
text_delta string- field (string)
reasoning_delta string- field (string)
tool_name string- field (string)
arguments_json string- field (string)
tool_output string- field (string)
is_error bool- field (bool)
finish_reason string- field (string)
struct Skill
pub struct Skill {
pub name string
pub description string
pub body string
pub path string
}
Purpose
Structure encapsulating name, description, body, path.
Public fields
name string- name
description string- field (string)
body string- body
path string- filesystem path
struct TraceSpan
pub struct TraceSpan {
pub trace_id string
pub kind string
pub name string
pub turn int
pub duration_ms int
pub tokens int
pub is_error bool
pub detail string
}
Purpose
Structure encapsulating trace_id, kind, name, turn, duration_ms.
Public fields
trace_id string- field (string)
kind string- kind tag
name string- name
turn int- field (int)
duration_ms int- field (int)
tokens int- field (int)
is_error bool- field (bool)
detail string- field (string)
struct AgentMemory
pub struct AgentMemory {
pub store rag.MemoryStore
}
Purpose
Structure encapsulating store.
Public fields
store rag.MemoryStore- field (rag.MemoryStore)
struct WorkflowStepResult
pub struct WorkflowStepResult {
pub agent_name string
pub result RunResult
}
Purpose
Structure encapsulating agent_name, result.
Public fields
agent_name string- field (string)
result RunResult- field (RunResult)
struct Agent
pub struct Agent {
pub client openai.Client
pub model string
pub system_prompt string
pub max_turns int
pub temperature f64
pub has_temperature bool
pub max_tokens int
pub max_total_tokens int
pub tool_choice string
pub response_format_json string
pub parallel_tools bool
pub context_max_tokens int
pub max_tool_output_chars int
pub progressive_skills bool
}
Purpose
Structure encapsulating client, model, system_prompt, max_turns, temperature.
Public fields
client openai.Client- field (openai.Client)
model string- field (string)
system_prompt string- field (string)
max_turns int- field (int)
temperature f64- field (f64)
has_temperature bool- field (bool)
max_tokens int- field (int)
max_total_tokens int- field (int)
tool_choice string- field (string)
response_format_json string- field (string)
parallel_tools bool- field (bool)
context_max_tokens int- field (int)
max_tool_output_chars int- field (int)
progressive_skills bool- field (bool)
new_agent
pub fn new_agent(client openai.Client, model string) Agent
Purpose
Construct agent.
Parameters
client openai.Client- client (openai.Client)
model string- model (string)
Returns
Agent — a value of this type
($&Agent) set_token_counter
pub fn (a $&Agent) set_token_counter(counter fn(&string) int)
Purpose
Operation on $&Agent: set token counter.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
counter fn(&string) int- counter (function value; type fn(&string) int)
Returns
This call does not return a value.
($&Agent) set_tool_hook
pub fn (a $&Agent) set_tool_hook(hook fn(&string, &string) string)
Purpose
Operation on $&Agent: set tool hook.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
hook fn(&string, &string) string- hook (function value; type fn(&string, &string) string)
Returns
This call does not return a value.
($&Agent) add_skill
pub fn (a $&Agent) add_skill(skill Skill)
Purpose
Operation on $&Agent: add skill.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
skill Skill- skill (Skill)
Returns
This call does not return a value.
($&Agent) set_context_budget
pub fn (a $&Agent) set_context_budget(max_tokens int, max_tool_output_chars int)
Purpose
Operation on $&Agent: set context budget.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
max_tokens int- max_tokens (int)
max_tool_output_chars int- max_tool_output_chars (int)
Returns
This call does not return a value.
($&Agent) set_progressive_skills
pub fn (a $&Agent) set_progressive_skills(enabled bool)
Purpose
Operation on $&Agent: set progressive skills.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&Agent) set_guardrails_policy
pub fn (a $&Agent) set_guardrails_policy(policy guardrails.Policy)
Purpose
Operation on $&Agent: set guardrails policy.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
policy guardrails.Policy- policy (guardrails.Policy)
Returns
This call does not return a value.
($&Agent) set_trace_hook
pub fn (a $&Agent) set_trace_hook(hook fn(TraceSpan))
Purpose
Operation on $&Agent: set trace hook.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
hook fn(TraceSpan)- hook (function value; type fn(TraceSpan))
Returns
This call does not return a value.
($&Agent) set_approval_hook
pub fn (a $&Agent) set_approval_hook(hook fn(&string, &string) bool)
Purpose
Operation on $&Agent: set approval hook.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
hook fn(&string, &string) bool- hook (function value; type fn(&string, &string) bool)
Returns
This call does not return a value.
($&Agent) set_system_prompt
pub fn (a $&Agent) set_system_prompt(prompt string)
Purpose
Operation on $&Agent: set system prompt.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
prompt string- prompt (string)
Returns
This call does not return a value.
($&Agent) set_max_turns
pub fn (a $&Agent) set_max_turns(max_turns int)
Purpose
Operation on $&Agent: set max turns.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
max_turns int- max_turns (int)
Returns
This call does not return a value.
($&Agent) set_temperature
pub fn (a $&Agent) set_temperature(t f64)
Purpose
Operation on $&Agent: set temperature.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
t f64- t (f64)
Returns
This call does not return a value.
($&Agent) set_max_tokens
pub fn (a $&Agent) set_max_tokens(n int)
Purpose
Operation on $&Agent: set max tokens.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&Agent) set_max_total_tokens
pub fn (a $&Agent) set_max_total_tokens(n int)
Purpose
Operation on $&Agent: set max total tokens.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&Agent) set_tool_choice
pub fn (a $&Agent) set_tool_choice(choice string)
Purpose
Operation on $&Agent: set tool choice.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
choice string- choice (string)
Returns
This call does not return a value.
($&Agent) set_response_format
pub fn (a $&Agent) set_response_format(format_json string)
Purpose
Operation on $&Agent: set response format.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
format_json string- format_json (string)
Returns
This call does not return a value.
($&Agent) set_parallel_tools
pub fn (a $&Agent) set_parallel_tools(enabled bool)
Purpose
Operation on $&Agent: set parallel tools.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&Agent) add_tool
pub fn (a $&Agent) add_tool(name string, description string, parameters_json string, handler fn(&string) string)
Purpose
Operation on $&Agent: add tool.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
name string- name (string)
description string- description (string)
parameters_json string- parameters_json (string)
handler fn(&string) string- handler (function value; type fn(&string) string)
Returns
This call does not return a value.
from_mcp_tools
pub fn from_mcp_tools(tools &[]mcp.ToolInfo) []openai.ToolDef
Purpose
Build from mcp tools.
Parameters
tools &[]mcp.ToolInfo- tools (read-only borrow; caller keeps the original; type &[]mcp.ToolInfo)
Returns
[]openai.ToolDef — slice result
from_mcp_anthropic_tools
pub fn from_mcp_anthropic_tools(tools &[]mcp.ToolInfo) []anthropic.Tool
Purpose
Build from mcp anthropic tools.
Parameters
tools &[]mcp.ToolInfo- tools (read-only borrow; caller keeps the original; type &[]mcp.ToolInfo)
Returns
[]anthropic.Tool — slice result
struct Session
pub struct Session {
pub agent Agent
}
Purpose
Structure encapsulating agent.
Public fields
agent Agent- field (Agent)
new_session
pub fn new_session(agent Agent) Session
Purpose
Construct session.
Parameters
agent Agent- agent (Agent)
Returns
Session — a value of this type
($&Session) clear
pub fn (s $&Session) clear()
Purpose
Clear all buffered or stored entries and internal state.
Parameters
s $&Session- The
Session instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&Session) history
pub fn (s &Session) history() []openai.Message
Purpose
Execute history on &Session.
Parameters
s &Session- The
Session instance used by this call (borrow).
Returns
[]openai.Message — slice result
($&Session) send
pub fn (s $&Session) send(user_prompt string) RunResult
Purpose
Execute send on $&Session. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&Session- The
Session instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
Returns
RunResult — a value of this type
($&Session) send_with_mcp
pub fn (s $&Session) send_with_mcp(user_prompt string, mc $&mcp.Client) RunResult
Purpose
Operation on $&Session: send with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&Session- The
Session instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
Returns
RunResult — a value of this type
($&Session) send_with_stdio_mcp
pub fn (s $&Session) send_with_stdio_mcp(user_prompt string, mc $&mcp.StdioClient) RunResult
Purpose
Operation on $&Session: send with stdio mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&Session- The
Session instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.StdioClient- mc (exclusive borrow; may modify the original; type $&mcp.StdioClient)
Returns
RunResult — a value of this type
($&Session) send_stream
pub fn (s $&Session) send_stream(user_prompt string, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on $&Session: send stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&Session- The
Session instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
($&Session) send_stream_with_mcp
pub fn (s $&Session) send_stream_with_mcp(user_prompt string, mc $&mcp.Client, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on $&Session: send stream with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&Session- The
Session instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
(&Agent) run
pub fn (a &Agent) run(user_prompt string) RunResult
Purpose
Execute run on &Agent. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &Agent- The
Agent instance used by this call (borrow).
user_prompt string- user_prompt (string)
Returns
RunResult — a value of this type
(&Agent) run_with_mcp
pub fn (a &Agent) run_with_mcp(user_prompt string, mc $&mcp.Client) RunResult
Purpose
Operation on &Agent: run with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &Agent- The
Agent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
Returns
RunResult — a value of this type
(&Agent) run_with_stdio_mcp
pub fn (a &Agent) run_with_stdio_mcp(user_prompt string, mc $&mcp.StdioClient) RunResult
Purpose
Operation on &Agent: run with stdio mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &Agent- The
Agent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.StdioClient- mc (exclusive borrow; may modify the original; type $&mcp.StdioClient)
Returns
RunResult — a value of this type
(&Agent) run_stream
pub fn (a &Agent) run_stream(user_prompt string, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &Agent: run stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &Agent- The
Agent instance used by this call (borrow).
user_prompt string- user_prompt (string)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
(&Agent) run_stream_with_mcp
pub fn (a &Agent) run_stream_with_mcp(user_prompt string, mc $&mcp.Client, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &Agent: run stream with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &Agent- The
Agent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
(&Agent) run_stream_with_stdio_mcp
pub fn (a &Agent) run_stream_with_stdio_mcp(user_prompt string, mc $&mcp.StdioClient, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &Agent: run stream with stdio mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &Agent- The
Agent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.StdioClient- mc (exclusive borrow; may modify the original; type $&mcp.StdioClient)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
struct AnthropicAgent
pub struct AnthropicAgent {
pub client anthropic.Client
pub model string
pub system_prompt string
pub max_turns int
pub max_tokens int
pub max_total_tokens int
pub temperature f64
pub has_temperature bool
pub thinking_budget_tokens int
pub parallel_tools bool
pub context_max_tokens int
pub max_tool_output_chars int
pub progressive_skills bool
}
Purpose
Structure encapsulating client, model, system_prompt, max_turns, max_tokens.
Public fields
client anthropic.Client- field (anthropic.Client)
model string- field (string)
system_prompt string- field (string)
max_turns int- field (int)
max_tokens int- field (int)
max_total_tokens int- field (int)
temperature f64- field (f64)
has_temperature bool- field (bool)
thinking_budget_tokens int- field (int)
parallel_tools bool- field (bool)
context_max_tokens int- field (int)
max_tool_output_chars int- field (int)
progressive_skills bool- field (bool)
new_anthropic_agent
pub fn new_anthropic_agent(client anthropic.Client, model string) AnthropicAgent
Purpose
Construct anthropic agent.
Parameters
client anthropic.Client- client (anthropic.Client)
model string- model (string)
Returns
AnthropicAgent — a value of this type
($&AnthropicAgent) set_token_counter
pub fn (a $&AnthropicAgent) set_token_counter(counter fn(&string) int)
Purpose
Operation on $&AnthropicAgent: set token counter.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
counter fn(&string) int- counter (function value; type fn(&string) int)
Returns
This call does not return a value.
($&AnthropicAgent) set_tool_hook
pub fn (a $&AnthropicAgent) set_tool_hook(hook fn(&string, &string) string)
Purpose
Operation on $&AnthropicAgent: set tool hook.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
hook fn(&string, &string) string- hook (function value; type fn(&string, &string) string)
Returns
This call does not return a value.
($&AnthropicAgent) add_skill
pub fn (a $&AnthropicAgent) add_skill(skill Skill)
Purpose
Operation on $&AnthropicAgent: add skill.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
skill Skill- skill (Skill)
Returns
This call does not return a value.
($&AnthropicAgent) load_skills_dir
pub fn (a $&AnthropicAgent) load_skills_dir(dir_path string) int
Purpose
Operation on $&AnthropicAgent: load skills directory. Throws on failure; handle the error or propagate it to the caller.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
dir_path string- dir_path (string)
Returns
int — a value of this type
($&AnthropicAgent) set_progressive_skills
pub fn (a $&AnthropicAgent) set_progressive_skills(enabled bool)
Purpose
Operation on $&AnthropicAgent: set progressive skills.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&AnthropicAgent) set_context_budget
pub fn (a $&AnthropicAgent) set_context_budget(max_tokens int, max_tool_output_chars int)
Purpose
Operation on $&AnthropicAgent: set context budget.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
max_tokens int- max_tokens (int)
max_tool_output_chars int- max_tool_output_chars (int)
Returns
This call does not return a value.
($&AnthropicAgent) set_guardrails_policy
pub fn (a $&AnthropicAgent) set_guardrails_policy(policy guardrails.Policy)
Purpose
Operation on $&AnthropicAgent: set guardrails policy.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
policy guardrails.Policy- policy (guardrails.Policy)
Returns
This call does not return a value.
($&AnthropicAgent) set_trace_hook
pub fn (a $&AnthropicAgent) set_trace_hook(hook fn(TraceSpan))
Purpose
Operation on $&AnthropicAgent: set trace hook.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
hook fn(TraceSpan)- hook (function value; type fn(TraceSpan))
Returns
This call does not return a value.
($&AnthropicAgent) set_approval_hook
pub fn (a $&AnthropicAgent) set_approval_hook(hook fn(&string, &string) bool)
Purpose
Operation on $&AnthropicAgent: set approval hook.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
hook fn(&string, &string) bool- hook (function value; type fn(&string, &string) bool)
Returns
This call does not return a value.
($&AnthropicAgent) set_system_prompt
pub fn (a $&AnthropicAgent) set_system_prompt(prompt string)
Purpose
Operation on $&AnthropicAgent: set system prompt.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
prompt string- prompt (string)
Returns
This call does not return a value.
($&AnthropicAgent) set_max_turns
pub fn (a $&AnthropicAgent) set_max_turns(max_turns int)
Purpose
Operation on $&AnthropicAgent: set max turns.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
max_turns int- max_turns (int)
Returns
This call does not return a value.
($&AnthropicAgent) set_max_tokens
pub fn (a $&AnthropicAgent) set_max_tokens(n int)
Purpose
Operation on $&AnthropicAgent: set max tokens.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&AnthropicAgent) set_max_total_tokens
pub fn (a $&AnthropicAgent) set_max_total_tokens(n int)
Purpose
Operation on $&AnthropicAgent: set max total tokens.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&AnthropicAgent) set_temperature
pub fn (a $&AnthropicAgent) set_temperature(t f64)
Purpose
Operation on $&AnthropicAgent: set temperature.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
t f64- t (f64)
Returns
This call does not return a value.
($&AnthropicAgent) set_thinking_budget
pub fn (a $&AnthropicAgent) set_thinking_budget(tokens int)
Purpose
Operation on $&AnthropicAgent: set thinking budget.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
tokens int- tokens (int)
Returns
This call does not return a value.
($&AnthropicAgent) set_parallel_tools
pub fn (a $&AnthropicAgent) set_parallel_tools(enabled bool)
Purpose
Operation on $&AnthropicAgent: set parallel tools.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&AnthropicAgent) add_tool
pub fn (a $&AnthropicAgent) add_tool(name string, description string, parameters_json string, handler fn(&string) string)
Purpose
Operation on $&AnthropicAgent: add tool.
Parameters
a $&AnthropicAgent- The
AnthropicAgent instance used by this call (exclusive borrow).
name string- name (string)
description string- description (string)
parameters_json string- parameters_json (string)
handler fn(&string) string- handler (function value; type fn(&string) string)
Returns
This call does not return a value.
compact_anthropic_messages_with
pub fn compact_anthropic_messages_with(messages &[]anthropic.Message, max_tokens int, keep_recent int, counter fn(&string) int) []anthropic.Message
Purpose
Compact anthropic messages with.
Parameters
messages &[]anthropic.Message- messages (read-only borrow; caller keeps the original; type &[]anthropic.Message)
max_tokens int- max_tokens (int)
keep_recent int- keep_recent (int)
counter fn(&string) int- counter (function value; type fn(&string) int)
Returns
[]anthropic.Message — slice result
compact_anthropic_messages
pub fn compact_anthropic_messages(messages &[]anthropic.Message, max_tokens int, keep_recent int) []anthropic.Message
Purpose
Compact anthropic messages.
Parameters
messages &[]anthropic.Message- messages (read-only borrow; caller keeps the original; type &[]anthropic.Message)
max_tokens int- max_tokens (int)
keep_recent int- keep_recent (int)
Returns
[]anthropic.Message — slice result
(&AnthropicAgent) run
pub fn (a &AnthropicAgent) run(user_prompt string) RunResult
Purpose
Execute run on &AnthropicAgent. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &AnthropicAgent- The
AnthropicAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
Returns
RunResult — a value of this type
(&AnthropicAgent) run_with_mcp
pub fn (a &AnthropicAgent) run_with_mcp(user_prompt string, mc $&mcp.Client) RunResult
Purpose
Operation on &AnthropicAgent: run with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &AnthropicAgent- The
AnthropicAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
Returns
RunResult — a value of this type
(&AnthropicAgent) run_stream
pub fn (a &AnthropicAgent) run_stream(user_prompt string, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &AnthropicAgent: run stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &AnthropicAgent- The
AnthropicAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
(&AnthropicAgent) run_stream_with_mcp
pub fn (a &AnthropicAgent) run_stream_with_mcp(user_prompt string, mc $&mcp.Client, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &AnthropicAgent: run stream with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &AnthropicAgent- The
AnthropicAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
struct AnthropicSession
pub struct AnthropicSession {
pub agent AnthropicAgent
}
Purpose
Structure encapsulating agent.
Public fields
agent AnthropicAgent- field (AnthropicAgent)
new_anthropic_session
pub fn new_anthropic_session(agent AnthropicAgent) AnthropicSession
Purpose
Construct anthropic session.
Parameters
agent AnthropicAgent- agent (AnthropicAgent)
Returns
AnthropicSession — a value of this type
($&AnthropicSession) clear
pub fn (s $&AnthropicSession) clear()
Purpose
Clear all buffered or stored entries and internal state.
Parameters
s $&AnthropicSession- The
AnthropicSession instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&AnthropicSession) history
pub fn (s &AnthropicSession) history() []anthropic.Message
Purpose
Execute history on &AnthropicSession.
Parameters
s &AnthropicSession- The
AnthropicSession instance used by this call (borrow).
Returns
[]anthropic.Message — slice result
($&AnthropicSession) send
pub fn (s $&AnthropicSession) send(user_prompt string) RunResult
Purpose
Execute send on $&AnthropicSession. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&AnthropicSession- The
AnthropicSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
Returns
RunResult — a value of this type
($&AnthropicSession) send_with_mcp
pub fn (s $&AnthropicSession) send_with_mcp(user_prompt string, mc $&mcp.Client) RunResult
Purpose
Operation on $&AnthropicSession: send with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&AnthropicSession- The
AnthropicSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
Returns
RunResult — a value of this type
($&AnthropicSession) send_stream
pub fn (s $&AnthropicSession) send_stream(user_prompt string, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on $&AnthropicSession: send stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&AnthropicSession- The
AnthropicSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
($&AnthropicSession) send_stream_with_mcp
pub fn (s $&AnthropicSession) send_stream_with_mcp(user_prompt string, mc $&mcp.Client, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on $&AnthropicSession: send stream with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&AnthropicSession- The
AnthropicSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
struct GeminiAgent
pub struct GeminiAgent {
pub client gemini.Client
pub model string
pub system_prompt string
pub max_turns int
pub max_tokens int
pub max_total_tokens int
pub temperature f64
pub has_temperature bool
pub thinking_budget int
pub parallel_tools bool
pub context_max_tokens int
pub max_tool_output_chars int
pub progressive_skills bool
}
Purpose
Structure encapsulating client, model, system_prompt, max_turns, max_tokens.
Public fields
client gemini.Client- field (gemini.Client)
model string- field (string)
system_prompt string- field (string)
max_turns int- field (int)
max_tokens int- field (int)
max_total_tokens int- field (int)
temperature f64- field (f64)
has_temperature bool- field (bool)
thinking_budget int- field (int)
parallel_tools bool- field (bool)
context_max_tokens int- field (int)
max_tool_output_chars int- field (int)
progressive_skills bool- field (bool)
new_gemini_agent
pub fn new_gemini_agent(client gemini.Client, model string) GeminiAgent
Purpose
Construct gemini agent.
Parameters
client gemini.Client- client (gemini.Client)
model string- model (string)
Returns
GeminiAgent — a value of this type
($&GeminiAgent) set_token_counter
pub fn (a $&GeminiAgent) set_token_counter(counter fn(&string) int)
Purpose
Operation on $&GeminiAgent: set token counter.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
counter fn(&string) int- counter (function value; type fn(&string) int)
Returns
This call does not return a value.
($&GeminiAgent) set_tool_hook
pub fn (a $&GeminiAgent) set_tool_hook(hook fn(&string, &string) string)
Purpose
Operation on $&GeminiAgent: set tool hook.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
hook fn(&string, &string) string- hook (function value; type fn(&string, &string) string)
Returns
This call does not return a value.
($&GeminiAgent) add_skill
pub fn (a $&GeminiAgent) add_skill(skill Skill)
Purpose
Operation on $&GeminiAgent: add skill.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
skill Skill- skill (Skill)
Returns
This call does not return a value.
($&GeminiAgent) load_skills_dir
pub fn (a $&GeminiAgent) load_skills_dir(dir_path string) int
Purpose
Operation on $&GeminiAgent: load skills directory. Throws on failure; handle the error or propagate it to the caller.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
dir_path string- dir_path (string)
Returns
int — a value of this type
($&GeminiAgent) set_progressive_skills
pub fn (a $&GeminiAgent) set_progressive_skills(enabled bool)
Purpose
Operation on $&GeminiAgent: set progressive skills.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&GeminiAgent) set_context_budget
pub fn (a $&GeminiAgent) set_context_budget(max_tokens int, max_tool_output_chars int)
Purpose
Operation on $&GeminiAgent: set context budget.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
max_tokens int- max_tokens (int)
max_tool_output_chars int- max_tool_output_chars (int)
Returns
This call does not return a value.
($&GeminiAgent) set_guardrails_policy
pub fn (a $&GeminiAgent) set_guardrails_policy(policy guardrails.Policy)
Purpose
Operation on $&GeminiAgent: set guardrails policy.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
policy guardrails.Policy- policy (guardrails.Policy)
Returns
This call does not return a value.
($&GeminiAgent) set_trace_hook
pub fn (a $&GeminiAgent) set_trace_hook(hook fn(TraceSpan))
Purpose
Operation on $&GeminiAgent: set trace hook.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
hook fn(TraceSpan)- hook (function value; type fn(TraceSpan))
Returns
This call does not return a value.
($&GeminiAgent) set_approval_hook
pub fn (a $&GeminiAgent) set_approval_hook(hook fn(&string, &string) bool)
Purpose
Operation on $&GeminiAgent: set approval hook.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
hook fn(&string, &string) bool- hook (function value; type fn(&string, &string) bool)
Returns
This call does not return a value.
($&GeminiAgent) set_system_prompt
pub fn (a $&GeminiAgent) set_system_prompt(prompt string)
Purpose
Operation on $&GeminiAgent: set system prompt.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
prompt string- prompt (string)
Returns
This call does not return a value.
($&GeminiAgent) set_max_turns
pub fn (a $&GeminiAgent) set_max_turns(max_turns int)
Purpose
Operation on $&GeminiAgent: set max turns.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
max_turns int- max_turns (int)
Returns
This call does not return a value.
($&GeminiAgent) set_max_tokens
pub fn (a $&GeminiAgent) set_max_tokens(n int)
Purpose
Operation on $&GeminiAgent: set max tokens.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&GeminiAgent) set_max_total_tokens
pub fn (a $&GeminiAgent) set_max_total_tokens(n int)
Purpose
Operation on $&GeminiAgent: set max total tokens.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&GeminiAgent) set_temperature
pub fn (a $&GeminiAgent) set_temperature(t f64)
Purpose
Operation on $&GeminiAgent: set temperature.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
t f64- t (f64)
Returns
This call does not return a value.
($&GeminiAgent) set_thinking_budget
pub fn (a $&GeminiAgent) set_thinking_budget(tokens int)
Purpose
Operation on $&GeminiAgent: set thinking budget.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
tokens int- tokens (int)
Returns
This call does not return a value.
($&GeminiAgent) set_parallel_tools
pub fn (a $&GeminiAgent) set_parallel_tools(enabled bool)
Purpose
Operation on $&GeminiAgent: set parallel tools.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&GeminiAgent) add_tool
pub fn (a $&GeminiAgent) add_tool(name string, description string, parameters_json string, handler fn(&string) string)
Purpose
Operation on $&GeminiAgent: add tool.
Parameters
a $&GeminiAgent- The
GeminiAgent instance used by this call (exclusive borrow).
name string- name (string)
description string- description (string)
parameters_json string- parameters_json (string)
handler fn(&string) string- handler (function value; type fn(&string) string)
Returns
This call does not return a value.
from_mcp_gemini_tools
pub fn from_mcp_gemini_tools(tools &[]mcp.ToolInfo) []gemini.FunctionDecl
Purpose
Build from mcp gemini tools.
Parameters
tools &[]mcp.ToolInfo- tools (read-only borrow; caller keeps the original; type &[]mcp.ToolInfo)
Returns
[]gemini.FunctionDecl — slice result
compact_gemini_contents_with
pub fn compact_gemini_contents_with(contents &[]gemini.Content, max_tokens int, keep_recent int, counter fn(&string) int) []gemini.Content
Purpose
Compact gemini contents with.
Parameters
contents &[]gemini.Content- contents (read-only borrow; caller keeps the original; type &[]gemini.Content)
max_tokens int- max_tokens (int)
keep_recent int- keep_recent (int)
counter fn(&string) int- counter (function value; type fn(&string) int)
Returns
[]gemini.Content — slice result
compact_gemini_contents
pub fn compact_gemini_contents(contents &[]gemini.Content, max_tokens int, keep_recent int) []gemini.Content
Purpose
Compact gemini contents.
Parameters
contents &[]gemini.Content- contents (read-only borrow; caller keeps the original; type &[]gemini.Content)
max_tokens int- max_tokens (int)
keep_recent int- keep_recent (int)
Returns
[]gemini.Content — slice result
(&GeminiAgent) run
pub fn (a &GeminiAgent) run(user_prompt string) RunResult
Purpose
Execute run on &GeminiAgent. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &GeminiAgent- The
GeminiAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
Returns
RunResult — a value of this type
(&GeminiAgent) run_with_mcp
pub fn (a &GeminiAgent) run_with_mcp(user_prompt string, mc $&mcp.Client) RunResult
Purpose
Operation on &GeminiAgent: run with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &GeminiAgent- The
GeminiAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
Returns
RunResult — a value of this type
(&GeminiAgent) run_with_stdio_mcp
pub fn (a &GeminiAgent) run_with_stdio_mcp(user_prompt string, mc $&mcp.StdioClient) RunResult
Purpose
Operation on &GeminiAgent: run with stdio mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &GeminiAgent- The
GeminiAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.StdioClient- mc (exclusive borrow; may modify the original; type $&mcp.StdioClient)
Returns
RunResult — a value of this type
(&GeminiAgent) run_stream
pub fn (a &GeminiAgent) run_stream(user_prompt string, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &GeminiAgent: run stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &GeminiAgent- The
GeminiAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
(&GeminiAgent) run_stream_with_mcp
pub fn (a &GeminiAgent) run_stream_with_mcp(user_prompt string, mc $&mcp.Client, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &GeminiAgent: run stream with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &GeminiAgent- The
GeminiAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
(&GeminiAgent) run_stream_with_stdio_mcp
pub fn (a &GeminiAgent) run_stream_with_stdio_mcp(user_prompt string, mc $&mcp.StdioClient, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &GeminiAgent: run stream with stdio mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &GeminiAgent- The
GeminiAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.StdioClient- mc (exclusive borrow; may modify the original; type $&mcp.StdioClient)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
struct GeminiSession
pub struct GeminiSession {
pub agent GeminiAgent
}
Purpose
Structure encapsulating agent.
Public fields
agent GeminiAgent- field (GeminiAgent)
new_gemini_session
pub fn new_gemini_session(agent GeminiAgent) GeminiSession
Purpose
Construct gemini session.
Parameters
agent GeminiAgent- agent (GeminiAgent)
Returns
GeminiSession — a value of this type
($&GeminiSession) clear
pub fn (s $&GeminiSession) clear()
Purpose
Clear all buffered or stored entries and internal state.
Parameters
s $&GeminiSession- The
GeminiSession instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&GeminiSession) history
pub fn (s &GeminiSession) history() []gemini.Content
Purpose
Execute history on &GeminiSession.
Parameters
s &GeminiSession- The
GeminiSession instance used by this call (borrow).
Returns
[]gemini.Content — slice result
($&GeminiSession) send
pub fn (s $&GeminiSession) send(user_prompt string) RunResult
Purpose
Execute send on $&GeminiSession. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&GeminiSession- The
GeminiSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
Returns
RunResult — a value of this type
($&GeminiSession) send_with_mcp
pub fn (s $&GeminiSession) send_with_mcp(user_prompt string, mc $&mcp.Client) RunResult
Purpose
Operation on $&GeminiSession: send with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&GeminiSession- The
GeminiSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
Returns
RunResult — a value of this type
($&GeminiSession) send_with_stdio_mcp
pub fn (s $&GeminiSession) send_with_stdio_mcp(user_prompt string, mc $&mcp.StdioClient) RunResult
Purpose
Operation on $&GeminiSession: send with stdio mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&GeminiSession- The
GeminiSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.StdioClient- mc (exclusive borrow; may modify the original; type $&mcp.StdioClient)
Returns
RunResult — a value of this type
($&GeminiSession) send_stream
pub fn (s $&GeminiSession) send_stream(user_prompt string, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on $&GeminiSession: send stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&GeminiSession- The
GeminiSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
($&GeminiSession) send_stream_with_mcp
pub fn (s $&GeminiSession) send_stream_with_mcp(user_prompt string, mc $&mcp.Client, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on $&GeminiSession: send stream with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&GeminiSession- The
GeminiSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
struct ResponsesAgent
pub struct ResponsesAgent {
pub client openai.Client
pub model string
pub instructions string
pub max_turns int
pub temperature f64
pub has_temperature bool
pub max_output_tokens int
pub max_total_tokens int
pub tool_choice string
pub parallel_tools bool
pub context_max_tokens int
pub max_tool_output_chars int
pub progressive_skills bool
}
Purpose
Structure encapsulating client, model, instructions, max_turns, temperature.
Public fields
client openai.Client- field (openai.Client)
model string- field (string)
instructions string- field (string)
max_turns int- field (int)
temperature f64- field (f64)
has_temperature bool- field (bool)
max_output_tokens int- field (int)
max_total_tokens int- field (int)
tool_choice string- field (string)
parallel_tools bool- field (bool)
context_max_tokens int- field (int)
max_tool_output_chars int- field (int)
progressive_skills bool- field (bool)
new_responses_agent
pub fn new_responses_agent(client openai.Client, model string) ResponsesAgent
Purpose
Construct responses agent.
Parameters
client openai.Client- client (openai.Client)
model string- model (string)
Returns
ResponsesAgent — a value of this type
($&ResponsesAgent) set_token_counter
pub fn (a $&ResponsesAgent) set_token_counter(counter fn(&string) int)
Purpose
Operation on $&ResponsesAgent: set token counter.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
counter fn(&string) int- counter (function value; type fn(&string) int)
Returns
This call does not return a value.
($&ResponsesAgent) set_instructions
pub fn (a $&ResponsesAgent) set_instructions(s string)
Purpose
Operation on $&ResponsesAgent: set instructions.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
s string- source string (string)
Returns
This call does not return a value.
($&ResponsesAgent) set_max_turns
pub fn (a $&ResponsesAgent) set_max_turns(n int)
Purpose
Operation on $&ResponsesAgent: set max turns.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&ResponsesAgent) set_temperature
pub fn (a $&ResponsesAgent) set_temperature(t f64)
Purpose
Operation on $&ResponsesAgent: set temperature.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
t f64- t (f64)
Returns
This call does not return a value.
($&ResponsesAgent) set_max_output_tokens
pub fn (a $&ResponsesAgent) set_max_output_tokens(n int)
Purpose
Operation on $&ResponsesAgent: set max output tokens.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&ResponsesAgent) set_max_total_tokens
pub fn (a $&ResponsesAgent) set_max_total_tokens(n int)
Purpose
Operation on $&ResponsesAgent: set max total tokens.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
n int- count, length, or limit (int)
Returns
This call does not return a value.
($&ResponsesAgent) set_tool_choice
pub fn (a $&ResponsesAgent) set_tool_choice(c string)
Purpose
Operation on $&ResponsesAgent: set tool choice.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
c string- byte or character code (string)
Returns
This call does not return a value.
($&ResponsesAgent) set_parallel_tools
pub fn (a $&ResponsesAgent) set_parallel_tools(enabled bool)
Purpose
Operation on $&ResponsesAgent: set parallel tools.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&ResponsesAgent) set_tool_hook
pub fn (a $&ResponsesAgent) set_tool_hook(hook fn(&string, &string) string)
Purpose
Operation on $&ResponsesAgent: set tool hook.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
hook fn(&string, &string) string- hook (function value; type fn(&string, &string) string)
Returns
This call does not return a value.
($&ResponsesAgent) add_skill
pub fn (a $&ResponsesAgent) add_skill(skill Skill)
Purpose
Operation on $&ResponsesAgent: add skill.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
skill Skill- skill (Skill)
Returns
This call does not return a value.
($&ResponsesAgent) load_skills_dir
pub fn (a $&ResponsesAgent) load_skills_dir(dir_path string) int
Purpose
Operation on $&ResponsesAgent: load skills directory. Throws on failure; handle the error or propagate it to the caller.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
dir_path string- dir_path (string)
Returns
int — a value of this type
($&ResponsesAgent) set_progressive_skills
pub fn (a $&ResponsesAgent) set_progressive_skills(enabled bool)
Purpose
Operation on $&ResponsesAgent: set progressive skills.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&ResponsesAgent) set_context_budget
pub fn (a $&ResponsesAgent) set_context_budget(max_tokens int, max_tool_output_chars int)
Purpose
Operation on $&ResponsesAgent: set context budget.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
max_tokens int- max_tokens (int)
max_tool_output_chars int- max_tool_output_chars (int)
Returns
This call does not return a value.
($&ResponsesAgent) set_guardrails_policy
pub fn (a $&ResponsesAgent) set_guardrails_policy(policy guardrails.Policy)
Purpose
Operation on $&ResponsesAgent: set guardrails policy.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
policy guardrails.Policy- policy (guardrails.Policy)
Returns
This call does not return a value.
($&ResponsesAgent) set_trace_hook
pub fn (a $&ResponsesAgent) set_trace_hook(hook fn(TraceSpan))
Purpose
Operation on $&ResponsesAgent: set trace hook.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
hook fn(TraceSpan)- hook (function value; type fn(TraceSpan))
Returns
This call does not return a value.
($&ResponsesAgent) set_approval_hook
pub fn (a $&ResponsesAgent) set_approval_hook(hook fn(&string, &string) bool)
Purpose
Operation on $&ResponsesAgent: set approval hook.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
hook fn(&string, &string) bool- hook (function value; type fn(&string, &string) bool)
Returns
This call does not return a value.
($&ResponsesAgent) add_tool
pub fn (a $&ResponsesAgent) add_tool(name string, description string, parameters_json string, handler fn(&string) string)
Purpose
Operation on $&ResponsesAgent: add tool.
Parameters
a $&ResponsesAgent- The
ResponsesAgent instance used by this call (exclusive borrow).
name string- name (string)
description string- description (string)
parameters_json string- parameters_json (string)
handler fn(&string) string- handler (function value; type fn(&string) string)
Returns
This call does not return a value.
(&ResponsesAgent) run
pub fn (a &ResponsesAgent) run(user_prompt string) RunResult
Purpose
Execute run on &ResponsesAgent. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &ResponsesAgent- The
ResponsesAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
Returns
RunResult — a value of this type
(&ResponsesAgent) run_with_mcp
pub fn (a &ResponsesAgent) run_with_mcp(user_prompt string, mc $&mcp.Client) RunResult
Purpose
Operation on &ResponsesAgent: run with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &ResponsesAgent- The
ResponsesAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
Returns
RunResult — a value of this type
(&ResponsesAgent) run_with_stdio_mcp
pub fn (a &ResponsesAgent) run_with_stdio_mcp(user_prompt string, mc $&mcp.StdioClient) RunResult
Purpose
Operation on &ResponsesAgent: run with stdio mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &ResponsesAgent- The
ResponsesAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.StdioClient- mc (exclusive borrow; may modify the original; type $&mcp.StdioClient)
Returns
RunResult — a value of this type
(&ResponsesAgent) run_stream
pub fn (a &ResponsesAgent) run_stream(user_prompt string, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &ResponsesAgent: run stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &ResponsesAgent- The
ResponsesAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
(&ResponsesAgent) run_stream_with_mcp
pub fn (a &ResponsesAgent) run_stream_with_mcp(user_prompt string, mc $&mcp.Client, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on &ResponsesAgent: run stream with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &ResponsesAgent- The
ResponsesAgent instance used by this call (borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
struct ResponsesSession
pub struct ResponsesSession {
pub agent ResponsesAgent
pub prev_response_id string
}
Purpose
Structure encapsulating agent, prev_response_id.
Public fields
agent ResponsesAgent- field (ResponsesAgent)
prev_response_id string- field (string)
new_responses_session
pub fn new_responses_session(agent ResponsesAgent) ResponsesSession
Purpose
Construct responses session.
Parameters
agent ResponsesAgent- agent (ResponsesAgent)
Returns
ResponsesSession — a value of this type
($&ResponsesSession) clear
pub fn (s $&ResponsesSession) clear()
Purpose
Clear all buffered or stored entries and internal state.
Parameters
s $&ResponsesSession- The
ResponsesSession instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&ResponsesSession) last_response_id
pub fn (s &ResponsesSession) last_response_id() string
Purpose
Operation on &ResponsesSession: last response id.
Parameters
s &ResponsesSession- The
ResponsesSession instance used by this call (borrow).
Returns
string — result string
($&ResponsesSession) send
pub fn (s $&ResponsesSession) send(user_prompt string) RunResult
Purpose
Execute send on $&ResponsesSession. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&ResponsesSession- The
ResponsesSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
Returns
RunResult — a value of this type
($&ResponsesSession) send_with_mcp
pub fn (s $&ResponsesSession) send_with_mcp(user_prompt string, mc $&mcp.Client) RunResult
Purpose
Operation on $&ResponsesSession: send with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&ResponsesSession- The
ResponsesSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
Returns
RunResult — a value of this type
($&ResponsesSession) send_with_stdio_mcp
pub fn (s $&ResponsesSession) send_with_stdio_mcp(user_prompt string, mc $&mcp.StdioClient) RunResult
Purpose
Operation on $&ResponsesSession: send with stdio mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&ResponsesSession- The
ResponsesSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.StdioClient- mc (exclusive borrow; may modify the original; type $&mcp.StdioClient)
Returns
RunResult — a value of this type
($&ResponsesSession) send_stream
pub fn (s $&ResponsesSession) send_stream(user_prompt string, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on $&ResponsesSession: send stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&ResponsesSession- The
ResponsesSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
($&ResponsesSession) send_stream_with_mcp
pub fn (s $&ResponsesSession) send_stream_with_mcp(user_prompt string, mc $&mcp.Client, on_event fn(AgentEvent) bool) RunResult
Purpose
Operation on $&ResponsesSession: send stream with mcp. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&ResponsesSession- The
ResponsesSession instance used by this call (exclusive borrow).
user_prompt string- user_prompt (string)
mc $&mcp.Client- mc (exclusive borrow; may modify the original; type $&mcp.Client)
on_event fn(AgentEvent) bool- on_event (function value; type fn(AgentEvent) bool)
Returns
RunResult — a value of this type
parse_skill_markdown
pub fn parse_skill_markdown(raw &string, path string) Skill
Purpose
Parse as skill markdown.
Parameters
raw &string- raw (read-only borrow; caller keeps the original; type &string)
path string- filesystem path (string)
Returns
Skill — a value of this type
load_skill_file
pub fn load_skill_file(path string) Skill
Purpose
Load skill file. Throws on failure; handle the error or propagate it to the caller.
Parameters
path string- filesystem path (string)
Returns
Skill — a value of this type
format_skills_prompt
pub fn format_skills_prompt(skills &[]Skill, user_prompt &string) string
Purpose
Format as skills prompt.
Parameters
skills &[]Skill- skills (read-only borrow; caller keeps the original; type &[]Skill)
user_prompt &string- user_prompt (read-only borrow; caller keeps the original; type &string)
Returns
string — result string
format_skills_catalog
pub fn format_skills_catalog(skills &[]Skill) string
Purpose
Format as skills catalog.
Parameters
skills &[]Skill- skills (read-only borrow; caller keeps the original; type &[]Skill)
Returns
string — result string
lookup_skill_body
pub fn lookup_skill_body(skills &[]Skill, name &string) string
Purpose
Lookup skill body.
Parameters
skills &[]Skill- skills (read-only borrow; caller keeps the original; type &[]Skill)
name &string- name (read-only borrow; caller keeps the original; type &string)
Returns
string — result string
new_memory
pub fn new_memory(dim int) AgentMemory
Purpose
Construct memory.
Parameters
dim int- dim (int)
Returns
AgentMemory — a value of this type
($&AgentMemory) remember
pub fn (m $&AgentMemory) remember(text string, tag string, embedding &[]f64) string
Purpose
Execute remember on $&AgentMemory. Throws on failure; handle the error or propagate it to the caller.
Parameters
m $&AgentMemory- The
AgentMemory instance used by this call (exclusive borrow).
text string- text (string)
tag string- tag (string)
embedding &[]f64- embedding (read-only borrow; caller keeps the original; type &[]f64)
Returns
string — result string
(&AgentMemory) recall
pub fn (m &AgentMemory) recall(query string, query_emb &[]f64, top_k int) []rag.SearchHit
Purpose
Execute recall on &AgentMemory.
Parameters
m &AgentMemory- The
AgentMemory instance used by this call (borrow).
query string- query (string)
query_emb &[]f64- query_emb (read-only borrow; caller keeps the original; type &[]f64)
top_k int- top_k (int)
Returns
[]rag.SearchHit — slice result
(&AgentMemory) format_memories
pub fn (m &AgentMemory) format_memories(hits &[]rag.SearchHit) string
Purpose
Operation on &AgentMemory: format as memories.
Parameters
m &AgentMemory- The
AgentMemory instance used by this call (borrow).
hits &[]rag.SearchHit- hits (read-only borrow; caller keeps the original; type &[]rag.SearchHit)
Returns
string — result string
($&AgentMemory) forget
pub fn (m $&AgentMemory) forget(id string) bool
Purpose
Execute forget on $&AgentMemory.
Parameters
m $&AgentMemory- The
AgentMemory instance used by this call (exclusive borrow).
id string- id (string)
Returns
bool — true or false
($&AgentMemory) update
pub fn (m $&AgentMemory) update(id string, text string, tag string, embedding &[]f64) bool
Purpose
Execute update on $&AgentMemory. Throws on failure; handle the error or propagate it to the caller.
Parameters
m $&AgentMemory- The
AgentMemory instance used by this call (exclusive borrow).
id string- id (string)
text string- text (string)
tag string- tag (string)
embedding &[]f64- embedding (read-only borrow; caller keeps the original; type &[]f64)
Returns
bool — true or false
(&AgentMemory) save_json
pub fn (m &AgentMemory) save_json(path string) int
Purpose
Operation on &AgentMemory: save json. Throws on failure; handle the error or propagate it to the caller.
Parameters
m &AgentMemory- The
AgentMemory instance used by this call (borrow).
path string- filesystem path (string)
Returns
int — a value of this type
load_memory_json
pub fn load_memory_json(path string) AgentMemory
Purpose
Load memory json. Throws on failure; handle the error or propagate it to the caller.
Parameters
path string- filesystem path (string)
Returns
AgentMemory — a value of this type
(&AgentMemory) save_sqlite
pub fn (m &AgentMemory) save_sqlite(path string) int
Purpose
Operation on &AgentMemory: save sqlite. Throws on failure; handle the error or propagate it to the caller.
Parameters
m &AgentMemory- The
AgentMemory instance used by this call (borrow).
path string- filesystem path (string)
Returns
int — a value of this type
load_memory_sqlite
pub fn load_memory_sqlite(path string) AgentMemory
Purpose
Load memory sqlite. Throws on failure; handle the error or propagate it to the caller.
Parameters
path string- filesystem path (string)
Returns
AgentMemory — a value of this type
estimate_tokens
pub fn estimate_tokens(text &string) int
Purpose
Estimate tokens.
Parameters
text &string- text (read-only borrow; caller keeps the original; type &string)
Returns
int — a value of this type
compact_messages_with
pub fn compact_messages_with(messages &[]openai.Message, max_tokens int, keep_recent int, counter fn(&string) int) []openai.Message
Purpose
Compact messages with.
Parameters
messages &[]openai.Message- messages (read-only borrow; caller keeps the original; type &[]openai.Message)
max_tokens int- max_tokens (int)
keep_recent int- keep_recent (int)
counter fn(&string) int- counter (function value; type fn(&string) int)
Returns
[]openai.Message — slice result
compact_messages
pub fn compact_messages(messages &[]openai.Message, max_tokens int, keep_recent int) []openai.Message
Purpose
Compact messages.
Parameters
messages &[]openai.Message- messages (read-only borrow; caller keeps the original; type &[]openai.Message)
max_tokens int- max_tokens (int)
keep_recent int- keep_recent (int)
Returns
[]openai.Message — slice result
summarize_messages_openai
pub fn summarize_messages_openai(client &openai.Client, model string, messages &[]openai.Message, keep_recent int) []openai.Message
Purpose
Summarize messages openai. Throws on failure; handle the error or propagate it to the caller.
Parameters
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
model string- model (string)
messages &[]openai.Message- messages (read-only borrow; caller keeps the original; type &[]openai.Message)
keep_recent int- keep_recent (int)
Returns
[]openai.Message — slice result
format_trace_jsonl
pub fn format_trace_jsonl(spans &[]TraceSpan) string
Purpose
Format as trace jsonl.
Parameters
spans &[]TraceSpan- spans (read-only borrow; caller keeps the original; type &[]TraceSpan)
Returns
string — result string
run_sequential_workflow
pub fn run_sequential_workflow(agents &[]Agent, names &[]string, initial_prompt string) []WorkflowStepResult
Purpose
Run sequential workflow. Throws on failure; handle the error or propagate it to the caller.
Parameters
agents &[]Agent- agents (read-only borrow; caller keeps the original; type &[]Agent)
names &[]string- names (read-only borrow; caller keeps the original; type &[]string)
initial_prompt string- initial_prompt (string)
Returns
[]WorkflowStepResult — slice result
run_router_workflow
pub fn run_router_workflow(router &Agent, specialists &[]Agent, specialist_names &[]string, user_prompt string) WorkflowStepResult
Purpose
Run router workflow. Throws on failure; handle the error or propagate it to the caller.
Parameters
router &Agent- router (read-only borrow; caller keeps the original; type &Agent)
specialists &[]Agent- specialists (read-only borrow; caller keeps the original; type &[]Agent)
specialist_names &[]string- specialist_names (read-only borrow; caller keeps the original; type &[]string)
user_prompt string- user_prompt (string)
Returns
WorkflowStepResult — a value of this type
(&Session) save_checkpoint_json
pub fn (s &Session) save_checkpoint_json(path string) int
Purpose
Operation on &Session: save checkpoint json. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &Session- The
Session instance used by this call (borrow).
path string- filesystem path (string)
Returns
int — a value of this type
load_session_checkpoint
pub fn load_session_checkpoint(agent Agent, path string) Session
Purpose
Load session checkpoint. Throws on failure; handle the error or propagate it to the caller.
Parameters
agent Agent- agent (Agent)
path string- filesystem path (string)
Returns
Session — a value of this type
(&Session) save_checkpoint_sqlite
pub fn (s &Session) save_checkpoint_sqlite(path string, session_id string) int
Purpose
Operation on &Session: save checkpoint sqlite. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &Session- The
Session instance used by this call (borrow).
path string- filesystem path (string)
session_id string- session_id (string)
Returns
int — a value of this type
load_session_checkpoint_sqlite
pub fn load_session_checkpoint_sqlite(agent Agent, path string, session_id string) Session
Purpose
Load session checkpoint sqlite. Throws on failure; handle the error or propagate it to the caller.
Parameters
agent Agent- agent (Agent)
path string- filesystem path (string)
session_id string- session_id (string)
Returns
Session — a value of this type
run_parallel_workflow
pub fn run_parallel_workflow(agents &[]Agent, names &[]string, prompts &[]string) []WorkflowStepResult
Purpose
Run parallel workflow. Throws on failure; handle the error or propagate it to the caller.
Parameters
agents &[]Agent- agents (read-only borrow; caller keeps the original; type &[]Agent)
names &[]string- names (read-only borrow; caller keeps the original; type &[]string)
prompts &[]string- prompts (read-only borrow; caller keeps the original; type &[]string)
Returns
[]WorkflowStepResult — slice result
struct EvalOptResult
pub struct EvalOptResult {
pub content string
pub passed bool
pub rounds int
pub last_feedback string
pub history []WorkflowStepResult
}
Purpose
Structure encapsulating content, passed, rounds, last_feedback, history.
Public fields
content string- field (string)
passed bool- field (bool)
rounds int- field (int)
last_feedback string- field (string)
history []WorkflowStepResult- field ([]WorkflowStepResult)
run_evaluator_optimizer
pub fn run_evaluator_optimizer(generator &Agent, evaluator &Agent, task string, max_rounds int, pass_marker string) EvalOptResult
Purpose
Run evaluator optimizer. Throws on failure; handle the error or propagate it to the caller.
Parameters
generator &Agent- generator (read-only borrow; caller keeps the original; type &Agent)
evaluator &Agent- evaluator (read-only borrow; caller keeps the original; type &Agent)
task string- task (string)
max_rounds int- max_rounds (int)
pass_marker string- pass_marker (string)
Returns
EvalOptResult — a value of this type
(&Agent) run_json_checked
pub fn (a &Agent) run_json_checked(user_prompt string, required_keys &[]string, max_retries int) RunResult
Purpose
Operation on &Agent: run json checked. Throws on failure; handle the error or propagate it to the caller.
Parameters
a &Agent- The
Agent instance used by this call (borrow).
user_prompt string- user_prompt (string)
required_keys &[]string- required_keys (read-only borrow; caller keeps the original; type &[]string)
max_retries int- max_retries (int)
Returns
RunResult — a value of this type
discover_skills_dir
pub fn discover_skills_dir(dir_path string) []Skill
Purpose
Discover skills directory. Throws on failure; handle the error or propagate it to the caller.
Parameters
dir_path string- dir_path (string)
Returns
[]Skill — slice result
($&Agent) load_skills_dir
pub fn (a $&Agent) load_skills_dir(dir_path string) int
Purpose
Operation on $&Agent: load skills directory. Throws on failure; handle the error or propagate it to the caller.
Parameters
a $&Agent- The
Agent instance used by this call (exclusive borrow).
dir_path string- dir_path (string)
Returns
int — a value of this type
struct GraphNode
pub struct GraphNode {
pub name string
pub handler fn(&string) string
}
Purpose
Structure encapsulating name, handler.
Public fields
name string- name
handler fn(&string) string- field (function value; type fn(&string) string)
struct GraphEdge
pub struct GraphEdge {
pub from string
pub to string
}
Purpose
Structure encapsulating from, to.
Public fields
from string- field (string)
to string- field (string)
struct GraphCondEdge
pub struct GraphCondEdge {
pub from string
pub router fn(&string) string
}
Purpose
Structure encapsulating from, router.
Public fields
from string- field (string)
router fn(&string) string- field (function value; type fn(&string) string)
struct GraphParallelBranch
pub struct GraphParallelBranch {
pub name string
pub handler fn(&string) string
}
Purpose
Structure encapsulating name, handler.
Public fields
name string- name
handler fn(&string) string- field (function value; type fn(&string) string)
struct GraphFanOutNode
pub struct GraphFanOutNode {
pub name string
pub branches []GraphParallelBranch
pub reducer fn(&string, &[]string) string
}
Purpose
Structure encapsulating name, branches, reducer.
Public fields
name string- name
branches []GraphParallelBranch- field ([]GraphParallelBranch)
reducer fn(&string, &[]string) string- field (function value; type fn(&string, &[]string) string)
struct StateGraph
pub struct StateGraph {
pub entry string
}
Purpose
Structure encapsulating entry.
Public fields
entry string- field (string)
struct GraphStep
pub struct GraphStep {
pub step int
pub node string
pub input string
pub output string
}
Purpose
Structure encapsulating step, node, input, output.
Public fields
step int- field (int)
node string- field (string)
input string- field (string)
output string- field (string)
struct GraphRunResult
pub struct GraphRunResult {
pub final_state string
pub steps []GraphStep
pub finished bool
pub last_node string
pub interrupted bool
pub next_node string
}
Purpose
Structure encapsulating final_state, steps, finished, last_node, interrupted.
Public fields
final_state string- field (string)
steps []GraphStep- field ([]GraphStep)
finished bool- field (bool)
last_node string- field (string)
interrupted bool- field (bool)
next_node string- field (string)
struct GraphCheckpoint
pub struct GraphCheckpoint {
pub next_node string
pub state string
pub last_node string
pub steps []GraphStep
}
Purpose
Structure encapsulating next_node, state, last_node, steps.
Public fields
next_node string- field (string)
state string- field (string)
last_node string- field (string)
steps []GraphStep- field ([]GraphStep)
new_state_graph
pub fn new_state_graph(entry string) StateGraph
Purpose
Construct state graph.
Parameters
entry string- entry (string)
Returns
StateGraph — a value of this type
($&StateGraph) add_interrupt_before
pub fn (g $&StateGraph) add_interrupt_before(node string)
Purpose
Operation on $&StateGraph: add interrupt before.
Parameters
g $&StateGraph- The
StateGraph instance used by this call (exclusive borrow).
node string- node (string)
Returns
This call does not return a value.
($&StateGraph) add_node
pub fn (g $&StateGraph) add_node(name string, handler fn(&string) string)
Purpose
Operation on $&StateGraph: add node.
Parameters
g $&StateGraph- The
StateGraph instance used by this call (exclusive borrow).
name string- name (string)
handler fn(&string) string- handler (function value; type fn(&string) string)
Returns
This call does not return a value.
($&StateGraph) add_parallel_node
pub fn (g $&StateGraph) add_parallel_node(name string, branch_names []string, branch_handlers []fn(&string) string, reducer fn(&string, &[]string) string)
Purpose
Operation on $&StateGraph: add parallel node.
Parameters
g $&StateGraph- The
StateGraph instance used by this call (exclusive borrow).
name string- name (string)
branch_names []string- branch_names ([]string)
branch_handlers []fn(&string) string- branch_handlers ([]fn(&string) string)
reducer fn(&string, &[]string) string- reducer (function value; type fn(&string, &[]string) string)
Returns
This call does not return a value.
($&StateGraph) add_edge
pub fn (g $&StateGraph) add_edge(from string, to string)
Purpose
Operation on $&StateGraph: add edge.
Parameters
g $&StateGraph- The
StateGraph instance used by this call (exclusive borrow).
from string- from (string)
to string- to (string)
Returns
This call does not return a value.
($&StateGraph) add_conditional_edge
pub fn (g $&StateGraph) add_conditional_edge(from string, router fn(&string) string)
Purpose
Operation on $&StateGraph: add conditional edge.
Parameters
g $&StateGraph- The
StateGraph instance used by this call (exclusive borrow).
from string- from (string)
router fn(&string) string- router (function value; type fn(&string) string)
Returns
This call does not return a value.
graph_state_get
pub fn graph_state_get(state_json &string, key string, def string) string
Purpose
Graph state get.
Parameters
state_json &string- state_json (read-only borrow; caller keeps the original; type &string)
key string- key (string)
def string- default (string)
Returns
string — result string
graph_state_set
pub fn graph_state_set(state_json &string, key string, value string) string
Purpose
Graph state set.
Parameters
state_json &string- state_json (read-only borrow; caller keeps the original; type &string)
key string- key (string)
value string- value (string)
Returns
string — result string
(&StateGraph) run
pub fn (g &StateGraph) run(initial_state string, max_steps int) GraphRunResult
Purpose
Execute run on &StateGraph. Throws on failure; handle the error or propagate it to the caller.
Parameters
g &StateGraph- The
StateGraph instance used by this call (borrow).
initial_state string- initial_state (string)
max_steps int- max_steps (int)
Returns
GraphRunResult — a value of this type
checkpoint_from_result
pub fn checkpoint_from_result(res &GraphRunResult) GraphCheckpoint
Purpose
Checkpoint from result.
Parameters
res &GraphRunResult- res (read-only borrow; caller keeps the original; type &GraphRunResult)
Returns
GraphCheckpoint — a value of this type
save_graph_checkpoint
pub fn save_graph_checkpoint(ckpt &GraphCheckpoint, path string) int
Purpose
Save graph checkpoint. Throws on failure; handle the error or propagate it to the caller.
Parameters
ckpt &GraphCheckpoint- ckpt (read-only borrow; caller keeps the original; type &GraphCheckpoint)
path string- filesystem path (string)
Returns
int — a value of this type
load_graph_checkpoint
pub fn load_graph_checkpoint(path string) GraphCheckpoint
Purpose
Load graph checkpoint. Throws on failure; handle the error or propagate it to the caller.
Parameters
path string- filesystem path (string)
Returns
GraphCheckpoint — a value of this type
save_graph_checkpoint_sqlite
pub fn save_graph_checkpoint_sqlite(ckpt &GraphCheckpoint, path string, thread_id string) int
Purpose
Save graph checkpoint sqlite. Throws on failure; handle the error or propagate it to the caller.
Parameters
ckpt &GraphCheckpoint- ckpt (read-only borrow; caller keeps the original; type &GraphCheckpoint)
path string- filesystem path (string)
thread_id string- thread_id (string)
Returns
int — a value of this type
load_graph_checkpoint_sqlite
pub fn load_graph_checkpoint_sqlite(path string, thread_id string) GraphCheckpoint
Purpose
Load graph checkpoint sqlite. Throws on failure; handle the error or propagate it to the caller.
Parameters
path string- filesystem path (string)
thread_id string- thread_id (string)
Returns
GraphCheckpoint — a value of this type
(&StateGraph) resume
pub fn (g &StateGraph) resume(ckpt &GraphCheckpoint, override_state string, max_steps int) GraphRunResult
Purpose
Execute resume on &StateGraph. Throws on failure; handle the error or propagate it to the caller.
Parameters
g &StateGraph- The
StateGraph instance used by this call (borrow).
ckpt &GraphCheckpoint- ckpt (read-only borrow; caller keeps the original; type &GraphCheckpoint)
override_state string- override_state (string)
max_steps int- max_steps (int)
Returns
GraphRunResult — a value of this type
format_trace_otlp_json
pub fn format_trace_otlp_json(service_name string, spans &[]TraceSpan) string
Purpose
Format as trace otlp json.
Parameters
service_name string- service_name (string)
spans &[]TraceSpan- spans (read-only borrow; caller keeps the original; type &[]TraceSpan)
Returns
string — result string
format_trace_prometheus
pub fn format_trace_prometheus(service_name string, spans &[]TraceSpan) string
Purpose
Format as trace prometheus.
Parameters
service_name string- service_name (string)
spans &[]TraceSpan- spans (read-only borrow; caller keeps the original; type &[]TraceSpan)
Returns
string — result string
export_traces_otlp_http
pub fn export_traces_otlp_http(endpoint string, service_name string, spans &[]TraceSpan) int
Purpose
Export traces otlp http. Throws on failure; handle the error or propagate it to the caller.
Parameters
endpoint string- endpoint (string)
service_name string- service_name (string)
spans &[]TraceSpan- spans (read-only borrow; caller keeps the original; type &[]TraceSpan)
Returns
int — a value of this type
struct HandoffAgent
pub struct HandoffAgent {
pub name string
pub instructions string
}
Purpose
Structure encapsulating name, instructions.
Public fields
name string- name
instructions string- field (string)
struct HandoffTeam
pub struct HandoffTeam {
pub entry string
pub agents []HandoffAgent
}
Purpose
Structure encapsulating entry, agents.
Public fields
entry string- field (string)
agents []HandoffAgent- field ([]HandoffAgent)
struct HandoffResult
pub struct HandoffResult {
pub final_agent string
pub content string
pub route_trace []string
pub handoffs int
pub turns int
}
Purpose
Structure encapsulating final_agent, content, route_trace, handoffs, turns.
Public fields
final_agent string- field (string)
content string- field (string)
route_trace []string- field ([]string)
handoffs int- field (int)
turns int- field (int)
new_handoff_team
pub fn new_handoff_team(entry_agent string) HandoffTeam
Purpose
Construct handoff team.
Parameters
entry_agent string- entry_agent (string)
Returns
HandoffTeam — a value of this type
($&HandoffTeam) add_agent
pub fn (t $&HandoffTeam) add_agent(name string, instructions string)
Purpose
Operation on $&HandoffTeam: add agent.
Parameters
t $&HandoffTeam- The
HandoffTeam instance used by this call (exclusive borrow).
name string- name (string)
instructions string- instructions (string)
Returns
This call does not return a value.
run_handoff_openai
pub fn run_handoff_openai(team &HandoffTeam, client &openai.Client, model string, user_prompt string, max_handoffs int) HandoffResult
Purpose
Run handoff openai. Throws on failure; handle the error or propagate it to the caller.
Parameters
team &HandoffTeam- team (read-only borrow; caller keeps the original; type &HandoffTeam)
client &openai.Client- client (read-only borrow; caller keeps the original; type &openai.Client)
model string- model (string)
user_prompt string- user_prompt (string)
max_handoffs int- max_handoffs (int)
Returns
HandoffResult — a value of this type
discover_a2a_skills_prompt
pub fn discover_a2a_skills_prompt(base_url string) string
Purpose
Discover a2a skills prompt. Throws on failure; handle the error or propagate it to the caller.
Parameters
base_url string- base_url (string)
Returns
string — result string
delegate_to_a2a
pub fn delegate_to_a2a(base_url string, auth_token string, task_id string, prompt string) string
Purpose
Delegate to a2a. Throws on failure; handle the error or propagate it to the caller.
Parameters
base_url string- base_url (string)
auth_token string- auth_token (string)
task_id string- task_id (string)
prompt string- prompt (string)
Returns
string — result string
struct SwarmMember
pub struct SwarmMember {
pub name string
pub description string
pub provider string
pub agent Agent
pub anthropic_agent AnthropicAgent
pub gemini_agent GeminiAgent
pub responses_agent ResponsesAgent
}
Purpose
Structure encapsulating name, description, provider, agent, anthropic_agent.
Public fields
name string- name
description string- field (string)
provider string- field (string)
agent Agent- field (Agent)
anthropic_agent AnthropicAgent- field (AnthropicAgent)
gemini_agent GeminiAgent- field (GeminiAgent)
responses_agent ResponsesAgent- field (ResponsesAgent)
struct AgentSwarm
pub struct AgentSwarm {
pub entry string
pub members []SwarmMember
}
Purpose
Structure encapsulating entry, members.
Public fields
entry string- field (string)
members []SwarmMember- field ([]SwarmMember)
struct SwarmResult
pub struct SwarmResult {
pub final_agent string
pub content string
pub route_trace []string
pub handoffs int
pub turns int
pub steps []Step
pub total_tokens int
}
Purpose
Structure encapsulating final_agent, content, route_trace, handoffs, turns.
Public fields
final_agent string- field (string)
content string- field (string)
route_trace []string- field ([]string)
handoffs int- field (int)
turns int- field (int)
steps []Step- field ([]Step)
total_tokens int- field (int)
new_agent_swarm
pub fn new_agent_swarm(entry string) AgentSwarm
Purpose
Construct agent swarm.
Parameters
entry string- entry (string)
Returns
AgentSwarm — a value of this type
($&AgentSwarm) add_member
pub fn (s $&AgentSwarm) add_member(name string, description string, agent Agent)
Purpose
Operation on $&AgentSwarm: add member.
Parameters
s $&AgentSwarm- The
AgentSwarm instance used by this call (exclusive borrow).
name string- name (string)
description string- description (string)
agent Agent- agent (Agent)
Returns
This call does not return a value.
($&AgentSwarm) add_anthropic_member
pub fn (s $&AgentSwarm) add_anthropic_member(name string, description string, agent AnthropicAgent)
Purpose
Operation on $&AgentSwarm: add anthropic member.
Parameters
s $&AgentSwarm- The
AgentSwarm instance used by this call (exclusive borrow).
name string- name (string)
description string- description (string)
agent AnthropicAgent- agent (AnthropicAgent)
Returns
This call does not return a value.
($&AgentSwarm) add_gemini_member
pub fn (s $&AgentSwarm) add_gemini_member(name string, description string, agent GeminiAgent)
Purpose
Operation on $&AgentSwarm: add gemini member.
Parameters
s $&AgentSwarm- The
AgentSwarm instance used by this call (exclusive borrow).
name string- name (string)
description string- description (string)
agent GeminiAgent- agent (GeminiAgent)
Returns
This call does not return a value.
($&AgentSwarm) add_responses_member
pub fn (s $&AgentSwarm) add_responses_member(name string, description string, agent ResponsesAgent)
Purpose
Operation on $&AgentSwarm: add responses member.
Parameters
s $&AgentSwarm- The
AgentSwarm instance used by this call (exclusive borrow).
name string- name (string)
description string- description (string)
agent ResponsesAgent- agent (ResponsesAgent)
Returns
This call does not return a value.
(&AgentSwarm) run
pub fn (s &AgentSwarm) run(user_prompt string, max_handoffs int) SwarmResult
Purpose
Execute run on &AgentSwarm. Throws on failure; handle the error or propagate it to the caller.
Parameters
s &AgentSwarm- The
AgentSwarm instance used by this call (borrow).
user_prompt string- user_prompt (string)
max_handoffs int- max_handoffs (int)
Returns
SwarmResult — a value of this type