Skip to main content

Qoder Agent SDK for Python

Python SDK for building applications on top of Qoder Agent.

The SDK starts qodercli for you, streams agent messages back to Python, and lets your application configure tools, permissions, working directories, MCP servers, hooks, and interactive sessions.

Installation

pip install qoder-agent-sdk

Prerequisites:

  • Python 3.10+
  • A Qoder account or another authentication method supported by your host application

CLI Behavior

Published platform wheels include a bundled qodercli, so a separate CLI installation is not required for normal SDK use. If you prefer to use a system-wide CLI or a pinned local build, pass QoderAgentOptions(cli_path=...).

Authentication

Every SDK query needs an explicit authentication option.

To reuse the local qodercli login state:

from qoder_agent_sdk import QoderAgentOptions, qodercli_auth

options = QoderAgentOptions(auth=qodercli_auth())

To authenticate with a personal access token:

Generate a Personal Access Token at qoder.com/account/integrations:

  1. Sign in to your Qoder account.
  2. Open the integrations page.
  3. Create a new PAT, choosing the expiry and scopes you need.
  4. Copy the token immediately. The value cannot be retrieved again after the page is closed.

Use separate tokens for local scripts, CI, and production services when possible, so each environment can be revoked independently. Do not hard-code tokens in source code.

from qoder_agent_sdk import QoderAgentOptions, access_token_from_env

options = QoderAgentOptions(auth=access_token_from_env())

access_token_from_env() reads QODER_PERSONAL_ACCESS_TOKEN by default.

Quick Start

import anyio
from qoder_agent_sdk import QoderAgentOptions, qodercli_auth, query


async def main() -> None:
    options = QoderAgentOptions(auth=qodercli_auth())

    async for message in query(
        prompt="What is 2 + 2?",
        options=options,
    ):
        print(message)


anyio.run(main)

Basic Usage

query() runs a single SDK query and returns an async iterator of response messages.

from qoder_agent_sdk import (
    AssistantMessage,
    QoderAgentOptions,
    TextBlock,
    qodercli_auth,
    query,
)

options = QoderAgentOptions(
    auth=qodercli_auth(),
    system_prompt="You are a helpful assistant.",
    max_turns=1,
)

async for message in query(prompt="Explain this repository", options=options):
    if isinstance(message, AssistantMessage):
        for block in message.content:
            if isinstance(block, TextBlock):
                print(block.text)

Tools and Permissions

Qoder Agent can use tools such as file reads, file edits, shell commands, and MCP tools. allowed_tools is an approval allowlist: listed tools are auto-approved, while unlisted tools continue through permission_mode and can_use_tool for a decision. It does not remove tools from the agent's available toolset. To block tools, use disallowed_tools.

from qoder_agent_sdk import QoderAgentOptions, qodercli_auth, query

options = QoderAgentOptions(
    auth=qodercli_auth(),
    allowed_tools=["Read", "Edit"],
    disallowed_tools=["Bash"],
    permission_mode="acceptEdits",
)

async for message in query(
    prompt="Update the README introduction.",
    options=options,
):
    print(message)

For application-specific approval flows, provide can_use_tool:

from qoder_agent_sdk import (
    PermissionResultAllow,
    PermissionResultDeny,
    QoderAgentOptions,
    ToolPermissionContext,
    qodercli_auth,
)


async def can_use_tool(
    tool_name: str,
    tool_input: dict,
    context: ToolPermissionContext,
):
    if tool_name == "Bash":
        return PermissionResultDeny(message="Shell commands are disabled here.")
    return PermissionResultAllow()


options = QoderAgentOptions(
    auth=qodercli_auth(),
    can_use_tool=can_use_tool,
)

Working Directory

Use cwd to run the agent in a specific project directory:

from pathlib import Path

from qoder_agent_sdk import QoderAgentOptions, qodercli_auth

options = QoderAgentOptions(
    auth=qodercli_auth(),
    cwd=Path("/path/to/project"),
)

Interactive Sessions

Use QoderSDKClient when you need a long-lived, bidirectional session instead of a single query() call.

from qoder_agent_sdk import QoderAgentOptions, QoderSDKClient, qodercli_auth

options = QoderAgentOptions(auth=qodercli_auth())

async with QoderSDKClient(options=options) as client:
    await client.query("Inspect this project and summarize the main modules.")

    async for message in client.receive_response():
        print(message)

QoderSDKClient is useful for chat interfaces, follow-up prompts, interrupts, runtime permission changes, MCP server management, and other workflows that need state across multiple turns.

Custom Tools

You can expose Python functions to Qoder Agent as in-process SDK MCP servers. This avoids managing a separate MCP subprocess for simple application-local tools.

from qoder_agent_sdk import (
    QoderAgentOptions,
    QoderSDKClient,
    create_sdk_mcp_server,
    qodercli_auth,
    tool,
)


@tool("greet", "Greet a user", {"name": str})
async def greet_user(args):
    return {
        "content": [
            {"type": "text", "text": f"Hello, {args['name']}!"}
        ]
    }


server = create_sdk_mcp_server(
    name="my-tools",
    version="1.0.0",
    tools=[greet_user],
)

options = QoderAgentOptions(
    auth=qodercli_auth(),
    mcp_servers={"tools": server},
    allowed_tools=["mcp__tools__greet"],
)

async with QoderSDKClient(options=options) as client:
    await client.query("Greet Alice.")
    async for message in client.receive_response():
        print(message)

Hooks

Hooks are deterministic Python callbacks invoked at specific points in the agent loop. They are useful for validation, policy checks, logging, and application-specific feedback.

from qoder_agent_sdk import HookMatcher, QoderAgentOptions, qodercli_auth


async def block_script(input_data, tool_use_id, context):
    if input_data["tool_name"] != "Bash":
        return {}

    command = input_data["tool_input"].get("command", "")
    if "./deploy.sh" in command:
        return {
            "hookSpecificOutput": {
                "hookEventName": "PreToolUse",
                "permissionDecision": "deny",
                "permissionDecisionReason": "Deployment scripts require review.",
            }
        }
    return {}


options = QoderAgentOptions(
    auth=qodercli_auth(),
    hooks={
        "PreToolUse": [
            HookMatcher(matcher="Bash", hooks=[block_script]),
        ],
    },
)

Error Handling

from qoder_agent_sdk import (
    CLIConnectionError,
    CLIJSONDecodeError,
    CLINotFoundError,
    ProcessError,
    QoderAgentOptions,
    QoderSDKError,
    qodercli_auth,
    query,
)

try:
    async for message in query(
        prompt="Hello Qoder",
        options=QoderAgentOptions(auth=qodercli_auth()),
    ):
        print(message)
except CLINotFoundError:
    print("qodercli was not found. Install a platform wheel or set cli_path.")
except CLIConnectionError as exc:
    print(f"Connection failed: {exc}")
except ProcessError as exc:
    print(f"qodercli exited with code {exc.exit_code}")
except CLIJSONDecodeError as exc:
    print(f"Could not parse qodercli output: {exc}")
except QoderSDKError as exc:
    print(f"SDK error: {exc}")

License and Terms

Copyright (c) 2026 Qoder

Use of this software is governed by the Qoder Product Service Terms:

https://qoder.com/product-service

By installing or using this package, you agree to those terms.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qoder_agent_sdk-1.0.8.tar.gz (348.1 kB view details)

Uploaded Source

Built Distributions

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

qoder_agent_sdk-1.0.8-py3-none-win_amd64.whl (59.9 MB view details)

Uploaded Python 3Windows x86-64

qoder_agent_sdk-1.0.8-py3-none-musllinux_1_2_x86_64.whl (49.2 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

qoder_agent_sdk-1.0.8-py3-none-musllinux_1_2_aarch64.whl (48.5 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

qoder_agent_sdk-1.0.8-py3-none-manylinux_2_17_x86_64.whl (50.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

qoder_agent_sdk-1.0.8-py3-none-manylinux_2_17_aarch64.whl (49.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

qoder_agent_sdk-1.0.8-py3-none-macosx_11_0_x86_64.whl (41.7 MB view details)

Uploaded Python 3macOS 11.0+ x86-64

qoder_agent_sdk-1.0.8-py3-none-macosx_11_0_arm64.whl (37.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file qoder_agent_sdk-1.0.8.tar.gz.

File metadata

  • Download URL: qoder_agent_sdk-1.0.8.tar.gz
  • Upload date:
  • Size: 348.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.14

File hashes

Hashes for qoder_agent_sdk-1.0.8.tar.gz
Algorithm Hash digest
SHA256 9ed0306819d55e9068cb5d97e87e8c8f46a0abb9d32d3d44d93b76e69882aed2
MD5 f60353ccfa7cd01ed7734ff0dc992001
BLAKE2b-256 ac733dd7b7d7170b02253f26d78fce0d0d0b0a13826312b9f42e09d5a8c60527

See more details on using hashes here.

File details

Details for the file qoder_agent_sdk-1.0.8-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for qoder_agent_sdk-1.0.8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 55357919c74e861854516b5fd24cd92a0c2061b7ed0e7dbdd3a7f6ce0b420c40
MD5 f879872f794167c882b70ca4b495dc14
BLAKE2b-256 6d20d25a78b0c76d5a6a9bf3a82490c0b73369d8160ecf5163415bdd3bba964c

See more details on using hashes here.

File details

Details for the file qoder_agent_sdk-1.0.8-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for qoder_agent_sdk-1.0.8-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fded35b3ee523ca6be9660a3de12737dbf013233eb5648fe8201d2890ffe1a21
MD5 4e102fd37af0d00ffdb0702e42a9e348
BLAKE2b-256 02c41205983b9abe62327254ea8455b1d7fa9acec59edc40d5fb6d5fc5ff312f

See more details on using hashes here.

File details

Details for the file qoder_agent_sdk-1.0.8-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for qoder_agent_sdk-1.0.8-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 473c88e3c3ca23e591574847bffd044f2ed2b773975daba1c75abb7246eb570e
MD5 8b0e6f77b948f0075fe9ea3930f3f6b1
BLAKE2b-256 903ed142a3399ab6a484ea3d13d0a08c742ced445a9fdefd0060cbaf1365d7a3

See more details on using hashes here.

File details

Details for the file qoder_agent_sdk-1.0.8-py3-none-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for qoder_agent_sdk-1.0.8-py3-none-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 2727d20bdceb89d179fbbe233f1c23efe3afd0ebea4fe178822bf42bdc1c808d
MD5 9291b1ca1728bcecf80b790cf169a207
BLAKE2b-256 98d97af0c60d42d619245a90441726eb2473638fdeaf0762dda50a353e39e815

See more details on using hashes here.

File details

Details for the file qoder_agent_sdk-1.0.8-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for qoder_agent_sdk-1.0.8-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 9e7abb0df5349717beab2ce991892d36d7fd980c6a4c0ba6630baf4163f0a1c9
MD5 8e387bfc08317fcf8973d346a463006f
BLAKE2b-256 b396a02cb228c55b2df2a0e67e7fc260c7bcd1b5e0ab0b01868d430b2a7dbfd9

See more details on using hashes here.

File details

Details for the file qoder_agent_sdk-1.0.8-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for qoder_agent_sdk-1.0.8-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 032528aed3b36f1e07cfb4eaaa6cefe4d5f3df129e98cb4684fe090f644a4bac
MD5 591f72c883b67c5933a4ae4c2605a2e6
BLAKE2b-256 058c26a06a01e2ec2f146cca9b097a2a3bac0d1e94537551ad55e74aa1036d33

See more details on using hashes here.

File details

Details for the file qoder_agent_sdk-1.0.8-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qoder_agent_sdk-1.0.8-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 48f8fdbfce8fa8b2ce3f62605c3fe6b5d02a23fbef231c961bf5687ced94490e
MD5 9d8f77e9b908938f242b16f22a7ee50e
BLAKE2b-256 8580c14f518f39a4259ab8b8725b39ee01f19f3e8fc92367e3789a4375650ccd

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.13

8 files

1.0.12

8 files

1.0.11

8 files

1.0.10

8 files

1.0.9

8 files

This release

1.0.8 This release

8 files

1.0.5

8 files

1.0.2

8 files

1.0.1

8 files

1.0.0

8 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page