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:
SwarmTaskSwarmTaskTypeEvaluationStatusEvaluationContextEvaluationResultTaskResultBaseEvaluatorCustomEvaluatorPassthroughEvaluatorSchemaValidator
Notes
SwarmTaskis 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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swarm_task-0.0.3.tar.gz | 13.9 kB | With provenance | Details for swarm_task-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarm_task-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for swarm_task-0.0.3-py3-none-any.whl |
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 logRelease 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 logSecurity for swarm-task 0.0.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for swarm_task-0.0.3.tar.gz
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 logA 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.