0
Phase 4

Agent Capabilities

~3 min read

Concept & How It Works

    Why Does It Exist?

    LLMs can't access the internet, databases, or filesystems natively. Tool calling is the bridge — it gives the LLM a typed API to the real world. Every production agent is only as capable as its tool set.

    Real-World Analogy

    Tool calling is like giving a remote worker a set of authorized system logins — they can't physically touch the servers, but they can operate them through defined interfaces.
    Loading diagram...

    Visual Workflows

    What is Agent Capabilities?

    Loading diagram...

    Example

    Scenario

    Agent needs weather data. LLM returns: tool_call(name='get_weather', args={city: 'Tokyo'}). Runtime calls the weather API, returns {temp: 28, condition: 'sunny'}. LLM uses this to answer the user.

    Solution

    In Agent Foundations, apply Agent Capabilities to this scenario: Agent needs weather data. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

    Practice Task

    Do this before moving to the next module — reading alone is not enough.

    Open the Code Walkthrough below and run it locally. Change one parameter related to Agent Capabilities (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.

    Code Walkthrough

    Highlighted lines show where Agent Capabilities happens in the code.

    Agent Capabilities
    1from pydantic import BaseModel, Field  # import dependencies2
    3class WeatherInput(BaseModel):  # define a data structure or component4    city: str = Field(description="City name")5
    6def get_weather(city: str) -> dict:  # define a reusable function7    # calls weather API8    return {"temp": 28, "condition": "sunny", "city": city}  # return the result9
    10tools = [{11    "type": "function",12    "function": {13        "name": "get_weather",14        "description": "Get current weather for a city",15        "parameters": WeatherInput.model_json_schema(),16    }17}]18
    19response = client.chat.completions.create(  # call the API20    model="gpt-4o",21    messages=[{"role": "user", "content": "Weather in Tokyo?"}],22    tools=tools,23)24# Parse: response.choices[0].message.tool_calls[0].function

    Commands to Remember

    Commands to Remember

    • pip install openai # minimal agent = LLM API + Python loop
    • python agent.py # run your agent script
    • pip install python-dotenv # load API keys from .env

    Common Mistakes

    • Vague tool descriptions causing wrong tool selection
    • No argument validation — injection and type errors
    • Unrestricted shell/code execution tools
    • No timeout — hung tools block the agent loop
    • Prompt-based tool parsing instead of native calling

    Cheat Sheet

    Quick recap — the most important points from this module.

    Cheat Sheet

    quick ref
    • JSON schema per tool
    • Description = tool selection key
    • Pydantic validates args
    • Sandbox + timeout
    • Native > prompt-based
    • Audit every call