โ†
AI for Tech Certification
Proficient ยท M1 ยท lesson 1 of 30 ยท in progress
Preview โ€” browse every lesson free. Enroll to mark lessons complete, open partner links and save your progress. Login & enroll โ†’
AI Agents, Tool Use, and Autonomous Systems
๐Ÿ“–
now learning

AI Agents, Tool Use, and Autonomous Systems

15 min

Overview

Today, an AI can reason brilliantly but can't do anything. It can analyze a problem, suggest a solution, but can't execute it. Someone has to take the recommendation and turn it into action.

The next generation of AI is different. It's autonomous. It doesn't just reason. It acts. It uses tools to interface with your systems. It executes workflows. It completes tasks with minimal human oversight.

A customer submits a support ticket. An autonomous agent reads it. Checks their account. Searches the knowledge base. Identifies the issue. Runs a diagnosis. Determines the solution. Implements the fix. All without human intervention.

An engineer needs a code change. They ask an agent. The agent plans the change, writes the code, runs tests, submits a pull request. All in minutes.

A sales representative needs to research a prospect. An agent gathers company information, recent news, competitor landscape, financial data. Compiles it into a briefing. All automatically.

These aren't science fiction. These are being built today. The technology is tool use and agent architectures.

This lecture is about what agents are, why they matter, how to build them, and what the limitations are right now.

Understanding AI Agents and Tool Use

What Is a Tool?

A tool is a function that an AI can call. It extends what the AI can do beyond just generating text.

Examples:

Database query tool: "Execute this SQL query and return results."

API call tool: "Make a request to this endpoint and return the response."

Code execution tool: "Run this code and return the output."

Search tool: "Search your knowledge base and return relevant results."

Email tool: "Send an email to this recipient."

Web fetch tool: "Download and summarize this web page."

Calculator tool: "Do math on these numbers."

Tools work because Claude (and other LLMs) can be taught to recognize when a tool is needed and how to call it. You give Claude a function definition and examples. It learns to use them.

What Is an Agent?

An agent is a system with these components:

Goal: What is the agent trying to accomplish? "Answer this customer question." "Debug this error." "Generate a report."

Tools: What functions does the agent have available? Query database, search knowledge base, make API calls, send emails.

Reasoning: How does the agent decide what to do? It reasons through the problem, considers which tools to use, makes a plan.

Execution: The agent takes actions using tools. It gets results. It uses those results to inform the next step.

Feedback loop: If something fails, the agent tries a different approach. It learns from results and adjusts.

An agent is essentially a loop: reason about problem โ†’ decide what tool to use โ†’ call tool โ†’ get result โ†’ reason about result โ†’ decide next step โ†’ repeat until goal achieved.

Agentic vs. Conversational

Conversational AI (like ChatGPT) responds to your messages. You drive the interaction. The AI reacts.

Agentic AI has a goal and autonomously works toward it. You set the goal. The AI figures out how to achieve it. You don't have to drive every step.

Conversational is pull-based. Agentic is push-based.

Example: Conversational: "Claude, help me debug this error." You describe the error. Claude suggests steps. You run the steps. You report back. Claude suggests more steps.

Agentic: "Claude, debug this error and fix it." Claude reads the error. Checks logs. Tests hypotheses. Identifies root cause. Implements fix. Reports back: "Fixed."

Agentic is more powerful but also more complex to build and potentially more risky (you're giving the AI authority to make changes).

Key distinction: Tool use is about capability. Agents are about autonomy. You can have tool-using systems that aren't fully autonomous (Claude with tools, where a human decides what to do with the tool results). Or you can have agents that autonomously use tools toward a goal.

Building Tool-Using Agents

Step 1: Define the Goal and Success Criteria

What is the agent trying to accomplish? Be specific. "Answer customer support questions" is vague. "Resolve customer support questions and reduce human escalations to 10% of volume" is better.

Define success metrics. How do you know the agent succeeded? What counts as a successful ticket resolution? What counts as a failure?

This matters because you'll measure the agent against these metrics and refine based on performance.

Step 2: Inventory Available Tools

What systems does the agent need to interact with? Database, APIs, knowledge base, file systems, email, code repositories, deployment systems?

Create an inventory of every system the agent might need to touch. This becomes your tool list.

Step 3: Design Tool Definitions

For each tool, define:

Name: What's the tool called? "query_customer_database"

Description: What does it do? "Queries the customer database and returns account information including balance, account age, service level, and recent activities."

Parameters: What inputs does it take? "customer_id (required), date_range (optional)"

Return value: What does it return? "JSON object with customer account details"

Examples: Show examples of how to call it and what results look like.

Constraints: Any limitations? "Can only query US customers." "Returns only last 90 days of activity."

Write these definitions clearly. The better your tool definitions, the better the agent will use them.

Step 4: Implement Tool Functions

Tools are real functions that do real work. Each tool definition maps to actual code that executes.

When the agent decides to call a tool, your system actually executes the underlying function. The agent gets the real result.

Critical: tools must be safe. An agent that can delete data is dangerous if it makes a mistake. Consider:

  • Read-only tools (query data, but don't modify)
  • Sandboxed execution (tools run in isolated environment)
  • Human approval (agent suggests an action, human approves before it executes)

Step 5: Integrate with Agent Framework

Use a framework that handles the agent loop. Options:

LangChain: Popular open-source framework. Lots of tool integrations. Supports agents with tool use.

Anthropic SDK with tool use: Direct integration with Claude. You define tools, pass them to Claude, Claude decides to use them.

Custom implementation: Build your own agent loop. More control, more complexity.

The framework handles the loop: send request with available tools โ†’ Claude reasons and decides to call a tool โ†’ tool executes โ†’ results sent back to Claude โ†’ Claude reasons and decides next step โ†’ repeat.

Step 6: Test and Iterate

Create test cases. Give the agent problems. Evaluate how well it solves them.

Common issues:

  • Agent gets stuck in a loop (calling same tool over and over)
  • Agent makes wrong tool choices (calls database query when it should search knowledge base)
  • Agent hallucinates tool calls (tries to call a tool that doesn't exist)

Refine based on results. Better tool definitions help. More examples help. Clearer system prompts help.

Real-World Agent Applications

Customer Support Agent

Tools: search knowledge base, query customer database, check service status, lookup order history, send email, create tickets.

Goal: answer customer questions. If can't answer, escalate to human.

Benefits: 70-80% of questions answered automatically. Humans handle complex issues.

Risks: wrong answers given to customers (mitigated with human review).

Internal Research Agent

Tools: web search, email search, internal document repository, company wiki, CRM.

Goal: research a topic and compile briefing.

Example: sales rep says "I need to understand this prospect." Agent gathers company info, recent news, competitive landscape, hiring news, financial data. Compiles into briefing. Takes 5 minutes instead of 2 hours.

Code Quality Agent

Tools: run linter, run tests, check code coverage, check security vulnerabilities, access code repository.

Goal: review pull requests for quality issues.

Benefit: catches common issues before human review. Reduces back-and-forth on style issues.

Infrastructure Troubleshooting Agent

Tools: query monitoring systems, check logs, restart services, run diagnostics, contact on-call engineers.

Goal: troubleshoot and resolve infrastructure issues autonomously.

Benefit: reduces mean time to resolution. Resolves common issues without human intervention.

Data Analysis Agent

Tools: query database, run SQL, generate charts, statistical analysis, send reports.

Goal: answer business questions with data analysis.

Benefit: people can ask questions in plain language. Agent figures out how to answer with data.

Pattern: Best agents are built for well-defined, repetitive tasks with clear success criteria. Ambiguous tasks are harder for agents. Novel situations require human judgment. Build agents for the 80% of work that's repetitive and well-defined. Leave the 20% of novel work to humans.

Current Limitations and How to Work Around Them

Tool Hallucination

Sometimes agents try to call tools that don't exist. Or call with wrong parameters.

Mitigation: very clear tool definitions. Good error handling. If tool call fails, agent retries with corrected parameters.

Context Window Limits

Agents with long tool histories can hit token limits. Each tool call and result adds to the conversation context.

Mitigation: reset context periodically. Summarize tool results instead of including full results. Use efficient prompting.

Tool Sequencing

Sometimes agents need to call multiple tools in a specific order. If they get the order wrong, subsequent tools fail.

Mitigation: tool definitions should explicitly describe dependencies. You can also require certain tools to be called before others.

Cost and Latency

Agents with many tool calls become expensive and slow. Each tool call is a round trip.

Mitigation: batch tool calls where possible (call multiple tools in parallel, get results back together). Use cheaper models for simpler agent tasks. Cache tool results that don't change frequently.

Safety and Governance

An agent with write access to production systems is risky. A mistake could delete data or break services.

Mitigation: start with read-only tools. Implement approval workflows (agent decides to do something, human approves before it happens). Audit all agent actions. Test extensively before production use. Limit agent authority to low-risk operations.

Debugging

When something goes wrong, it's hard to understand why. Agent took tool A, got result B, then made decision C. Why?

Mitigation: comprehensive logging. Log every tool call, every result, every decision. This helps you understand what went wrong and refine the agent.

What to Do Monday Morning

Identify a repetitive task: What do your team members spend a lot of time on that's repetitive and well-defined? Customer support? Data analysis? Research? Start there.

Define the goal and success metrics: If you built an agent to do this task, how would you measure success?

Inventory the tools needed: What systems would the agent need to interact with? What information would it need to access?

Start simple: Don't try to build a perfect agent. Start with simple tool use. Agent can call one or two tools. See if it works.

Measure and iterate: Once you have a working agent, measure performance. Refine based on results.

Case Study: Building an Agent That Shipped

A SaaS company built a customer support agent. Here's what worked:

Phase 1 (Simple): Agent could search knowledge base and answer FAQs. 30% of support tickets were "How do I...?" questions. Agent answered these. Success rate: 85%. Time to answer: 30 seconds vs. 5 minutes for human. Cost: $3k for agent setup. Saved: 10 hours/week in human time ($500/week, $26k/year). ROI: positive in one month.

Phase 2 (More Tools): Agent could also check account status, look up transaction history, see recent support interactions. Now 55% of tickets could be fully resolved by agent. Success rate: 80% (slightly lower because more complex situations). Cost: $5k more for integrations. Saved: 20 hours/week. ROI: still strong.

Phase 3 (Judgment): Agent could identify when a ticket required human intervention and escalate with context. Instead of humans having to read the full ticket, agent provided summary and recommendations. Humans spend 50% less time on complex tickets. Cost: $8k more. Saved: 25 hours/week. ROI: strong.

Year 1 Results: Support team of 5 people handled 3x the ticket volume (with same headcount). Customers got faster responses (agent responds in 30 seconds, human in 2 hours). Support team spent time on complex, valuable issues. Customer satisfaction improved.

Key Lesson: Don't try to build a perfect agent. Start simple. Expand capabilities based on what works. Measure continuously. This agent started at 30% coverage (answering FAQs) and grew to 60% (resolving most common issues). The remaining 40% still required humans, and they were happier handling only complex issues.

FAQ

Q: How complex can agents get?

A: Very. Multi-step workflows with loops and branching. Agents that call other agents. Complex reasoning with tool results. The limit is your imagination. The practical limit is cost and latency.

Q: Can agents learn and improve over time?

A: Not yet in the traditional sense (model weights don't update). But you can track agent performance and refine tool definitions, prompts, and strategies. The agent itself doesn't learn, but your system around it improves.

Q: What about security? What if an agent is compromised?

A: Same security principles as any software system. Authenticate tool access. Encrypt data. Audit all actions. Run agents with minimal required permissions. Implement approval workflows for risky operations.

Q: Can agents handle ambiguous requests?

A: Not well. Agents work best with clear, well-defined goals. If a request is ambiguous, the agent might make wrong assumptions. Build agents for clear-cut tasks.

Q: What's the difference between agents and workflows/automation?

A: Workflows are usually predefined: step A โ†’ step B โ†’ step C. Agents reason about what to do: analyze situation โ†’ choose best path โ†’ execute โ†’ evaluate results โ†’ adjust.

Key Insight

Agents extend AI from thinking to doing by giving models access to tools (functions). Tool use enables autonomous execution: agent plans, calls tools, evaluates results, adjusts approach. Start with read-only tools (search, database queries), progress to write operations (tickets, code). Agents work best for repetitive, well-defined tasks. Human oversight required for high-stakes operations.

On This Page

Watch the Lecture
Agent Foundations
Building Agents
Real-World Applications
Limitations and Workarounds
Monday Morning Action
FAQ

Chapter Details

Part ofChapter 8