Skip to main content

Python SDK for d:spatch agent-to-host communication

Project description

dspatch-sdk

Python SDK for building containerized AI agents on the d:spatch orchestration platform.

Agents run inside Docker containers and communicate with the d:spatch router over gRPC. The SDK handles connection lifecycle, turn management, and provides a simple Context API for logging, messaging, inter-agent communication, and user inquiries.

Installation

pip install dspatch-sdk

Requires Python 3.10+.

Quick Start

from dspatch import DspatchEngine, Context

engine = DspatchEngine()

@engine.agent()
async def my_agent(ctx: Context):
    await ctx.log("info", "Agent started")
    await ctx.message("Hello from my agent!")

engine.run()

With Claude

from dspatch import DspatchEngine, ClaudeAgentContext

engine = DspatchEngine()

@engine.agent(context_class=ClaudeAgentContext)
async def my_agent(ctx: ClaudeAgentContext):
    await ctx.run()

engine.run()

With OpenAI

from dspatch import DspatchEngine, OpenAiAgentContext

engine = DspatchEngine()

@engine.agent(context_class=OpenAiAgentContext)
async def my_agent(ctx: OpenAiAgentContext):
    await ctx.run()

engine.run()

Context API

The Context object is passed to your agent function each turn:

Method Description
ctx.log(level, message) Structured logging (visible in the d:spatch app)
ctx.activity(description) Activity status updates
ctx.message(content, role) Send a message to the conversation
ctx.files(paths) Attach files
ctx.inquire(question, priority, timeout) Ask the user a question (blocks until answered)
ctx.talk_to(peer, message) Send a message to another agent (blocks until response)
ctx.prompt(text) Raw prompt passthrough

Agent Template

Agents are configured with a dspatch.agent.yml in their project directory:

name: My Agent
description: What this agent does.
entry_point: agent.py
fields:
  system_prompt: <base64-encoded prompt>
required_env:
  - ANTHROPIC_API_KEY

See the user guide for the full config reference.

Documentation

Full documentation at dspatch.dev/docs.

License

AGPL-3.0 — see LICENSE for details.

Project details


Download files

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

Source Distribution

dspatch_sdk-0.1.3.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

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

dspatch_sdk-0.1.3-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

Details for the file dspatch_sdk-0.1.3.tar.gz.

File metadata

  • Download URL: dspatch_sdk-0.1.3.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dspatch_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6cebfa5e2997db6dc1a971fb7e344414b0b7d6c2209b60404d49e651115db017
MD5 15225386c3a9c3f4216316bb3bb0cb83
BLAKE2b-256 f9f38be5c374ebf9cc2f063fcf2f08ff88b8c9861de81eee00cb6f9d92201edc

See more details on using hashes here.

Provenance

The following attestation bundles were made for dspatch_sdk-0.1.3.tar.gz:

Publisher: publish.yml on dspatch/sdk.python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dspatch_sdk-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: dspatch_sdk-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dspatch_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bac266a92306e1af0e26adb23bc3ad3f7cb9c014c612fd1c2fcbad7356c9ed53
MD5 1a00fedb1d503f74ec683718b88e217a
BLAKE2b-256 e9595d8322639f00fc53afb0c3955fe4c0a54f9f87553799b9237a5e7de66e08

See more details on using hashes here.

Provenance

The following attestation bundles were made for dspatch_sdk-0.1.3-py3-none-any.whl:

Publisher: publish.yml on dspatch/sdk.python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page