Skip to main content

The Human-in-the-Loop SDK for AI Agents

Project description

LetsPing Python SDK

PyPI version License: MIT Python Versions

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

letsping-0.1.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

letsping-0.1.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file letsping-0.1.2.tar.gz.

File metadata

  • Download URL: letsping-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for letsping-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b8aa6e2f9ac33d77ca914ae36735df68f6580dcb9d6a21cba0ee893c606affc3
MD5 c8128473c2fcb96cca2e751f4f39c0df
BLAKE2b-256 f6bb9dba7b820a250ad766f525a24349d5c3ed3dd2e12d2bf81bb8e5b5ea6dbc

See more details on using hashes here.

File details

Details for the file letsping-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: letsping-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for letsping-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d8bb7cc42083352a375108dda1587523b0f342abef5669da6a93a726f5b2b987
MD5 55eed58c56a94df241d06db5b8419140
BLAKE2b-256 a7198b4cff96ac931bb075fa562e446f23d2e9f4e857aa20e4e30b9e17bd4a47

See more details on using hashes here.

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