Pular para o conteúdo
← Back to Skalablog

Published article

AI Personal Agenda Agent: Build It With Tool Calling

Software EngineeringClaude CodeAnthropic

The cheapest model is not what makes an AI personal agenda agent affordable. Relevance is. A keyword search that dumps twenty notes into the model's context can multiply cost per message, while a retrieval setup that returns one relevant passage keeps the bill flat. That trade-off shaped an entire live build.

What Is an AI Personal Agenda Agent?

An AI personal agenda agent is a language-model application that answers questions about a user's tasks and notes by calling tools against the user's own API. In a live-coding session broadcast by Rocketseat in June 2026, Gabriel Buzzi, the company's head of product and technology, built exactly this: a task API, an agent layer with tool calling, and a chat interface, all in TypeScript.

The architecture has three layers. The API layer stores tasks and notes in a database and exposes ordinary endpoints. The agent layer receives natural-language questions, reasons about them, and issues tool calls that translate the question into parameters such as completed: false. The interface layer streams the agent's behavior back to the user, showing reasoning, tool activity, and final text as separate message parts.

The agent was orchestrated with the AI SDK, the TypeScript toolkit for building streaming model applications. A run limit of five rounds kept the agent from looping forever: if the first tool call found nothing, the agent could reason again and try a different query shape, but only a bounded number of times.

How Tool Calling Connects the Agent to the Task API

Tool calling is the mechanism that lets the model act on your application instead of only describing what should happen. When the live audience asked "what are today's tasks?", the agent reasoned about the question and issued a tool call named searchTask. That call was a request to the application's own API, with parameters the model derived from natural language.

The first attempt failed in a revealing way. The agent searched by date and got an empty result, so within the same run it reasoned again and changed strategy: it queried all incomplete tasks (completed: false) and filtered by date afterward. That second round returned the correct list. The five-round stop condition mattered here, because the agent used two of its rounds on one question.

This pattern defines what a tool call actually is in an agent application. It can hit an external endpoint, invoke an internal service function, or run a query inside the same process. What matters is that the model produces structured parameters and the application executes the action, returning the output for the next reasoning step.

Streaming Reasoning and Message Parts With the AI SDK

The agent does not return one blob of text. It returns a stream of typed parts, and each part type carries a different phase of the work: reasoning steps, text deltas, and tool-call events. During the live session, the host inspected the stream in an API client and could watch the model reason in real time as it worked out today's date, declared its intent, and fired the tool call.

Each part has a type such as reasoning, text delta, or tool call, and the interface renders each type differently. When a tool call arrives, the widget shows a small card such as "tasks consulted" with the tool name; when text deltas arrive, they append to the visible message. One quirk surfaced live: the model in use liked to announce its intent in text before acting, a model-specific behavior rather than a property of streaming itself.

This part-based stream is what makes an agent interface legible. The host noted at one point that the model was taking around 30 seconds to respond. Without the stream, the user stares at a spinner for that whole half-minute. With it, the user sees thinking, action, and answer as distinct phases.

Why the Agent Got the Date Wrong, and the Fix

The most instructive bug of the session was temporal: the agent believed it lived in the past, so every date filter it built returned wrong results. Asked about today's tasks, its reasoning said the date was July 10, 2025, likely close to the training cutoff of the model in use.

The fix was one line of context: inject the current date and timezone into the system prompt. After the change, the agent reasoned that the deadline it should pass to the tool was the actual current date and time. Testing on June 17, it passed a deadline of 1:25 PM in the UTC-3 timezone the application operated in, and correctly flagged the overdue task. When the host marked that task complete and asked again, the agent reported nothing was overdue.

The lesson generalizes beyond dates. Smaller, cheaper models often need explicit context that larger models might infer or remember. Rather than paying for a bigger model, the application supplied the missing fact in the system prompt. That is usually the right order of operations: fix context before switching models. The host also added logging of tool inputs and outputs to trace exactly what the agent sent when a search came back empty.

Building a Streaming Chat Interface for the Agent

To make the agent usable, the live session generated a floating chat widget styled like Intercom, in the bottom-right corner, connected to the agent endpoint with streaming support through the AI SDK. Before committing to one design, the host asked the coding agent to produce static HTML mockups of three interface concepts and used the mockups as context for the real build.

The concepts were:

  1. A console-style single pane for talking to the agent.
  2. A drawer that slides open beside the app.
  3. A spotlight-style command palette, similar to what many apps ship today.

The host picked the Intercom-style companion widget. The result decomposed into a launcher button, a composer with streaming state, and a message list that renders the typed parts from the stream. When the agent executed a tool, the message list showed a compact card naming the tool; when it streamed text, the deltas appended in place. The host also directed the coding agent to match the team's own design system rather than copy Intercom's rounded look.

Conversation persistence was deliberately deferred. The chat was ephemeral for this session, with saving and history planned for a later stream. Separating the agent loop from persistence keeps the first iteration simple and testable.

Tool Calls, MCP, and Other Ways to Wire an Agent

There is more than one way to connect an agent to an application, and the choice changes who can use your agent's capabilities. The session closed with a map of the options; three are worth distinguishing side by side.

OptionHow it worksBest for
Direct tool callsFunctions or endpoints inside the same applicationSingle-app agents, like this live build
MCPOpen protocol exposing tools to external clientsReuse by tools such as Claude Code
Messaging bridgeAgent behind WhatsApp or Telegram transportChat-first users on their phones
  • Direct tool calls. The agent's tools are functions or endpoints inside the same application. This is what the live build used: the tool call translated natural language into a query against the task API, effectively a database query with model-derived parameters. It is the simplest option and covers most single-application cases.
  • Model Context Protocol (MCP). MCP is an open protocol for exposing tools to external clients. The host's example: wrap the agenda tools as an MCP server, then connect Claude Code, Anthropic agentic terminal tool, which understands MCP natively. This externalizes the agent so other tools can use the same capabilities. MCP clients still use tool calls underneath; the protocol standardizes how the tools are described and invoked.
  • Messaging integrations. Building the agent behind a WhatsApp or Telegram bridge, a pattern a live viewer using the Evolution API, an open-source WhatsApp messaging API, reported already running for a month. The agent logic stays the same; the transport changes.

The next live stream in the series was set to cover two extensions: tool-call approval, a human-in-the-loop flow where the model asks the user to approve a sensitive action before executing it, and a full RAG implementation.

When Keyword Search Breaks: RAG and Vector Retrieval

Keyword search works until the wording or the volume of matches turns against you. Asked "when did I start using Claude Code?", the agent searched the notes database and found the right note because the title contained the phrase. But the host showed the fragility: rename the note, or have a hundred notes mentioning the term, and keyword search either misses the answer or dumps every match into the model's context.

Both failure modes cost money. Twenty matching notes pushed into the context inflate token usage on every message; the host estimated a query that could cost 0.50 of a centavo creeping up to one, two, or five as retrieved text grows. Diluted context can also make the model lose the thread entirely. He cited a real production agent serving more than 600 daily users with a monthly bill around 400 in local currency, driven largely by how much context each request carried.

The fix is RAG, retrieval-augmented generation. Notes and the user's question are converted into vector embeddings, then compared with cosine similarity so only the semantically relevant passage is retrieved. Instead of twenty rows, the context receives one relevant chunk. The session noted that hybrid retrieval, combining vector search with database queries and a ranking algorithm such as BM25, is the more complete production pattern, and deferred the full implementation to the next live stream. The principle stands on its own: retrieve only what is relevant, for both answer quality and cost.

FAQ

What is an AI personal agenda agent?

It is an application where a language model answers questions about a user's tasks and notes by issuing tool calls against the user's own API, then streams its reasoning, actions, and final answer back to a chat interface.

What is a tool call in an AI agent?

A tool call is a structured request the model generates, which the application executes against an API, a function, or a database. The result returns to the model so it can reason over it and produce the final answer.

Why did the agent think it was in 2025?

The model used in the live session had no knowledge of the current date and defaulted to July 10, 2025, near its training cutoff. Injecting the current date and timezone into the system prompt fixed the behavior.

What is the difference between tool calls and MCP?

Tool calls are the mechanism a single agent uses to act. MCP, the Model Context Protocol, is a standard way to expose those tools to external clients such as Claude Code, which can then reuse them across applications.

Why is RAG better than keyword search for an agent's notes?

Keyword search returns every textual match, which inflates the context window and the cost per message, and can miss reworded content. Vector retrieval compares semantic similarity and returns only the passages relevant to the question.

Which SDK was used to build the streaming agent?

The live build used the AI SDK, the TypeScript toolkit for streaming model responses, message parts, and tool calls in web applications.

How do you stop an agent from looping forever?

Cap the number of reasoning-and-tool rounds per run. The live build allowed five rounds, which was enough for the agent to retry a failed search with a different query strategy.

Does a chat agent need conversation persistence?

Not initially. The live session kept the chat ephemeral, separating the agent loop from storage, with history and persistence planned as a later feature.

How expensive is it to run an agent in production?

It depends mainly on context size per request. The host cited a production agent with over 600 daily users costing around 400 in local currency per month, and argued that reducing retrieved context matters more than switching to a cheaper model.

Turn Your Own Live Builds Into Written Articles

This walkthrough came from a live stream: a build that succeeded, broke on a date, and got fixed in public. That kind of material is valuable, but it stays locked inside a long video unless someone transcribes and edits it. If you have sessions like this on your own channel, whether architecture reviews, live codings, or community deep dives from spaces such as the Crazystack TypeScript community around Crazystack, the Bootcamp do Dev Doido by Gustavo Dev Doido, or any other channel, you can turn that recorded knowledge into a searchable article.

The flow is simple with Skala Blog: paste a YouTube URL, get the transcription, and generate a structured article ready to review and publish. Your best live moments stop being scroll-back material and become content that answers questions on its own.

Source video