Skip to content

1.4 Hello Agentao in 5 min

Goal: get a minimal Python embedding running. Pure SDK path, no custom code.

Want a non-Python first taste? Jump to 3.1 ACP Quick Try instead.

⚡ Runnable end-to-end (≈ 3 minutes)

Outcome — agent thinks, runs glob + run_shell_command, prints the 3 largest files under cwd. Stackpip install 'agentao>=0.4.0' + 3 env vars + 6 lines of Python. Runpython hello.py (after pasting the snippet from Step 3 below).

Step 1 · Install (1 minute)

bash
pip install 'agentao>=0.4.0'

pip install agentao ships the embedding-only core. Add extras ([web], [cli], [i18n], …) later as needed — see 1.5 Requirements.

Step 2 · Configure credentials (1 minute)

bash
export OPENAI_API_KEY="sk-..."
export OPENAI_BASE_URL="https://api.openai.com/v1"   # or any OpenAI-compatible endpoint
export OPENAI_MODEL="gpt-5.4"

All three are required. DeepSeek / Gemini / vLLM work the same way — just point OPENAI_BASE_URL and OPENAI_MODEL at them.

Step 3 · Run (1 minute)

Save as hello.py:

python
from pathlib import Path
from agentao import Agentao

agent = Agentao(working_directory=Path.cwd())
print(agent.chat("List the 3 largest files under the current directory."))
agent.close()
bash
python hello.py

You'll see Agentao think, call run_shell_command / glob, and print a final answer like:

text
The three largest files under the current directory are:
1. ./node_modules/.cache/...   (12 MB)
2. ./dist/bundle.js            (4.1 MB)
3. ./README.md                 (38 KB)

What just happened

  • Agentao(...) created one stateful session — history, tools, and memory are bound to this instance
  • chat() ran the full LLM loop: think → call tool → observe → think → answer
  • working_directory rooted file/shell tools at the current dir. Always pass an explicit Path in production so concurrent instances don't share Path.cwd()
  • close() released MCP subprocesses and DB handles — wrap in try/finally in real code

Add streaming output (5 more lines)

python
from pathlib import Path
from agentao import Agentao
from agentao.transport import SdkTransport

def stream(ev):
    if ev.type.name == "LLM_TEXT":
        print(ev.data["chunk"], end="", flush=True)

agent = Agentao(
    working_directory=Path.cwd(),
    transport=SdkTransport(on_event=stream),
)
agent.chat("List the 3 largest files under the current directory.")
agent.close()

That's the whole pattern. Tool confirmations, custom tools, permissions, memory — every other feature extends from these two calls (Agentao(...) + chat(...)).

Troubleshooting

SymptomLikely cause
ImportError: cannot import name 'Agentao'Forgot pip install agentao, or imported from agentao.agent (not the public path)
ValueError: OPENAI_API_KEY is not setAll three of OPENAI_API_KEY / OPENAI_BASE_URL / OPENAI_MODEL are required
Agent says Tool execution cancelled by userDefault permissions denied a write — see 5.4
chat() never returnsLikely tool loop or no ask_user callback — see Appendix F.2

Full FAQ: Appendix F.

Where to go next

If you want to…Read
Wire one of your business APIs as a tool5.1 Custom Tools
Embed in FastAPI / Flask with SSE streaming2.7 FastAPI / Flask Embedding
Drive Agentao from Node / Go / Rust / IDEPart 3 · ACP
Verify environment requirements first1.5 Requirements
Understand the core nouns (Agent / Tool / Skill / …)1.2 Core Concepts