Skip to main content
Every scenario below has a runnable script in the SDK’s examples/ directory. Each snippet assumes you are inside an AsyncCominty context and have an AGENT_ID:
Run the examples from a checkout of the repo:
New to the SDK? Read Overview first for install, auth, and the core concepts (client, resources, runs, tools).

Stream progress events

Watch the agent work — tool calls, LLM steps, the result — as it happens. Iterating a run yields progress events only; the finished reply is captured for you.
examples/01_stream_events.py

Fire and await the answer

No event handling — just the final reply.
examples/02_await_result.py

Continue the conversation

chat.send posts a follow-up in the same thread; the agent keeps context.
examples/03_follow_up.py

Answer the agent’s questions

When the agent needs input, it ends its turn with questions (a prompt plus options) instead of a final answer. Answer with a normal follow-up.
examples/04_answer_questions.py

List and search threads

examples/05_list_threads.py

Manage a thread

examples/06_manage_thread.py

Use a custom managed agent

A custom agent — its own model, failover order, and instructions, configured at platform.cominty.ai → Agents — is just another agent_id. Pass it to any chat call. This example feeds a jargon-heavy incident report to an agent instructed to reply with a clean, non-technical French executive summary.
examples/07_custom_agent.py

Pull live context from an MCP server

MCP servers connected to an agent on the platform (for example Linear) work with no SDK change — tools are on by default, and you only disable what you don’t want. Here the custom agent reads the current Linear sprint and reports it in its French C-level voice. Linear tool calls appear in the stream as ToolCall events.
examples/08_mcp_linear.py

Handle errors

See Exceptions for the full hierarchy.