Skip to contents

This is an Agent-first orchestration loop. It observes tool_call_end events, parses tool calls, invokes matching R tools with private context, appends tool results to the agent transcript, and continues generation.

Usage

bebel_agent_run(
  agent,
  tools = list(),
  context = new.env(parent = emptyenv()),
  hooks = list(),
  parse_tool_call = bebel_parse_tool_call,
  max_steps = 4,
  on_event = NULL,
  check_interrupt = TRUE
)

Arguments

agent

A BebelAgent object.

tools

A list of bebel_tool() objects or named functions.

context

Private run context passed to tools and hooks but not appended to the model transcript.

hooks

Optional named list of hooks: turn_start, event, tool_request, tool_result, tool_error, turn_end.

parse_tool_call

Function converting tool-call content to list(name, arguments, raw).

max_steps

Maximum assistant/tool iterations.

on_event

Optional event callback or handler list for model events.

check_interrupt

Check for Ctrl-C during generation.

Value

A bebelAgentRun list with turns, tool calls, and final agent info.