Multi-turn tool-calling agent runtime for embedding the mycode agent loop.
Project description
mycode-sdk
Lightweight Python SDK for the mycode multi-turn tool-calling agent. Import name: mycode.
Install
uv add mycode-sdk
# or
pip install mycode-sdk
Quick Start
Agent(...) fills in sensible defaults: provider inferred from the model id, session_id generated, session log auto-persisted to ~/.mycode/sessions/<session_id>/. By default no tools are registered — pick the built-ins you want or register your own via @tool.
import asyncio
from mycode import Agent, bash_tool, read_tool
async def main() -> None:
agent = Agent(
model="claude-sonnet-4-6",
api_key="YOUR_API_KEY",
cwd=".",
system="You are a concise coding assistant.",
tools=[read_tool, bash_tool],
)
async for event in agent.achat("Read pyproject.toml and tell me the project name."):
if event.type == "text":
print(event.data["delta"], end="")
asyncio.run(main())
To resume a previous conversation, pass the same session_id (the agent loads its own history from disk).
Built-in tools
Pick and combine the four bundled coding tools:
from mycode import read_tool, write_tool, edit_tool, bash_tool
Custom Tools
@tool wraps a plain Python function (sync or async) as a ToolSpec. If the first parameter is annotated ToolContext, the context is injected; use ctx.call("read", {...}) to invoke another registered tool.
from mycode import Agent, ToolContext, read_tool, tool
@tool
def summarize_file(ctx: ToolContext, path: str) -> str:
"""Return the first line of a text file."""
result = ctx.call("read", {"path": path})
return result.model_text.splitlines()[0] if result.model_text else ""
agent = Agent(
model="claude-sonnet-4-6",
api_key="YOUR_API_KEY",
cwd=".",
tools=[read_tool, summarize_file],
)
Type hints drive the JSON schema. Unknown types raise; missing docstrings raise. async def tools are run via asyncio.run on the executor's worker thread.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 mycode_sdk-0.4.3.tar.gz.
File metadata
- Download URL: mycode_sdk-0.4.3.tar.gz
- Upload date:
- Size: 46.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d19b1a5fd90d7ec5c64523cfe4c47e66400c34a619d39b81e2e897977bb1782b
|
|
| MD5 |
be97ecede849b333cfe789e5443ab673
|
|
| BLAKE2b-256 |
1d41f6007a891485f2e6c3c3916217f886d30e1edbb9cfc89be23314ae77fe39
|
File details
Details for the file mycode_sdk-0.4.3-py3-none-any.whl.
File metadata
- Download URL: mycode_sdk-0.4.3-py3-none-any.whl
- Upload date:
- Size: 54.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75ec3370880027d171a2048933b67e691cf2abc4dd3bba148c1ee7569eb94d4a
|
|
| MD5 |
9cb4a49c7c11415a07782ba5f15c1d4e
|
|
| BLAKE2b-256 |
1a4652f26abf576f02a06b9cc10cb136536e37d221350c9a11142f44e1aea7de
|