How an AI Agent Actually Works

// think → call tools → receive data → reason again → answer  |  with live code execution

Agent: Travel Planner
🎯 Goal: Plan a weekend trip to Chicago
🛠 2 tools registered

🧰 Tool Registry — What tools does this agent have?

2 tools loaded Agents can ONLY use tools they've been given
get_weather( )
What it does: Fetches a weather forecast for any city + date range.

You give it: A city name & the dates you care about.
It gives back: Temperature, sky conditions, rain chance, and wind for each day.

Think of it like the agent calling the Weather Channel on your behalf.
search_activities( )
What it does: Searches a database of things to do in a city, filtered by your preferences.

You give it: A city, indoor/outdoor preference, and a vibe/mood.
It gives back: A curated list of activities grouped by day.

Think of it like a local concierge who knows every attraction in town.
get_weather( )
// This is the "contract" the agent reads. // It tells the agent: what to pass in, // and what it will get back. const get_weather = { name: "get_weather", description: "Fetch weather forecast", parameters: { // ← inputs city: { type: "string" }, // required dates: { type: "string" }, // required }, returns: { // ← outputs days: [{ date, temp_f, sky, rain_pct, wind_mph }] } }
search_activities( )
// The agent picks which params to fill // based on what it has learned so far. // Here, it uses weather to choose // indoor_outdoor value. const search_activities = { name: "search_activities", description: "Find things to do", parameters: { city: { type: "string" }, indoor_outdoor: { type: "string" }, vibe: { type: "string" }, }, returns: { activities: [{ name, type, day, description }] } }
User Goal
Agent Reasoning
Tool Call
Tool Response
Final Answer
agent_runtime.js ● LIVE
// Waiting to start... // Press "Run the Agent" to see live // JavaScript execute in real time.
Agent Memory Object goal: null weather_data: null activities_data: null final_answer: null Execution Stats tool_calls_made: 0 last_tool_called: none
💡 What you're seeing: The code console runs actual JavaScript — the tool functions on this page are real. When the agent "calls" a tool, that function executes and returns real data into memory.