Skip to main content

Python bindings for Starweaver

Project description

Starweaver Python

starweaver is the in-process Python SDK and binding package for Starweaver. It keeps the Rust runtime as the canonical agent loop while exposing Python ergonomics for agents, tools, models, sessions, streams, resources, media, and deterministic tests.

Python tools are injected directly as native Starweaver runtime tools. They do not use MCP, stdio, or another binary protocol.

Supported Python versions are CPython 3.11 through 3.13. Local development and single-version CI jobs default to Python 3.13.

Quickstart

import asyncio

from starweaver import create_agent, tool
from starweaver.testing import TestModel


@tool
async def add(left: int, right: int) -> dict[str, int]:
    return {"total": left + right}


async def main() -> None:
    model = TestModel.responses(
        [
            TestModel.tool_call_response(
                [{"id": "call_add", "name": "add", "arguments": {"left": 2, "right": 3}}]
            ),
            {"text": "done"},
        ]
    )
    result = await create_agent(model=model, tools=[add]).run("Add two numbers")
    print(result.output)


asyncio.run(main())

Core Surfaces

  • create_agent() builds a Python facade over the Rust runtime.
  • @tool, raw callables, and BaseTool register in-process tools.
  • Independent tool calls run in parallel by default; use sequential=True for ordered side effects.
  • Toolset, ToolSearchToolset, and ToolProxyToolset compose grouped tools.
  • ProviderModel, TestModel, and FunctionModel cover production providers, deterministic scripts, and callback-backed tests.
  • OutputSchema, OutputPolicy, validators, and output functions handle final output.
  • AgentSession and SessionArchive preserve reusable session state.
  • EnvironmentProvider, ResourceRef, SkillRegistry, and MediaUploader expose environment, resource, skill, and media boundaries.

Stream Boundary

run_stream() currently returns AgentRun, an async iterator over canonical StreamEvent records plus a Python facade for recv(), join(), result(), status(), recoverable_state(), interrupt(), active messages, steering, and streamed HITL helpers. The stable portable contract is the canonical StreamEvent.raw record sequence and collected run result. Python live-control ergonomics are the current facade, not a separately frozen live-handle protocol.

AgentStream remains a compatibility alias for AgentRun.

Documentation

Start with docs/python-sdk.md in the repository. The Python docs are organized by feature:

  • docs/python/agents.md
  • docs/python/tools.md
  • docs/python/toolsets.md
  • docs/python/models.md
  • docs/python/output.md
  • docs/python/sessions-streams.md
  • docs/python/environments-skills.md
  • docs/python/media.md
  • docs/python/testing.md
  • docs/python/examples.md
  • docs/python/stability.md

Runnable examples live in examples/python/.

Validation

From the repository root:

make py-sync
make py-lint
make py-rust-check
make py-test
make py-check

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

starweaver-0.3.0.tar.gz (845.7 kB view details)

Uploaded Source

Built Distributions

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

starweaver-0.3.0-cp313-cp313-win_amd64.whl (8.9 MB view details)

Uploaded CPython 3.13Windows x86-64

starweaver-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

starweaver-0.3.0-cp313-cp313-macosx_11_0_arm64.whl (8.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

starweaver-0.3.0-cp313-cp313-macosx_10_12_x86_64.whl (9.3 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

starweaver-0.3.0-cp312-cp312-win_amd64.whl (8.9 MB view details)

Uploaded CPython 3.12Windows x86-64

starweaver-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

starweaver-0.3.0-cp312-cp312-macosx_11_0_arm64.whl (9.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

starweaver-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl (9.3 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

starweaver-0.3.0-cp311-cp311-win_amd64.whl (8.9 MB view details)

Uploaded CPython 3.11Windows x86-64

starweaver-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

starweaver-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (9.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

starweaver-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl (9.2 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

Details for the file starweaver-0.3.0.tar.gz.

File metadata

  • Download URL: starweaver-0.3.0.tar.gz
  • Upload date:
  • Size: 845.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0.tar.gz
Algorithm Hash digest
SHA256 18633d677269b3cda7accd0db2cf3c24dd72de200ca033760937f1e05a3ed7f0
MD5 a998fca8f349d1c33088559be20049bf
BLAKE2b-256 c0c67737203a8045ca418aaf334843dc25c9caeb5589d3c3c40ba73606e09de3

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 8.9 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 bc1b7d649d2280f0facb5df51311eb1d6acb1ff57f2e2f758058e0c5886a235a
MD5 20be27909854b6baa80ae7bf259f3493
BLAKE2b-256 60d40da7d892eb7d538d7f99c6024304dcb735731f0f14f0264863073ae0e3ec

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.9 MB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c4207b499a3af99c79dfa3936b2d217488621ef595d97be5bb0168331c9ea019
MD5 9614fcd5cbf902072d449ffad303be5d
BLAKE2b-256 9afb2fd761189c7ff525d95f6181fb15369cb421875482d9739ec90c5744345b

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 8.9 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f944a7a27b8c4fe48dcb107dd884fc86660fd22cbce17cf27ad6eac6e4f6c1a7
MD5 68ec2f4c4cc7b7ae7349339495c4b685
BLAKE2b-256 12c63fbeb45bbd4c3e250c2a6970153efc38f50c608bfa243e08ecc78b679fe7

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp313-cp313-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 9.3 MB
  • Tags: CPython 3.13, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b6e8b57a9dc09d8d20f1362bdd6553ba85bfa4a0568345052e42645c83eca2fe
MD5 6be97607067888b8d6cfe5761dcc5f88
BLAKE2b-256 5426c7d49aa61ca372deeb9db869a7207cdbb3887ec3d08c6f326a12868bbedf

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 8.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8d8d814d122e195258b6f0b94162fb4b5fb472795568843112679b99c366abb7
MD5 e8a34ea3416cfdca0d63f406a5f8bc1a
BLAKE2b-256 e6016563561d5e3b0325ce66280e74c35904310e3bdd746108d447bd7563a779

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.9 MB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b541c19c45eca379832e1c2019cdac0a3451c7f3bfcb3c4bc658081109e4ade4
MD5 55498b3d6ac07e9689ab5b6e425c01e6
BLAKE2b-256 e1f258d14b139d1e2e993f4b553c333ceac7a2e7b92be7ffc26b11467adce614

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c151a61a39de38f71c49a436766fc4fde6936f763584d1f6a6f2cbabaaa6aa37
MD5 48ae2d3802c2becf3e246f4aab96827f
BLAKE2b-256 6d2e35c0e6bd45f95c4529f8199248d857b40f697fafcf6532d3fdeab4daba14

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 9.3 MB
  • Tags: CPython 3.12, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 64fdafeeff90d9ff9eb77fbe12b36aebdce3f0e5933d1ad7bec9608b99a9aa9c
MD5 85efcb008349f5cd88dde12e104cede7
BLAKE2b-256 81c56fd097e38b8ad732128fc88b5875eeb5f6efc7d9fd1bd3258cc94214ff4c

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 8.9 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8058ff9907f9bbeba3bbbfd74df7db34e14b520301df6bc9890e12e9fc0b1a2f
MD5 a06861417f6aaf25c1d76bab2f83e5f6
BLAKE2b-256 0acbaa5ff13ca9df3af9c11d154a30595b2070c46a9004bd808deb6863a987c6

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 9.9 MB
  • Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fa48d475912620356c08ede36410b3cffb62682faffaf225b939d96088c3fb90
MD5 34c064e13672be273aeb72098fd1b78d
BLAKE2b-256 8148ed1b924abe58659070e5ba2275f155e23372062331a366c9f88b628021ba

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.11, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bc4d558bf538448194390f770fe477f79d0ede8da9d4d8553b0de844f11e1e42
MD5 395d218b8bfb5673ba0bd9eccce07ffc
BLAKE2b-256 f8cdf6bdb5c14f7551dc6438695f6eee57529faccabbbaaf9d8abdfdac754983

See more details on using hashes here.

File details

Details for the file starweaver-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: starweaver-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 9.2 MB
  • Tags: CPython 3.11, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for starweaver-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cf0c4f46a23679780f1c09d9e604c7092f0e43edfafa63403f10ea4cfb365046
MD5 9c7ce649bf500a3055dae760f9056910
BLAKE2b-256 b6b5ea380736a384f1d55d8874a90609a4552adbfd5af650f5778b7de932bc52

See more details on using hashes here.

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