Durable background jobs for AI agents
Project description
Papayya
Durable background jobs for AI agents. Bring your own LLM — Papayya handles execution, checkpointing, budgets, and deployment.
Install
pip install papayya
Quick Start
Define an agent
from papayya import agent, tool
@tool
def search_web(query: str) -> str:
"""Search the web for information."""
# Your implementation here
return results
@agent(name="research-bot", model="gpt-4o-mini", budget_usd=1.0)
def research_bot(input_data):
from openai import OpenAI
client = OpenAI()
# Your agent logic — call your LLM directly
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": input_data}],
)
return response.choices[0].message.content
Durable execution
Wrap long-running work in checkpoint-able tasks. If a run crashes, it resumes from the last checkpoint instead of re-executing completed steps.
from papayya import papayya
run = papayya(agent="my-agent", budget_usd=2.0)
search = run.task("search", search_web)
summarize = run.task("summarize", summarize_results)
results = search(query) # cached on replay
summary = summarize(results) # cached on replay
run.complete(summary)
Budget enforcement
Set per-run spending limits by USD or token count. The run pauses when a budget is exceeded.
run = papayya(
agent="my-agent",
budget_usd=5.0,
budget_input_tokens=100_000,
budget_output_tokens=10_000,
)
# After each LLM call, record the cost:
run.record_cost(cost_usd=0.03, input_tokens=1500, output_tokens=200)
Deploy
papayya login
papayya deploy
Key Concepts
- BYOF (Bring Your Own Function) — Papayya doesn't wrap your LLM calls. You use any SDK (OpenAI, Anthropic, Bedrock, etc.) directly inside your agent function.
@agentdecorator — Registers your function for deployment. The function stays callable locally.@tooldecorator — Defines tools your agent can call, with automatic JSON Schema generation from type hints.- Durable runs — Checkpoint-and-replay execution. Tasks are cached so replayed runs skip completed work.
- Budgets — USD and token-based limits that pause runs before overspending.
Requirements
- Python 3.10+
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file papayya-0.1.0.tar.gz.
File metadata
- Download URL: papayya-0.1.0.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80f1227458e5b28660ebf33bd728237574616d95abf96726a5a0544f9649b62c
|
|
| MD5 |
a38bf744acc5cc2261a7834c85606b1c
|
|
| BLAKE2b-256 |
d916cdd1eb6928c6771c133eab0cd9e9c1abf2bc44aa9d68ecc8c6196eb1fd4f
|
File details
Details for the file papayya-0.1.0-py3-none-any.whl.
File metadata
- Download URL: papayya-0.1.0-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
535525ce3e481e362b62bfafc4ce8ae902f7ce7d204892201a41a4ef3fee593e
|
|
| MD5 |
7a77356657b84a4b61d8c3d6db047daa
|
|
| BLAKE2b-256 |
e4a784f477db7336b6cf93caaf4ce552fea6bc5568f5ab44c7d59e4a12ead840
|