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-wheel-smoke
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.4.0.tar.gz (978.1 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.4.0-cp313-cp313-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.13Windows x86-64

starweaver-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

starweaver-0.4.0-cp313-cp313-macosx_11_0_arm64.whl (12.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

starweaver-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl (13.0 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

starweaver-0.4.0-cp312-cp312-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.12Windows x86-64

starweaver-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

starweaver-0.4.0-cp312-cp312-macosx_11_0_arm64.whl (12.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

starweaver-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl (13.0 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

starweaver-0.4.0-cp311-cp311-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.11Windows x86-64

starweaver-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

starweaver-0.4.0-cp311-cp311-macosx_11_0_arm64.whl (12.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

starweaver-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl (13.0 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: starweaver-0.4.0.tar.gz
  • Upload date:
  • Size: 978.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0.tar.gz
Algorithm Hash digest
SHA256 abb9e684a803c3870db277e12ec12d3c26a08308a05686e1967f4ad689f62851
MD5 2bca1314135109019eaf8999eb2a1b4a
BLAKE2b-256 4398f667b972195c93cb103547ab16d36122ff8a98ae67e574bf5309ea8e439e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 12.5 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 752aade925d1a727d84d3126191ac818352bb69ed313d5256e5845d44d48750c
MD5 08b413b1ffdb9d899b24a336a23b52f4
BLAKE2b-256 d29d5822b3f0e9816403698b80106dafc495a9922196169ec9f7115ebbb90425

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 13.6 MB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 08ee46e6c48884b749a18f498ef4f126b1ba04dd19ea2e43189476c5463056ff
MD5 588c94a746ef6dbd5ae5a524d8de853b
BLAKE2b-256 ec2cfd85ccb1291b42f2b5274023ab9e7dd018823a73ba5cf3915fb3303a1982

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 12.5 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d032b8f1432e257204df2b20671d2426fca894964f6deb2c340960e4254066ab
MD5 d7a2f1e5f58d3624999c5c155e324802
BLAKE2b-256 6bc6305b88184322c8d9519b6ddff34d25c29b81b8c2b16e3e5c708de462c4aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 13.0 MB
  • Tags: CPython 3.13, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d5e76e48147c7073e46a8ea2f6b88627b07ea78d2d7cf8b0aeef596c75ef3269
MD5 1e5bf8f76b58425a2c9787a4fb8b0414
BLAKE2b-256 b6888fac4765fa6484c4e7e0c0bc9b67d2843cd901f230beba0220bb3bddc0c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.5 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 431ccfad104b2b32cd7fa19a490565327b86cdd16664040a961837901f834cf1
MD5 a3e63738e87d1e5fda5f7a4d2f21285f
BLAKE2b-256 899167b0582106f88e60e89d65e8cdc4977eaee45939aa9250b2f77d3e58d7e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 13.6 MB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 29835358065e322bd84743c46f06727ecefd33671910d4ac9a5f2f2fd91d89de
MD5 afa3dd103ff28e3d4e844310d2534edc
BLAKE2b-256 07c64e5e871b66cea87940048386f5474a8f57e9b4ecba29a261213c369a033b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 12.5 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 89e667502b825c963ec8fa55a66d67c6b6e647053c537316f628af14e8205aca
MD5 46964f1af1d58c93334f734d3d2413bb
BLAKE2b-256 402b84454db169541d30694bb4331c5109846c3958f81c55714603a7fae6c223

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 13.0 MB
  • Tags: CPython 3.12, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cccd186d86295c7e64fb5dd5a7db1a21926d40f448eccfcd91ba84041532730f
MD5 a15e7d1639bd54d4f7d5c6348dfbe0df
BLAKE2b-256 bc39a21eb205c298903b7a1b49427d7b06a9a015467bbbef0530d55c70205261

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.5 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9b31da9b5b9a2fd1f506c7a7fb94da5aa3c58ddd45b3bc3758ec77004d701e2a
MD5 7b80fd3949056945d34a606a64a6510b
BLAKE2b-256 58f2467b4cac19f458adc2d9dd93cd7ee646f55bb6c08e0e233287fb4515bb84

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 13.6 MB
  • Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ec1b8fc55a0f21951a2997508ab04192dfe71e4b3610c7d038173f9c5143cd1
MD5 faa009d77649b7c54b87ac855d656aff
BLAKE2b-256 b4a286d8168903ee629d78c68d7673a042d61494cbad9660139e9516f8491c7f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 12.5 MB
  • Tags: CPython 3.11, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e2fb7f5122c87a03468459f10cad51464cf2d7d239dc24d734dd98eaf0b747d5
MD5 d432d9b8162db52360baf6893e22232b
BLAKE2b-256 ad9831ecd3eb8d12b62545845808c64cf2dee55fbc3c23d4d76a32e6f168c019

See more details on using hashes here.

File details

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

File metadata

  • Download URL: starweaver-0.4.0-cp311-cp311-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 13.0 MB
  • Tags: CPython 3.11, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","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.4.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 17ad1c5141fa51d758790a8b20927df9300d43ce8f5c7cbaef88ab3a9ddc0c6c
MD5 da946dfc1830b1764a61a6c6969bfed6
BLAKE2b-256 092f3d891d71cd42ad9fe06ab71ba21ca2f0fc0b1e250fe4ae628c30457df2db

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