Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Agent Controller
The agent controller is the decision-making engine. It reads the current state and goal, and decides what action to take next. In most modern agents, the controller is powered by a language model.
What the Controller Does
The controller is the brain of the agent. It is responsible for:
- 1Reading the current goal
- 2Reading the current state and recent observations
- 3Deciding what action to take next (which tool to call, with what arguments)
- 4Deciding when the goal is complete
- 5Deciding when to escalate to a human
In most agentic AI systems today, the controller is a language model (like GPT-4, Claude, or Gemini). The controller receives a carefully structured input that includes the goal, the available tools, and the current state. It then outputs a decision about which tool to call next.
Important
the controller does not execute the action itself. It only decides what action to take. The tool runner executes the actual action.
Controller Input and Output
# Simplified controller input structure
controller_input = {
"goal": "Find the top 3 Python libraries for web scraping and summarise them",
"available_tools": ["web_search", "extract_page_content", "summarise"],
"current_state": {
"steps_completed": 0,
"observations": []
},
"system_rules": "Only use approved tools. Maximum 10 steps. Escalate if uncertain."
}
# The controller (language model) outputs a decision
controller_output = {
"action": "web_search",
"arguments": {"query": "top Python libraries for web scraping 2024"},
"reason": "Start by searching for current information on the topic"
}
print("Controller decided:", controller_output["action"])
print("Arguments:", controller_output["arguments"])