Pre-release
This release is a pre-release and may not be stable for production use.
CodeBuddy Agent SDK for Python
SDK for building AI agents with CodeBuddy Code's capabilities. Programmatically interact with AI to build autonomous agents that can understand codebases, edit files, and execute workflows.
Installation
# Using uv (recommended)
uv add codebuddy-agent-sdk
# Using pip
pip install codebuddy-agent-sdk
Quick Start
import asyncio
from codebuddy_agent_sdk import query
async def main():
async for message in query(
prompt="What files are in this directory?",
permission_mode="bypassPermissions",
):
if message.type == "assistant":
for block in message.content:
if hasattr(block, "text"):
print(block.text)
asyncio.run(main())
API Reference
query(prompt, **options)
Create a query to interact with the agent.
async for message in query(
prompt="Your prompt here",
model="sonnet", # Model to use
permission_mode="bypassPermissions", # Permission mode
max_turns=10, # Maximum conversation turns
cwd="/path/to/project", # Working directory
):
# Handle message
pass
Message Types
system- Session initialization infoassistant- Agent responses (text, tool calls)result- Query completion statustask_started/task_notification- Background task lifecycle events (TaskStartedMessage/TaskNotificationMessage, both subclasses ofSystemMessage). Emitted when a tool runs a command withrun_in_background: true. Concurrent tasks are told apart bytask_id.
Background tasks
Background task completion can arrive after the first ResultMessage, so use
CodeBuddySDKClient with receive_messages() (which keeps reading) rather than
query() / receive_response() (which stop at the first result):
from codebuddy_agent_sdk import (
CodeBuddySDKClient,
CodeBuddyAgentOptions,
TaskStartedMessage,
TaskNotificationMessage,
)
async def main():
options = CodeBuddyAgentOptions(permission_mode="bypassPermissions")
async with CodeBuddySDKClient(options=options) as client:
await client.query("Run a background command and report when it finishes")
async for msg in client.receive_messages():
if isinstance(msg, TaskStartedMessage):
print("started", msg.task_id, msg.description)
elif isinstance(msg, TaskNotificationMessage):
print("done", msg.task_id, msg.status, msg.output_file)
Related Links
Feedback
- Submit issues at Issues
- Contact: codebuddy@tencent.com
Release files for codebuddy-agent-sdk 0.3.265rc202609242240
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-musllinux_1_1_x86_64.whl | Python 3 | none | Linux musl 1.1+ x86-64 | Details |
| codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-musllinux_1_1_aarch64.whl | Python 3 | none | Linux musl 1.1+ ARM64 | Details |
| codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-manylinux_2_17_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-macosx_10_12_x86_64.whl | Python 3 | none | macOS 10.12+ x86-64 | Details |
Total release size: 349.2 MB
Release files / codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-win_amd64.whl
| Download URL | codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-win_amd64.whl |
|---|---|
| Size | 56.6 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2212eb6f363768c76041f791a690ba445c3876d57e2429ea17d0eb329a5002d5
|
|
BLAKE2b-256 checksum How to use checksums |
a9a0c9c0bb14bd471c3126c2d026f4fc70d2aea7dcfbcb60720b4fc7b5a4e27e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-musllinux_1_1_x86_64.whl
| Download URL | codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-musllinux_1_1_x86_64.whl |
|---|---|
| Size | 50.0 MB |
| Tags | Linux musl 1.1+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
000f515d8f43a76e74d136bc1f56895a29bca7363f3a8e3b148907f4d353a168
|
|
BLAKE2b-256 checksum How to use checksums |
92af45385e7260675c101ca5b0633503b8a350697e1d98d49e057b3481bd45c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-musllinux_1_1_aarch64.whl
| Download URL | codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-musllinux_1_1_aarch64.whl |
|---|---|
| Size | 49.8 MB |
| Tags | Linux musl 1.1+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
98bb53e2eb2e868e2a33d5119718d66b570ad0472ec9621476883548aa6796e9
|
|
BLAKE2b-256 checksum How to use checksums |
a79549c733e6ae5faeaa4385cac0bc0f6812fe830a74a176cd16926fee2cb9f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-manylinux_2_17_x86_64.whl
| Download URL | codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-manylinux_2_17_x86_64.whl |
|---|---|
| Size | 52.5 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
e8b56e7cf6fffa845ac09ee20b623856f596f61a117021d9652bf58b8cc54307
|
|
BLAKE2b-256 checksum How to use checksums |
03ccfc14221a5ec92830370c75e5a324115b9f8c6ead41e4a150eadf260f090a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-manylinux_2_17_aarch64.whl
| Download URL | codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-manylinux_2_17_aarch64.whl |
|---|---|
| Size | 52.4 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
2af5ead2ebd5019c4e50be448ea13aabcb83ad49883fed14eba9164a74b25eaa
|
|
BLAKE2b-256 checksum How to use checksums |
246c2baa43bd52204004a419d1272f7edda41135b5a595e71529957181064470
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-macosx_11_0_arm64.whl
| Download URL | codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 42.5 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
cc2aedb3be13ee7074af12465b4de36bb10566e18f1a3d39374b0c88416ffb7d
|
|
BLAKE2b-256 checksum How to use checksums |
a04880a1983b0a4b66e04e5993b50ad8b6337c7883484dc41f0b12f53a6ec412
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-macosx_10_12_x86_64.whl
| Download URL | codebuddy_agent_sdk-0.3.265rc202609242240-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 45.3 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
e5b4e9409421997e6c81606408cdd63429b25c1c452c40023332c0063268a23c
|
|
BLAKE2b-256 checksum How to use checksums |
3db00f0bb57e4d29a55fbc240d203455709ae461876f877767f4f6abe6c89894
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|