Skip to main content

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="http://localhost:8080")

No token needed for local use. If the backend was started with --token, set SWEBOT_TOKEN in your environment — the SDK reads it automatically.

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.8.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swebot_client-0.9.8-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file swebot_client-0.9.8.tar.gz.

File metadata

  • Download URL: swebot_client-0.9.8.tar.gz
  • Upload date:
  • Size: 8.5 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

Hashes for swebot_client-0.9.8.tar.gz
Algorithm Hash digest
SHA256 36eae837c7c0d8a4cf727ddc35ad6618ef2a0501f345c25f9ba320f1367e0eee
MD5 2cff24fb42b5c7785dbbca61464cda8a
BLAKE2b-256 36b381420fd038163e32bf60a143f266a6f552a4d3932b0c513e22b97ef95d86

See more details on using hashes here.

File details

Details for the file swebot_client-0.9.8-py3-none-any.whl.

File metadata

  • Download URL: swebot_client-0.9.8-py3-none-any.whl
  • Upload date:
  • Size: 6.7 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

Hashes for swebot_client-0.9.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a2d4880b36cb5eb9dbe3dd1141dc42dea5b2127deb903b87c48cac086ffd4c15
MD5 e6929f9001835b24994413dfcc3fd55d
BLAKE2b-256 7aeb626b274fd14b5d0795335226eeafa553657e8280c6ecd1e723bda895848e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page