Recursion Python SDK
Typed, synchronous and asynchronous request/response access to the Recursion API. The client and Pydantic models are generated from Recursion's committed public OpenAPI contract snapshots. Session-event and gestalt streaming are excluded.
The distribution is
labelbox-recursion-sdk,
and the Python import is recursion_sdk. This implementation starts at version
0.1.0; earlier releases contain the retired SDK and its different import/API.
Build a wheel from this checkout to try the implementation before its first
release. Versions remain below 1.0 while the public API evolves.
import os
from recursion_sdk import Recursion
with Recursion(api_key=os.environ["RECURSION_API_KEY"]) as recursion:
result = recursion.managed_agents.list_sessions()
print(result.data, result.response.headers.get("etag"))
AsyncRecursion exposes the same methods as coroutines and supports
async with. The production base URL is https://api.recursion.labelbox.com.
Set organization_id or tenant_id on the constructor when the API key
requires those selectors. Operation-level selectors may repeat those values;
they cannot change the constructor's scope.
The agent, agent-version, vault, credential, memory-list, agent-template,
environment, setup-run, environment-template, sandbox-provider, and session
discovery/overview and event read methods use /managed-agents/v2. Session
lifecycle writes, agent-version changes, content reads, and budget methods also
use v2. delete_session returns a bodyless 204 with data=None.
Uploaded-file methods, integration provider, connection, catalog,
and install methods, evaluation listing, memory get, delete, version, and
revision methods, and session outcome and pending-input methods also use v2.
Vault/credential create, update, and delete methods also use v2. For example,
managed_agents.list_agents(limit=50, cursor=...) returns the v2 page with
items, nextCursor, and total; managed_agents.list_environments(limit=50, cursor=...) returns items and nextCursor; and
managed_agents.list_sessions(limit=50, cursor=...) returns items,
nextCursor, and a nullable total. Vault/credential writes accept the v2
camelCase request models and return v2 response shapes (including 201 for
creates and bodyless 204 for deletes). The newly migrated writes accept v2
camelCase request models. define_session_outcome returns 201, and
delete_integration_connection
returns a bodyless 204 with data=None instead of the v1 disconnect count.
Agent tag writes (replace_agent_tags, apply_agent_tag, and remove_agent_tag)
and probe_mcp_server also use v2. Tag replacement accepts tagIds and rejects
duplicate ids with RecursionContractError before sending the request, instead
of collapsing them as v1 does. Tag-write responses use camelCase tag fields;
removal still returns a bodyless 204.
probe_mcp_server accepts serverUrl and optional vaultIds and returns the
v2 probe model with camelCase JSON aliases. It omits the deprecated, always-false
deployment_authorized attribute from v1. The v2 delete operation is also
available explicitly as delete_agent_tag_v2.
For pagination, list_files, list_evaluation_runs, and
list_managed_agent_evaluations take cursor instead of page_token;
list_session_events takes cursor instead of after_event_id;
list_integration_repositories and list_integration_pull_requests take
cursor and limit instead of page; and list_files also takes
file_id_any instead of file_ids. The explicit
*_v2 names remain available. Deprecated v1 operations and their explicit
*_v1 methods are excluded from this SDK. Releases after 0.1.2 require callers
upgrading from 0.1.x to use v2 request models, pagination arguments, and response
shapes. Skill and skill-group methods also use v2, including camelCase request
and response models. Other Managed Agents methods use the version declared by
the public contract.
Agent modelConfig (model_config in v1) no longer has imagesInView: the
platform chooses how many images the model sees at once. Once the server
change deploys, agent create and version requests that still set it get
400 invalid_request, from 0.1.1 and 0.1.2 too, so remove the key.
Methods return ApiResponse with typed data and the original HTTPX
response, including status and headers. A declared bodyless 304 has
data=None. Declared API errors raise RecursionAPIError; malformed or
undeclared responses raise RecursionContractError. HTTPX transport failures
retain their HTTPX exception types. Request and response values are validated
against the canonical schemas, including constraints beyond Pydantic's model
annotations.
JSON methods accept generated models from recursion_sdk.models, with
snake_case attributes and canonical JSON field aliases. Omitted model
fields stay omitted; explicitly supplied None becomes JSON null where the
contract permits it. Multipart methods accept Upload values, and binary
download methods return bytes. The client has no automatic retries or
pagination; callers retain control of mutation replay and iteration.
Refresh active outcomes during an upgrade
The single-session and bulk upgrade methods accept
replaceActiveOutcome: true in their JSON body. It reapplies the target
version's default rubric to an active outcome, including a caller-defined
outcome or a session already running that version:
import os
from uuid import UUID
from recursion_sdk import Recursion, models
with Recursion(api_key=os.environ["RECURSION_API_KEY"]) as recursion:
recursion.managed_agents.replace_session_agent_version(
session_id=UUID("e3a91f5c-7d24-4b68-9c10-2f8e6b4d7a53"),
body=models.ReplaceSessionAgentVersionRequest.model_validate({
"agentVersionId": "5a0c8e37-1f94-4b2d-a6c3-7e9d2b4f8a15",
"replaceActiveOutcome": True,
}),
)
recursion.managed_agents.start_agent_session_upgrade(
agent_id=UUID("7b1e4c2a-9d35-4f86-a0c7-5e2d8b3f6a14"),
idempotency_key="refresh-active-outcomes-1",
body=models.StartAgentSessionUpgradeRequest.model_validate({
"replaceActiveOutcome": True,
}),
)
While a bulk upgrade is running, a different replaceActiveOutcome policy
returns 409 conflict; the running upgrade keeps the policy it accepted.
AsyncRecursion exposes the same calls with await. The bulk body is optional;
leave it out for the usual version-only request. Without the option, inherited
default outcomes follow the version and caller-defined outcomes stay.
Explicit replacement requires a nonempty default rubric, preserves the
objective and pass limit, and retains the prior outcome and grading history as
interrupted. An evaluation in progress finishes before replacement; terminal
outcomes stay unchanged. A successful upgrade response acknowledges the
request. Verify the active criteria with managed_agents.list_session_outcomes
after the session's next model operation.
Development
All Python tooling uses uv. Run these commands from the repository root through the worktree's devbox:
./devbox exec -- bun run check recursion:python-sdk
The package's uv wrapper reuses uv on PATH or installs a checksum-verified,
pinned copy under the worktree's .local/ directory on a Linux devbox. Other
hosts can use an existing uv installation. Nothing is installed globally.
The check command generates, checks formatting, runs strict typing and behavioral
tests, verifies deterministic generation, builds wheel/sdist artifacts, and
checks an isolated installation of the wheel with hashed runtime dependencies
from uv.lock. Generated files under
src/recursion_sdk/_generated/ are ignored; change the public contract or
generator inputs and rerun the check. It runs tools/check.py through uv with
the materialized preview contract.
Python dependencies and generated outputs belong to this independent package. Root Bun installation, postinstall, JavaScript code generation, and ordinary application checks do not install or run Python tooling. Dedicated CI runs when this package or the canonical Recursion public contract changes.
Generation and ownership
datamodel-code-generator compiles schemas into Pydantic v2 models. A small
operation emitter produces typed methods and bundles the unmodified canonical
contract. One shared HTTPX transport owns wire behavior and uses JSON Schema
validation at its boundaries. No endpoint or request/response model is
maintained by hand, and generation requires no JVM or hosted service.
Generation binds the exact preview audience served by production: the public
contract source recursion-public-openapi.preview.generated.json without its
x-recursion-stability markers. bun run ci check recursion:python-sdk and release
qualification materialize those bytes and pass their path in
RECURSION_PYTHON_SDK_CONTRACT_PATH; the generator requires it and rejects a
marked source.
Build after generation, then add the wheel to your application's uv project:
uv build --project packages/recursion-python-sdk
uv add --project /absolute/path/to/your-python-project /absolute/path/to/labelbox_recursion_sdk-0.0.0-py3-none-any.whl
Published releases reuse the existing labelbox-recursion-sdk PyPI project.
The source version 0.0.0 identifies local preview builds; the release process
stamps the requested version into release artifacts. The TypeScript SDK release
process is independent.
Release
Releases are proposed on Mondays and announced in
#recursion-info while they wait for approval: publishing runs in the recursion-sdk-pypi
environment, which requires an approval from the recursion team, and the run
refuses to publish if it has none. Approving and yanking a bad release:
client package releases.
The Python release workflow builds and qualifies an explicit version. Its default run only uploads artifacts:
gh workflow run release-python-sdk.yml --ref main -f version=0.1.0
The SDK code comes from the workflow's commit. By default, its API contract does
too. When main contains API changes that have not reached production, set
PYTHON_SDK_CONTRACT_SOURCE_SHA to a deployed commit's full SHA and select its
contract explicitly:
gh workflow run release-python-sdk.yml --ref main -f version=0.1.0 -f contract-source-sha="$PYTHON_SDK_CONTRACT_SOURCE_SHA" -f publish=true
The contract source must be a full commit SHA in the workflow commit's ancestry.
The release extracts that commit's production contract without modifying any
tracked snapshot. Generation, behavioral tests, and strict production
verification all consume those exact bytes. Newer API changes on main can
therefore coexist with a release for the deployed API. The artifact manifest
records the SDK source commit, contract source commit, snapshot path, and hash.
For a local build without publishing, use an ignored artifact directory from a clean checkout:
bun run release python-sdk:prepare --version 0.1.0 --artifact-dir "$PWD/.agent/python-sdk-release"
The local command also accepts --contract-source-sha <full-commit-sha> and
--verify-production true for the same source selection and production check
without uploading anything.
The release command rejects published/older versions, temporarily stamps the package and lockfile, runs the full qualification, and restores the source metadata. The immutable candidate contains the wheel, source distribution, checksums, and its source commit.
Passing -f publish=true to the workflow additionally verifies the source
contract in production and publishes those exact archives with uv publish
through PyPI trusted publishing. Its publisher identity is
repository Labelbox/recursion-platform, workflow release-python-sdk.yml,
environment recursion-sdk-pypi, project labelbox-recursion-sdk. The final job verifies
PyPI's archive hashes before recording python-sdk-v<version> at the source
commit. Publication and Git tagging have separate credentials; release runs
never commit version changes to the branch.
Metadata
Release files for labelbox-recursion-sdk 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| labelbox_recursion_sdk-0.1.3.tar.gz | 665.0 kB | Without provenance | Details for labelbox_recursion_sdk-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| labelbox_recursion_sdk-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for labelbox_recursion_sdk-0.1.3-py3-none-any.whl |
Total release size: 1.3 MB
Release files / labelbox_recursion_sdk-0.1.3.tar.gz
| Download URL | labelbox_recursion_sdk-0.1.3.tar.gz |
|---|---|
| Size | 665.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e90b58d520bc1215e06e995b0658770a9d3bb735b622a9947425819f1c7363b4
|
|
BLAKE2b-256 checksum How to use checksums |
3e5e654eb93e8c8f0a5e16889eb82c5108eaa515d2a44fa3a61e9f952d762c31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / labelbox_recursion_sdk-0.1.3-py3-none-any.whl
| Download URL | labelbox_recursion_sdk-0.1.3-py3-none-any.whl |
|---|---|
| Size | 641.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5aae7451ed0c2297592203258434b51a956aabce1a8fbcef3d499384b2ca09a8
|
|
BLAKE2b-256 checksum How to use checksums |
7551a8951324e4ca4d4eda064245c6216531a894e8942c5858593069e696f621
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.14 {"installer":{"name":"uv","version":"0.12.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for labelbox-recursion-sdk 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.