The Human-in-the-Loop SDK for AI Agents
Project description
LetsPing Python SDK
The official state management infrastructure for Human-in-the-Loop (HITL) AI agents. LetsPing provides a durable "pause button" for autonomous agents, decoupling the agent's execution logic from the human's response time. It handles state serialization, secure polling, and notification routing (Slack, Email) automatically.
Installation
pip install letsping
Configuration
Set your API key as an environment variable (recommended) or pass it directly.
export LETSPING_API_KEY="lp_live_..."
Usage
1. The "Ask" Primitive (Blocking)
Use this when you want to pause a script until a human approves.
from letsping import LetsPing
client = LetsPing()
# Pauses here for up to 24 hours (default)
decision = client.ask(
service="payments-agent",
action="transfer_funds",
payload={
"amount": 5000,
"currency": "USD",
"recipient": "acct_99"
},
priority="critical"
)
# Execution resumes only after approval
print(f"Transfer approved by {decision['metadata']['actor_id']}")
2. Async / Non-Blocking (FastAPI/LangGraph)
For high-concurrency environments or event loops.
import asyncio
from letsping import LetsPing
async def main():
client = LetsPing()
# Non-blocking wait
decision = await client.aask(
service="github-agent",
action="merge_pr",
payload={"pr_id": 42},
timeout=3600 # 1 hour timeout
)
asyncio.run(main())
3. LangChain / Agent Integration
LetsPing provides a compliant tool interface that can be injected directly into LLM agent toolkits (LangChain, CrewAI, etc). This allows the LLM to decide when to ask for help.
from letsping import LetsPing
client = LetsPing()
tools = [
# ... your other tools (search, calculator) ...
# Inject the human as a tool
client.tool(
service="research-agent",
action="review_draft",
priority="high"
)
]
Error Handling
The SDK uses typed exceptions for control flow.
ApprovalRejectedError: Raised when the human explicitly clicks "Reject".TimeoutError: Raised when the duration (default 24h) expires without a decision.LetsPingError: Base class for API or network failures.
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 letsping-0.1.3.tar.gz.
File metadata
- Download URL: letsping-0.1.3.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a37ed6014dc40ee8153bfbfbafa44b42138b22b7bfa55321daf9c7de692c949a
|
|
| MD5 |
054fd579e3ab08863c40037bb949df04
|
|
| BLAKE2b-256 |
5e86013a09ccb5c7f66346fb3adb4991a7bb485c045a44e7ec0e7cce35055fe3
|
File details
Details for the file letsping-0.1.3-py3-none-any.whl.
File metadata
- Download URL: letsping-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a48af1147dacffd0cad07e85508be531996b17c2c1d70f8d9fb048fb97320aa
|
|
| MD5 |
37ee4c9098f58464b9eb10a584a7ee08
|
|
| BLAKE2b-256 |
11a27ee0b7f9643df3b06b879af7b16a9ce147c2f1baa6f80a44a7f619423a9d
|