Python client for the swebot autonomous coding agent
Project description
swebot-client
Python client for the swebot autonomous coding agent.
Pure Python — zero dependencies beyond the standard library.
Install
# pip
pip install swebot-client
# uv
uv add swebot-client
Quick start
from swebot_client import SwebotClient
client = SwebotClient("http://localhost:8080")
session = client.create_session()
# Stream tokens
for token in session.stream("explain goroutines"):
print(token, end="", flush=True)
# Or get the full reply at once
reply = session.send("what is 2+2?")
print(reply)
Features
- Streaming — real-time token-by-token output via SSE
- Tool callbacks — observe tool invocations and results
- Session management — create, resume, list, delete sessions
- Todos — read and update agent todo items
- MCP management — configure MCP servers programmatically
- Context control — compact or clear session context
- Skills — list and use built-in skill agents
Examples
from swebot_client import SwebotClient, Session, ToolCall, TodoItem
client = SwebotClient("http://localhost:8080")
# Wait for backend to be ready
client.wait_until_ready(timeout=10)
# Create a session with a specific agent
session = client.create_session(agent="developer")
# Stream with tool call callbacks
def on_tool(tc: ToolCall):
print(f" ⚙ {tc.name}")
reply = session.send_with_events(
"create a hello.py file",
on_tool_start=on_tool,
)
# Read todos
for todo in session.get_todos():
print(f"[{todo.status}] {todo.title}")
# List MCP servers
for mcp in client.list_mcp():
print(f"{mcp['name']}: {'connected' if mcp.get('connected') else 'disconnected'}")
# Token usage
usage = session.token_usage()
print(f"Tokens: {usage['tokens_in']:,} in / {usage['tokens_out']:,} out ({usage['usage_pct']}%)")
API reference
SwebotClient(addr, token="")
| Method | Description |
|---|---|
health() |
Check if backend is reachable |
wait_until_ready(timeout) |
Block until backend responds |
create_session(agent) |
Create a new session → Session |
get_session(id) |
Resume an existing session → Session |
list_sessions() |
List all sessions |
delete_session(id) |
Delete a session |
list_agents() |
List available agents |
list_providers() |
List LLM providers |
stats() |
Backend stats (model, tokens, uptime) |
skills() |
List built-in skill agents |
list_mcp() |
List MCP servers |
add_mcp(...) |
Add an MCP server |
delete_mcp(name) |
Remove an MCP server |
shutdown() |
Gracefully stop the backend |
Session
| Method | Description |
|---|---|
stream(message) |
Stream tokens → Iterator[str] |
send(message) |
Send and get full reply → str |
send_with_events(message, ...) |
Send with tool callbacks → str |
get_todos() |
List todo items → list[TodoItem] |
update_todo(id, status) |
Update a todo's status |
compact() |
Trigger context compaction |
clear() |
Clear all session context |
token_usage() |
Get token usage stats |
Requirements
- Python 3.9+
- A running swebot backend (
swebot --serve)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
swebot_client-0.9.7.tar.gz
(6.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swebot_client-0.9.7.tar.gz.
File metadata
- Download URL: swebot_client-0.9.7.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
797c45cd7e21394bc2550633bd6e01f98c61f94843bae76df9134e392acc8a0a
|
|
| MD5 |
cd156398247abd486150931d71be1da3
|
|
| BLAKE2b-256 |
98b8ee0aca624c239dec91b5f785f3ae2d91f84dbfe1ed3c315c9aa6fd16b91d
|
File details
Details for the file swebot_client-0.9.7-py3-none-any.whl.
File metadata
- Download URL: swebot_client-0.9.7-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cb72f89ed409b455a98c3aed125c4662dacf96f1326c332315112556a240fb9
|
|
| MD5 |
ba0074421d8841a36ec55ecb07639c43
|
|
| BLAKE2b-256 |
49239884f32829cef4153e3d9def4730921621b6aaa778a1b5bba0571086d477
|