Python SDK

Use Circuit CLI to create and deploy agents using this SDK

Install the SDK

# Using pip
pip install circuit-agent-sdk

# or using uv (recommended)
uv add circuit-agent-sdk
circle-info

Requires Python ≥ 3.12. Works seamlessly with the Circuit CLI for local testing and publishing.

Agent Constructor

Create a Circuit Agent instance by passing in run and unwind functions.

Signature

Agent(
  run_function: Callable[[AgentContext], None],
  unwind_function: Callable[[AgentContext, list[CurrentPosition]], None] | None = None,
  config: AgentConfig | None = None
)
class AgentConfig:
    title: str = "Circuit Agent"          # Agent display name
    description: str = "A Circuit Agent"  # Agent description
    version: str = "1.0.0"                # Agent version

Parameters

Param
Type
Description

run_function

Callable[[AgentContext], None]

The execution function that runs your agent's logic

unwind_function?

Callable[[AgentContext, list[CurrentPosition]], None]

The cleanup function called when the agent unwinds

config?

AgentConfig

Agent configuration (title, description, version)

Examples

AgentContext interface

Main interface for interacting with the Circuit platform. This object is passed to your run_function and unwind_function and contains the following.

Session Data

Property
Type
Description

agent.sessionId

int

Unique session identifier

agent.sessionWalletAddress

str

Wallet address for this session

agent.currentPositions

list[CurrentPosition]

Positions allocated to agent at start of execution

Core Methods

Method
Description

Send messages to users and log locally

Sign and broadcast blockchain transactions

Sign messages (EVM only)

Namespace

Namespace
Description

Persist data across executions ( .set(), .get(), .list(), .delete() )

Cross-chain swaps and bridges ( .quote(), .execute() )

Trade prediction markets ( .market_order(), .redeem_positions() )

Last updated