Skip to content

Python Client Configuration Reference

This is the complete reference for all configuration options available in the runcycles Python client.

CyclesConfig

All configuration is provided through the CyclesConfig dataclass.

Required fields

FieldTypeDescription
base_urlstrBase URL of the Cycles server (e.g., http://localhost:7878)
api_keystrAPI key for authentication

Subject defaults

These fields set default values for the Subject used in @cycles decorators. They apply to all decorated functions unless overridden at the decorator level.

FieldTypeDefaultDescription
tenantstr | NoneNoneDefault tenant
workspacestr | NoneNoneDefault workspace
appstr | NoneNoneDefault application name
workflowstr | NoneNoneDefault workflow
agentstr | NoneNoneDefault agent
toolsetstr | NoneNoneDefault toolset

HTTP timeouts

FieldTypeDefaultDescription
connect_timeoutfloat2.0TCP connection timeout in seconds
read_timeoutfloat5.0Read timeout for responses in seconds

Retry configuration

Controls the commit retry engine for transient failures.

FieldTypeDefaultDescription
retry_enabledboolTrueEnable automatic commit retries
retry_max_attemptsint5Maximum number of retry attempts
retry_initial_delayfloat0.5Delay before the first retry (seconds)
retry_multiplierfloat2.0Backoff multiplier between retries
retry_max_delayfloat30.0Maximum delay between retries (seconds)

How retry works

When a commit fails with a transport error or 5xx response, the retry engine schedules a retry using exponential backoff:

Attempt 1: wait 0.5s
Attempt 2: wait 1.0s
Attempt 3: wait 2.0s
Attempt 4: wait 4.0s
Attempt 5: wait 8.0s (capped at max_delay)

Non-retryable errors (4xx responses) are not retried.

Programmatic configuration

python
from runcycles import CyclesConfig

config = CyclesConfig(
    # Required
    base_url="http://localhost:7878",
    api_key="cyc_live_...",

    # Subject defaults
    tenant="acme",
    workspace="production",
    app="support-bot",

    # HTTP settings
    connect_timeout=2.0,
    read_timeout=5.0,

    # Commit retry
    retry_enabled=True,
    retry_max_attempts=5,
    retry_initial_delay=0.5,
    retry_multiplier=2.0,
    retry_max_delay=30.0,
)

Environment variable configuration

Use CyclesConfig.from_env() to load configuration from environment variables. The default prefix is CYCLES_:

python
config = CyclesConfig.from_env()
Environment variableMaps toRequired
CYCLES_BASE_URLbase_urlYes
CYCLES_API_KEYapi_keyYes
CYCLES_TENANTtenantNo
CYCLES_WORKSPACEworkspaceNo
CYCLES_APPappNo
CYCLES_WORKFLOWworkflowNo
CYCLES_AGENTagentNo
CYCLES_TOOLSETtoolsetNo
CYCLES_CONNECT_TIMEOUTconnect_timeoutNo
CYCLES_READ_TIMEOUTread_timeoutNo
CYCLES_RETRY_ENABLEDretry_enabledNo
CYCLES_RETRY_MAX_ATTEMPTSretry_max_attemptsNo
CYCLES_RETRY_INITIAL_DELAYretry_initial_delayNo
CYCLES_RETRY_MULTIPLIERretry_multiplierNo
CYCLES_RETRY_MAX_DELAYretry_max_delayNo

A custom prefix can be passed: CyclesConfig.from_env(prefix="MY_PREFIX_").

Setting a default client

Instead of passing client= to every @cycles decorator, set a module-level default:

python
from runcycles import CyclesClient, set_default_client, set_default_config

# Option 1: Set a config (client created lazily)
set_default_config(config)

# Option 2: Set an explicit client
set_default_client(CyclesClient(config))

Resolution order

For each Subject field, the decorator resolves the value using this priority:

  1. Decorator parameter — if set on the @cycles decorator, it wins
  2. Config default — if set on the CyclesConfig instance

If neither provides a value, the field is omitted from the request.

Disabling retry

python
config = CyclesConfig(
    base_url="http://localhost:7878",
    api_key="cyc_live_...",
    retry_enabled=False,
)

Aggressive retry for critical commits

python
config = CyclesConfig(
    base_url="http://localhost:7878",
    api_key="cyc_live_...",
    retry_max_attempts=10,
    retry_initial_delay=0.2,
    retry_multiplier=1.5,
    retry_max_delay=60.0,
)

Next steps