The era of autonomous agents is here. AI can now do more than just answer questions; it can reason, plan, and take action to achieve complex goals. But there's a critical gap between a brilliant plan and flawless execution. How do you give your AI a toolkit to safely and reliably interact with the real world? How do you prevent a simple network hiccup from causing your agent to send five duplicate invoices or create a dozen user accounts?
This is where the .do platform comes in.
This guide will walk you through building your first autonomous agent using agent.do. We'll explore how to give your AI a robust toolkit for action by grounding it in action.do, the platform's engine for executing single, atomic tasks. You’ll learn how to move from high-level reasoning to reliable, auditable, and repeatable execution.
An autonomous agent, powered by a Large Language Model (LLM), is excellent at breaking down a high-level goal into a sequence of steps. For example, if you tell an agent to "Onboard new user Jane Doe," it might generate a plan like this:
The problem arises when the agent tries to execute this plan. Letting an LLM generate raw API calls or database queries on the fly is risky. It can lead to:
To build robust agents, we need to separate the planning from the doing. The agent can devise the strategy, but the execution needs to be handled by a system built for reliability.
The .do platform provides the fundamental building blocks for your Business-as-Code. It starts with a simple but powerful concept: the atomic action.
An atomic action is a single, indivisible operation that either succeeds completely or fails entirely, leaving no messy partial state behind. This is the foundation of reliability.
This is where action.do shines. It provides a simple API to define and execute these single-purpose actions. Instead of letting the agent call a messy, multi-purpose onboardUser() function, you provide it with a set of clean, atomic tools:
This approach turns your business logic into a catalog of secure, reusable, and auditable components that your autonomous agent can leverage.
Let's build an agent that handles new user onboarding.
First, we define the atomic actions our agent is allowed to perform. These are the "verbs" it can use to interact with the world. Using the .do platform, you can define these actions as simple functions or microservices. For our example, we'll assume we've already registered the following actions:
Crucially, each of these actions is designed to be idempotent. This means running the same action with the same parameters multiple times has the same effect as running it once. Sending the welcome email to userId: 'usr_12345' twice will only result in one email. This is essential for building workflows that can safely recover from failure.
Now, we set up our agent. agent.do takes a high-level objective and uses an LLM to formulate a plan using the tools we provided.
Objective: "Onboard a new user with email jane.doe@example.com and user ID usr_12345."
The agent.do orchestrator consults the LLM, which has knowledge of the available actions. It might create a plan like this:
This is where the plan turns into reality. When the agent decides to execute a step, it doesn't generate a raw API call. Instead, it makes a structured call to the action.do endpoint.
When the agent reaches step 2 of its plan, "send-welcome-email," this is what happens under the hood:
import { Do } from '@do-sdk/core';
// Initialize the .do client with your API key
const a = new Do(process.env.DO_API_KEY);
// The agent executes a specific, atomic action from its plan
const { result, error } = await a.action.execute({
name: 'send-welcome-email',
params: {
userId: 'usr_12345',
template: 'new-user-welcome-v2'
}
});
if (error) {
console.error('Action failed:', error);
// The agent can now decide how to handle the failure: retry, abort, or try a different action.
} else {
console.log('Action Succeeded:', result);
// The agent proceeds to the next step in its plan.
}
This is the magic. The agent's abstract plan is translated into a concrete, reliable, and auditable action. Execute. Audit. Repeat.
Building agents on a foundation of atomic actions gives you three superpowers:
By composing complex, multi-step workflow.do sequences from these fundamental action.do building blocks, your autonomous agent can finally move from being a clever novelty to a reliable core component of your business automation.
Ready to give your agent a toolkit it can trust? Explore the .do platform and start building your first autonomous workflow today.
What constitutes an 'atomic action'?
An atomic action is a single, indivisible operation that either completes successfully or fails entirely, leaving no partial state. Examples include sending a single email, making one API call, or writing a single record to a database.
Why is idempotency important for actions?
Idempotency ensures that executing the same action multiple times with the same parameters has the same effect as executing it once. This is crucial for building reliable systems that can recover from failures without causing unintended side effects, like sending duplicate invoices.
How does action.do relate to a workflow.do?
action.do represents the individual steps or building blocks. A workflow.do is a sequence or graph of these actions orchestrated to achieve a larger business outcome. You compose workflows from one or more atomic actions.
Can I define my own custom actions?
Yes. The .do platform allows you to define your own custom actions as functions or microservices, which can then be invoked via the action.do API. This turns your existing business logic into reusable, auditable components.