Skip to main content

Lightweight task orchestration for iterative AI evaluation loops

Project description

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.

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

swarm_task-0.0.1.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

swarm_task-0.0.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file swarm_task-0.0.1.tar.gz.

File metadata

  • Download URL: swarm_task-0.0.1.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for swarm_task-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8bd8c4897bcab5aeabecfd019e62d96a65f25a0c72a803c38568eadad40f6c38
MD5 61cb92d3fcc404f3b037ea07a151e28b
BLAKE2b-256 0e76d97fa6285d5243384bee372e5c4e9e3fc4da64291cbd1c89dc38652d7ae8

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarm_task-0.0.1.tar.gz:

Publisher: publish-pypi.yml on logarith-ms/swarm-task

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swarm_task-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: swarm_task-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for swarm_task-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 371f34d4022efc86804487e33dd31808555a8fb252f2e7090c69945e164b6cba
MD5 186a0746681f2aa06d6ee36bcd56afde
BLAKE2b-256 be803ebc787c57d9b73ee29143dca44718e3e0d15b7b9808a2a5b2ffb30767a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarm_task-0.0.1-py3-none-any.whl:

Publisher: publish-pypi.yml on logarith-ms/swarm-task

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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