Skip to content
Articles

How to build an agent for your product and serve it everywhere

Ashpreet Bedi

September 1, 20266 min read

This article is for engineering leaders at SaaS companies that want to build an agent for their product. An agent that is available inside your product, in Claude and ChatGPT as connectors, or in Slack. The goal is to give your users a new way to use your product, thereby unlocking new distribution and revenue opportunities.

Why build an agent for your product

The way people use and discover software is changing.

Software is increasingly used through agents like Claude and ChatGPT and users have a growing preference for software that can be used through an agent. By the end of the decade, agents will be the primary consumer of most software.

Your product will get used in three ways:

  • Through your user's agent, eg: Claude, ChatGPT
  • Through your agent, inside your product
  • Through your user's agent talking to your agent

Very soon, having the best agent will be synonymous with having the best product.

This article will show you how to build the best agent experience for your product.

Build once, serve everywhere

The goal is to build one agent and serve it in three places:

1. Your product. As a chat interface inside your product. Users work with your product in natural language. This is the experience you control, own and learn from.

2. Claude and ChatGPT. As a connector to Claude or ChatGPT. Users reach your product through their agent of choice.

3. Slack. As an agent in their Slack workspace. Users reach your product in the channel where their team works.

How to read this guide

Read this guide like a normal article, start to finish. Skim if you want. Don't copy, don't follow along, don't run any code. The code in this guide shows you the shape of what we're building and some of it is trimmed to stay readable. At the end I'll give you the complete codebase, ready to hand off to your coding agent.

Build your agent

Say your product is an invoicing platform for small businesses.

Your users send invoices. Your product tracks who paid and who didn't. We'll build this agent as an example through this article.

v0 of your agent = model + tools + instructions

  • Model: the intelligence that orchestrates the tools
  • Tools: actions the agent can take; thin wrappers over your product's API
  • Instructions: how the agent works; your product's rules and policies

Here's what the first version of your agent looks like:

invoice_agent.py
from agno.agent import Agent
from your_product.api import (
    get_overdue_invoices,
    get_customer_history,
    get_open_disputes,
    send_payment_reminder,
)
 
invoice_agent = Agent(
    id="invoice-agent",
    model="openai:gpt-5.6",
    tools=[
        get_overdue_invoices,
        get_customer_history,
        get_open_disputes,
        send_payment_reminder,
    ],
    instructions="""
    You help small business owners get paid on time.
 
    Before you chase an invoice, pull the customer's history and check for open disputes.
    A reliable customer a few days late gets a friendly reminder.
    Past 60 days, the tone turns firm.
    Don't chase invoices with open disputes.
    """,
)

Why not just expose your API as tool calls?

There's a popular opinion that you should expose your product's API as tool calls and let the user's agent figure it out. This is fine for developer tools, but not for software where your team's know-how and policies are baked in.

A general-purpose agent with your raw API does not have the judgment your team built up over years. It will chase the disputed invoice and send a firm email to your best customer over a five day slip. The orchestration is the product, and if you want your users to have the best experience, you need to own the agent experience.

Improve your agent

v0 works, but it's far from a product, let alone the best product. There are three big problems you need to solve and a few others that are nice to have.

1. No session continuity. Every run is independent, meaning we need to build a multi-turn chat experience by adding session history to the context window.

2. Too much context. get_overdue_invoices can return 50 invoices and all of them will be included in the context window for the rest of the conversation, making every turn after it slower, pricier and dumber.

3. No knowledge of your product. The agent knows your API but it doesn't know your product. "How does late fees work?" and "can I invoice in euros?" are not in the API. They're in your help center, and you can't paste your help center into the instructions.

Two other issues that aren't necessary but make the product experience better:

4. Learning. We want the user to have the experience of working with someone who's been on their account for years. With learning, the agent can build a picture of each user; the customer who's always five days late but always pays, the owner who wants totals instead of paragraphs. The best agents learn from experience.

5. Context of past sessions. Many times users will start a new session but will be talking about the same thing as the last 2 sessions. Give your agent the ability to search past sessions.

Here's what the v1 of your agent looks like:

invoice_agent.py
from os import getenv
 
from agno.db.postgres import PostgresDb
from agno.knowledge import Knowledge
from agno.learn import LearningMachine
from agno.vectordb.pgvector import PgVector
 
db = PostgresDb(db_url=getenv("DATABASE_URL"))
knowledge = Knowledge(vector_db=PgVector(db_url=db_url, table_name="product_docs"))
 
invoice_agent = Agent(
    ...,  # the agent from before
    # Session continuity
    db=db,
    add_history_to_context=True,
    num_history_runs=5,
    read_chat_history=True,
    # Context of past sessions
    search_past_sessions=True,
    # Offload heavy tool results
    offload_tool_results=True,
    # Knowledge of your product
    knowledge=knowledge,
    # Continuous Learning from experience
    learning=LearningMachine(
        user_memory=True,
        user_profile=True,
        entity_memory=True,
    ),
)

Now your agent has memory, a lean context window, access to your product's documentation, and it gets better with use. It's ready to become a product.

Turn your agent into a product

The next step is putting the agent inside your product. For that you need:

  1. An API your product can call.
  2. Streaming of reasoning and tool calls as they happen.
  3. Session and run management to view past conversations, rename threads, delete them, and resume one from last week.

Agno's agent runtime, AgentOS, wraps your agents in a FastAPI app with 80+ prebuilt endpoints to build your product on. Here's what it looks like:

invoice_agent.py
from agno.os import AgentOS
 
invoice_agent = Agent(
    ...,  # the v1 agent from before
)
 
agent_os = AgentOS(agents=[invoice_agent], db=db, tracing=True)
app = agent_os.get_app()
 
if __name__ == "__main__":
    agent_os.serve(app="invoice_agent:app")

Now your agent is available as a REST API. Your product's chat panel is now a thin client that calls the AgentOS endpoints:

curl https://agents.your-product.com/agents/invoice-agent/runs \
  -d "message=Who owes me money?" \
  -d "user_id=usr_1042" \
  -d "session_id=chat_881" \
  -d "stream=true"

The response streams over SSE with reasoning and tool calls, so your panel shows the agent working instead of a spinner. Send the same session_id and the conversation picks up where it left off.

The run endpoint is a fraction of what a product needs.

AgentOS handles data isolation, so one customer can never pull another customer's thread. It handles durability so failed runs resume gracefully. It handles background execution so long running tasks don't block the UI. It resumes streaming when the network drops. It handles authentication, RBAC, and enforces agent- and tool- level governance at the HTTP layer.

It logs every call, traces every run, and schedules recurring work.

AgentOS turns your agent into a product.

Use your agent in Claude and ChatGPT

Many of your users won't open your product to ask a question. They want to use it through Claude or ChatGPT. Fighting this trend is pointless.

Serve your agent as an MCP server and so becomes a connector in those apps:

invoice_agent.py
from fastmcp.server.auth.providers.workos import AuthKitProvider
 
agent_os = AgentOS(
    ...,  # from before
    mcp=MCPConfig(
        tools=[
            invoice_agent.as_tool(
                name="invoice_agent",
                description=(
                    "Talk to the invoicing agent. Send plain language. "
                    "Pass session_id back to continue the conversation."
                ),
            )
        ],
        default_tools=False,
    ),
    mcp_auth=AuthKitProvider(
        authkit_domain=getenv("AUTHKIT_DOMAIN"),
        base_url=getenv("AGENTOS_URL"),
    ),
)

Your users' Claude doesn't get your API as forty flat tools and a hope that it calls them in the right order. It gets one tool that takes plain language, and behind it is your agent, running on your infrastructure. Their agent handles the conversation. Your agent handles the work.

Now your agent is available as an MCP server. Claude, ChatGPT or any other MCP client can connect to it and use your agent. New distribution channel unlocked.

Distribute your agent in Slack

Your agent should meet your users where they already are: Slack, Discord, Telegram, WhatsApp. AgentOS serves these as interfaces, and distributing your agent through these channels is a few lines of code:

invoice_agent.py
from agno.os.interfaces.slack import Slack
 
agent_os = AgentOS(
    ...,  # from before
    interfaces=[Slack(agent=invoice_agent, resolve_user_identity=True)],
)

AgentOS will now make your agent available over Slack. The resolve_user_identity flag turns your users' raw Slack ID into their email, so if your product keys user_id by email, sessions and memory line up across all surfaces.

Get started with one prompt

We covered a lot:

  • Build an agent for your product with Agno.
  • Serve it as an API and an MCP server with AgentOS.
  • Distribute it through your product, Claude, ChatGPT and Slack.

To get started, pick your cloud and hand your coding agent the setup prompt. It clones a prebuilt AgentOS template for that cloud, sets up your platform, and helps you build your first agent.

Where do you want to run your OS?
Help me set up my agent platform and build my first agent.

Clone https://github.com/agno-agi/agentos-railway into a folder called agent-platform, cd in, and run the setup-platform skill (in .agents/skills/).
Or
Open in

Tell your coding agent whatever you want to build, and it will build it for you. If you want dedicated help making your product agentic, grab some time with me.

Thanks for reading.

Others also liked...