Skip to main content

swarm-task

Lightweight task orchestration for iterative AI evaluation loops.

swarm_task provides a small runtime for running a callable, evaluating the result through one or more evaluators, and retrying until either evaluation succeeds or retry limits are exhausted.

Install

pip install swarm-task

Quick Start

from pydantic import BaseModel

from swarm_task import (
    CustomEvaluator,
    EvaluationContext,
    EvaluationResult,
    EvaluationStatus,
    SchemaValidator,
    SwarmTask,
    SwarmTaskType,
)


class ResultSchema(BaseModel):
    name: str
    values: list[int]


async def custom_check(result: dict[str, object], context: EvaluationContext[dict[str, object]]) -> EvaluationResult:
    if len(result["values"]) < 2:
        return EvaluationResult(
            status=EvaluationStatus.FAILED,
            success=False,
            message="Need at least two values",
        )
    return EvaluationResult(status=EvaluationStatus.SUCCESS, success=True)


async def task_fn() -> dict[str, object]:
    return {"name": "example", "values": [1, 2, 3]}


task = SwarmTask(
    type=SwarmTaskType.EVALUATOR_OPTIMIZER,
    evaluators=[
        SchemaValidator(schema=ResultSchema),
        CustomEvaluator(evaluator_fn=custom_check),
    ],
)

result = await task.run(task_fn)
assert result.success is True

Public API

Top-level exports:

  • SwarmTask
  • SwarmTaskType
  • EvaluationStatus
  • EvaluationContext
  • EvaluationResult
  • TaskResult
  • BaseEvaluator
  • CustomEvaluator
  • PassthroughEvaluator
  • SchemaValidator

Notes

  • SwarmTask is async-first and accepts both sync and async callables.
  • Evaluators manage their own retry counts.
  • The package intentionally ships only the active runtime; archived experimental code is excluded.

Metadata

Release files for swarm-task 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarm-task 0.0.3
File Size Uploaded
swarm_task-0.0.3.tar.gz 13.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swarm-task 0.0.3
File Interpreter ABI Platform
swarm_task-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 28.7 kB

Release files / swarm_task-0.0.3.tar.gz

Download URL swarm_task-0.0.3.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
aed826ec2733e2164ae8c1c16c5ed47e87ad9abdcf9e2074356969b7a6044e85
BLAKE2b-256 checksum
How to use checksums
695789e79bd4360b68538369fb1d0697f42680441877af8685dbbb4eaec62255
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 27, 2026.

Transparency log

Release files / swarm_task-0.0.3-py3-none-any.whl

Download URL swarm_task-0.0.3-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2dfcf51f0f42629fd4a5462c7048058b292c87352c00a5372c86ae7d5242cfb
BLAKE2b-256 checksum
How to use checksums
157dca8514bdddc97c686fdeec19066de084e18309459eab7538428976a7ad5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page