Skip to main content

purra-interaction · Python

English | 简体中文

Persist structured questions, wait for user input, and continue execution. Requires Python 3.11+.

API Use
SqliteClarification Suspend and resume the same Run using purra-sqlite checkpoints
ClarificationStore + ClarificationWorkflow Collect input before execution, then create a Run through an application callback

Install

For same-Run clarification, run from the repository root:

python -m pip install . ./integrations/sqlite/python './integrations/interaction/python[sqlite]'

Configure a Run

Given a model gateway:

from purra.api import AgentCore, AgentPreset
from purra.contracts import RuntimeLimits
from purra.tools import InMemoryToolCatalog
from purra_sqlite import SqliteAgentAdapters
from purra_interaction import SqliteClarification

storage = SqliteAgentAdapters("agent.db", scope="user-1/project-1")
interaction = SqliteClarification(storage)
core = AgentCore(
    model_gateway=gateway,
    preset=AgentPreset(
        id="assistant", revision="1",
        runtime_limits=RuntimeLimits(max_run_generation_tokens=8192),
        tool_catalog=InMemoryToolCatalog((interaction.registration,)),
    ),
    run_repository=storage.runs,
    output_repository=storage.outputs,
    output_publisher=storage.publisher,
    execution_lease_store=storage.leases,
)

Submit an AgentRunRequest with tools_enabled=True through await interaction.submit(core, request). When the Agent asks a question, handle.wait() raises purra.api.UserInputRequired. Use its request_id with await interaction.get(request_id) to obtain the public question data.

The Run remains waiting, with no worker or model call kept alive. After the user answers, provide the question revision, a stable command key, and answers keyed by question ID:

async def answer_and_resume(request_id, revision, answer_key, answers):
    ready = await interaction.answer(
        request_id, revision=revision, key=answer_key, answers=answers,
    )
    return await interaction.resume(core, ready["id"])

The returned handle continues the same Run with its spent budget and deadline. It may request input again. Answers provide task data and do not grant tool permissions.

Reload and cancel

Recreate the same storage, Agent preset, gateway, and interaction objects after restart. list_pending() includes waiting and answered requests; resume those in ready state. Use cancel(request_id) while waiting, or the Run handle after execution resumes.

For Agent trees, bind the same Run-tree repository and answer all pending questions under a Root before resuming. Auto, Reactive, and Planned execution are supported. Pauses occur at completed tool-round boundaries. Uncertain external writes require reconciliation. Close Core before closing storage.

Pre-execution input

ClarificationStore.ask(...) saves questions and an application checkpoint. Expose store.public(saved) to the UI, then call store.answer(...). ClarificationWorkflow.resume(..., submit=callback) invokes callback(snapshot, continuation_key) to create a new Run and return its ID.

Persist the continuation key on that Run. If submission is interrupted, reconcile against the existing Run before retrying. The application restores credentials, permissions, and remaining task budgets. Close the store on shutdown.

Metadata

Release files for purra-interaction 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for purra-interaction 1.0.0
File Size Uploaded Provenance Actions
purra_interaction-1.0.0.tar.gz 15.5 kB With provenance Details for purra_interaction-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for purra-interaction 1.0.0
File Interpreter ABI Platform Actions
purra_interaction-1.0.0-py3-none-any.whl Python 3 none any Details for purra_interaction-1.0.0-py3-none-any.whl

Total release size: 25.2 kB

Release files / purra_interaction-1.0.0.tar.gz

Download URL purra_interaction-1.0.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
62eba444ce4dccafe765f46c00287e0c9410e154ff7a6ef4c119a346a5de423d
BLAKE2b-256 checksum
How to use checksums
b8a30e920053283bcf733fe5f9412058156046bed3bf94bb4c6c0717b6227811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release files / purra_interaction-1.0.0-py3-none-any.whl

Download URL purra_interaction-1.0.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2749f75af24f102bad7c086e75d2108bac15618e0473813ea454b4be09d9eaed
BLAKE2b-256 checksum
How to use checksums
11f12b16a141e53b8040f42dace26f5d162d3f33e1faa6624944dfc621ce2bb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Security for purra-interaction 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for purra_interaction-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page