Durable background jobs for AI agents
Project description
Papayya
Durable background jobs for AI agents. Bring your own LLM — Papayya handles execution, checkpointing, and deployment. Budget enforcement and cost tracking live on the cloud runtime.
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
budget_usd on the @agent decorator is metadata the cloud runtime uses to cap per-run spend. It is not enforced when you call the function directly on your laptop.
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")
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 (cloud only)
Budget caps and cost tracking are enforced by the runtime shim when your agent runs in a Papayya container. Set a cap on the @agent decorator (shown above) or pass budget_cents when triggering a run via the API. There is no local budget API — local PapayyaRun is durability-only.
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 — Cloud-only. The runtime shim reserves cost before each LLM call and pauses the run when the cap is hit.
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.1.tar.gz.
File metadata
- Download URL: papayya-0.1.1.tar.gz
- Upload date:
- Size: 77.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92f00256a7425aafd4f45e388c413453197ea136e57859905b1381e972c7062d
|
|
| MD5 |
a1afeb96135f8d0b4080c00fd9096a32
|
|
| BLAKE2b-256 |
40c174c8408d20fa61354e3835f41e3c08e9cbde9e538acdc6bf5bf68756d5c6
|
File details
Details for the file papayya-0.1.1-py3-none-any.whl.
File metadata
- Download URL: papayya-0.1.1-py3-none-any.whl
- Upload date:
- Size: 74.6 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 |
7d7e0c231a90cbe278fac2044563cfaf4afbc64f33c91da60ea46db6e044171d
|
|
| MD5 |
0c9500c063a8e36f8c4cd9e412d0120a
|
|
| BLAKE2b-256 |
138048d65868c6986fbbd5a4b31570a6234361c7a74b0f2ce6c622b08d106d3e
|