Concepts

Agent

Wraps a tool-bound ChatModel in a reasoning loop — decides which tool to call, executes it, feeds the result back, and repeats until it reaches a final answer (bounded by max_iterations as a safety limit).

Why it exists

Some questions need multiple steps — call a tool, read the result, decide what to do next — rather than a single prompt-to-answer call.

View source on GitHub
educhain.py
from educhain.models import ChatModel
from educhain.core.tool import Tool
from educhain.core.agent import Agent

weather_tool = Tool(get_weather)
model = ChatModel(tools=[weather_tool])
agent = Agent(model=model)

answer = agent.invoke("What's the weather like in Delhi?")

Related