tinyagent README

The project's README from github.com/timczm/tinyagent. As one markdown file: README.md.

English | 简体中文

A lightweight Python agent for one trusted user and one running instance.

tinyagent provides a command-line interface and an in-process Python SDK, with support for DeepSeek and custom OpenAI-compatible providers, persistent sessions, workspace tools, layered memory, MCP servers, and progressively loaded skills.

tinyagent requires Python 3.11 or later and currently targets Linux first.

Highlights

Quick start

Install uv, then install the project and initialize the current directory as a tinyagent workspace:

cd tinyagent
uv sync
uv run tinyagent init

init creates .tinyagent/config.toml, .tinyagent/workspace-id, and an empty skills/ directory. Provide API keys through the environment variable named in the provider configuration; never store credentials in the configuration file:

export DEEPSEEK_API_KEY="your-api-key"

Command execution on Linux requires Bubblewrap by default. If Bubblewrap is not installed or cannot run, tinyagent can detect the system, show the exact install command, and ask for confirmation before installing it:

uv run tinyagent sandbox install

Run diagnostics to verify the configuration, state store, memory, MCP servers, and command sandbox:

uv run tinyagent doctor

Start with a single turn:

uv run tinyagent run "Introduce yourself in one sentence."

Or open an interactive chat in a specific local workspace:

uv run tinyagent chat --workspace /tmp/tinyagent-test

Guided tour

Interactive chat

The chat interface supports persistent sessions, streaming Markdown, command completion, and multiline input:

/new [name]        Create and switch to a new session
/sessions          List sessions in the current workspace
/resume <id|name>  Switch to an existing session
/help              Show help
/exit              Exit chat

Press Enter to send, Ctrl-J or Alt-Enter to insert a newline, and Ctrl-D to exit. Type / and press Tab to complete commands.

Providers and tools

The default configuration lives at .tinyagent/config.toml in the workspace. A typical configuration looks like this:

[agent]
provider = "deepseek"
model = "deepseek-v4-flash"
context_window_tokens = 64000
max_tool_iterations = 50
max_tool_output_chars = 20000

[providers.deepseek]
base_url = "https://api.deepseek.com"
api_key_env = "DEEPSEEK_API_KEY"
request_timeout_seconds = 120
stream_idle_timeout_seconds = 30
max_retries = 2
retry_base_delay_seconds = 0.25

[tools]
enabled = true
read_only = false
allow_unsafe_exec = false
exec_network_access = true
max_file_bytes = 1048576
max_list_entries = 1000
exec_timeout_seconds = 60
max_exec_output_chars = 20000

[memory]
enabled = true
max_chars = 6000
curator_event_threshold = 10

[mcp]

To use another OpenAI-compatible service, add a provider section and set agent.provider to its name. tinyagent currently uses the Chat Completions API.

For read-only operation:

[tools]
read_only = true

Set enabled = false to disable the built-in workspace tools entirely. Only set allow_unsafe_exec = true when you explicitly accept execution without process-level filesystem isolation.

Sessions

Create, inspect, switch, and delete persistent sessions from the CLI:

uv run tinyagent sessions new project-a
uv run tinyagent sessions list
uv run tinyagent sessions resume project-a
uv run tinyagent run "Continue our previous discussion."
uv run tinyagent sessions delete project-a

You can also select a session for one command without changing the active session:

uv run tinyagent run "Remember the number 17." --session-id project-a
uv run tinyagent chat --session-id project-a

Memory

Inspect and manage long-term memory with:

uv run tinyagent memory show
uv run tinyagent memory sync
uv run tinyagent memory history --limit 20
uv run tinyagent memory restore 3

Long-term memory is stored as readable Markdown in .tinyagent/memory/MEMORY.md. After editing it manually, run memory sync to record a new revision.

MCP servers

Configure a remote Streamable HTTP server:

[mcp.servers.openai_docs]
transport = "streamable_http"
url = "https://developers.openai.com/mcp"
enabled_tools = ["search_openai_docs", "fetch_openai_doc"]  # optional
connect_timeout_seconds = 30
tool_timeout_seconds = 60
allow_parallel_calls = false

Or configure a local stdio server:

[mcp.servers.local_index]
transport = "stdio"
command = "uvx"
args = ["local-index-mcp"]
cwd = "."
env = { CHILD_TOKEN = "LOCAL_INDEX_TOKEN" }
enabled_tools = ["*"]

Values in env and headers_from_env are the names of source environment variables, not credentials. After configuring a server, run uv run tinyagent doctor to inspect its connection and discovered tools.

Skills

Workspace skills live at skills/<name>/SKILL.md. A minimal skill looks like this:

---
name: release-notes
description: Produce concise release notes from the current changes.
---
# Release notes

Summarize user-visible behavior, compatibility changes, and verification.

List, validate, or inspect skills from the CLI:

uv run tinyagent skills list
uv run tinyagent skills validate
uv run tinyagent skills show release-notes

The model can load a relevant skill on demand. You can also activate one explicitly in a prompt:

Use $release-notes to prepare notes for this release.

Interfaces

CLI

Use uv run in a source checkout:

uv run tinyagent run "Hello"
uv run tinyagent chat

After installing the package, invoke the command directly:

tinyagent run "Hello"
tinyagent chat

Select another workspace with --workspace:

tinyagent doctor --workspace /path/to/workspace
tinyagent run "Summarize the current project." --workspace /path/to/workspace

Async Python SDK

The asynchronous API is the core interface:

import asyncio

from tinyagent import AsyncTinyAgent


async def main() -> None:
    async with AsyncTinyAgent.from_config(workspace=".") as agent:
        session = await agent.sessions.new("demo")
        result = await agent.run("Hello", session_id=session.id)
        print(result.content)


asyncio.run(main())

Stream events as they arrive:

async with AsyncTinyAgent.from_config(workspace=".") as agent:
    async for event in agent.stream("Introduce this project."):
        if event.type == "text.delta":
            print(event.delta or "", end="", flush=True)

Synchronous Python SDK

from tinyagent import TinyAgent


with TinyAgent.from_config(workspace=".") as agent:
    result = agent.run("Hello")
    print(result.content)

Development

Runnable examples for each release are available in examples/:

uv run python examples/v0_7_demo.py

The standard development checks do not require provider credentials:

uv run ruff check src tests
uv run basedpyright
uv run pytest

Detailed design notes are available for each module:

License

This project is licensed under the terms in LICENSE.

tinyagent (timczm/tinyagent)

Searching Database…

这是什么?tinyagent 是一个轻量级 Python AI 智能体,带有核心智能体循环,为单一可信用户和单一运行实例而构建,同时提供 CLI 和进程内 Python SDK。
它是 CLI 工具,还是我导入的库?两者都是:它既是命令行界面,又是进程内 Python SDK,两者共享同一个异步智能体运行时,因此你可以在终端里聊天,也可以把它嵌入自己的 Python 代码。
怎么让它跑起来?安装 uv,安装本项目,然后运行 init 命令把当前目录变成 tinyagent 工作区,这会创建 .tinyagent/config.toml、一个 workspace-id 文件和一个 skills/ 目录。
需要 Python 和特定大模型提供商的 API 密钥吗?需要,它要求 Python 3.11 或更高版本,你需要通过环境变量提供 API 密钥,默认面向 DeepSeek,也可以是任何其他 OpenAI 兼容的 Chat Completions 端点。
运行 shell 命令有什么要注意的?在 Linux 上执行命令默认需要 Bubblewrap 做沙箱;如果缺少它,tinyagent 可以主动提出安装;只有显式设置 allowunsafeexec 才能禁用沙箱,而这会移除文件系统隔离。
它也能在 macOS 或 Windows 上运行吗?它目前优先面向 Linux;README 未确认支持 macOS 或 Windows。
这是桌面应用,还是在终端里运行?它是基于终端的 CLI,支持流式 Markdown、命令补全和多行输入,另有一个用于嵌入脚本的 Python SDK。
我的会话和对话历史存在哪里?会话和完整的消息历史以 SQLite 存储在本地,保存在工作区目录之外。
MCP 服务器支持是怎么工作的?你可以通过显式的工具注册表连接远程 Streamable HTTP MCP 服务器或本地 stdio 服务器,并运行 doctor 命令来检查连接和发现的工具。
技能系统是什么?技能是存储在工作区 skills/ 文件夹内 SKILL.md 文件中的可复用指令;它们是渐进加载的,只在模型判断相关或在提示中显式激活时才会加载。
它有什么样的长期记忆?它把压缩后的对话上下文与整理过的、人类可读的长期记忆结合起来,后者以 Markdown 形式存储在 .tinyagent/memory/MEMORY.md,你可以手动编辑后再同步。
内置了哪些工作区工具?具备工作区感知的工具让智能体可以读取、写入、打补丁、列出文件和执行命令,全部限定在一个经过校验的工作区目录内以确保安全。
What are similar projects?codeAgent, Baize, bareloop, brigade, Benzi, Proteus, Raven, claude-code
Creator
timczm
Size
0.3 MB
Stars
253
Updated
CommitAug 24
Age
1mo
Commits · 90 Days