Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
docs(sdk): document Nanobot teardown
Xubin Ren73353785a023
diff --git a/docs/python-sdk.md b/docs/python-sdk.mdindex 5ee66a349..14609c143 100644--- a/docs/python-sdk.md+++ b/docs/python-sdk.md@@ -11,8 +11,8 @@ from nanobot import Nanobotasync def main() -> None:- bot = Nanobot.from_config()- result = await bot.run("What time is it in Tokyo?")+ async with Nanobot.from_config() as bot:+ result = await bot.run("What time is it in Tokyo?")print(result.content)@@ -21,6 +21,8 @@ asyncio.run(main())`Nanobot.from_config()` reuses your normal `~/.nanobot/config.json`, so the SDK follows the same provider, model, tools, and workspace defaults as the CLI unless you override them.+Use `async with` when possible so MCP connections and background cleanup work are closed before the event loop exits. If you manage the instance manually, call `await bot.aclose()` in a `finally` block.+## Common Patterns### Use a specific config or workspace@@ -83,6 +85,15 @@ Run the agent once and return a `RunResult`.| `session_key` | `str` | `"sdk:default"` | Session identifier for conversation isolation. Different keys get independent history. || `hooks` | `list[AgentHook] \| None` | `None` | Lifecycle hooks for this run only. |+### `await bot.aclose()`++Release resources held by the SDK instance, including MCP connections. The async context manager calls this automatically:++```python+async with Nanobot.from_config() as bot:+ result = await bot.run("Summarize this repo")+```+### `RunResult`| Field | Type | Description |