Skip to main content

AgentExecutor

AgentExecutor is the recommended high-level entry point. It wraps ReActAgent or FunctionCallingAgent behind a consistent interface.

Usage

from synapsekit import AgentExecutor, AgentConfig, CalculatorTool, WebSearchTool
from synapsekit.llm.openai import OpenAILLM
from synapsekit.llm.base import LLMConfig

llm = OpenAILLM(LLMConfig(model="gpt-4o-mini", api_key="sk-..."))

executor = AgentExecutor(AgentConfig(
llm=llm,
tools=[CalculatorTool(), WebSearchTool()],
agent_type="function_calling", # or "react"
max_iterations=10,
system_prompt="You are a helpful research assistant.",
))

# Async
answer = await executor.run("What is the square root of 1764?")

# Sync (scripts / notebooks)
answer = executor.run_sync("What is 12 factorial?")

# Streaming
async for token in executor.stream("Explain the result step by step"):
print(token, end="")

AgentConfig

FieldTypeDefaultDescription
llmBaseLLMrequiredLLM provider
toolslist[BaseTool]requiredAvailable tools
agent_type"react" | "function_calling""react"Which agent to use
max_iterationsint10Max tool-call cycles
system_promptstr"You are a helpful AI assistant."Agent system instruction
verboseboolFalseReserved for future logging

Inspecting agent steps

await executor.run("Do some research")

for step in executor.memory.steps:
print(f"[{step.action}] {step.action_input}{step.observation}")

Choosing agent type

SituationRecommended
Using OpenAI or Anthropic"function_calling"
Using Ollama, Cohere, Mistral, Gemini, Bedrock"react"
Many tools, need reliable selection"function_calling"
Want to inspect reasoning chain"react"