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.
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 purra_interaction-0.5.0.tar.gz.
File metadata
- Download URL: purra_interaction-0.5.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4db3f99be8a372cc00dd3218b7a2fcd34f176bf1056536da5b045c3260dbbe68
|
|
| MD5 |
4f2c78b89995ebb26068dbcd7564a477
|
|
| BLAKE2b-256 |
12eec582a3e52c1f1d34023eed660314ca13b617140c3f3246aae88af8f39d3b
|
Provenance
The following attestation bundles were made for purra_interaction-0.5.0.tar.gz:
Publisher:
release.yml on Lybrands/purra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
purra_interaction-0.5.0.tar.gz -
Subject digest:
4db3f99be8a372cc00dd3218b7a2fcd34f176bf1056536da5b045c3260dbbe68 - Sigstore transparency entry: 2728671747
- Sigstore integration time:
-
Permalink:
Lybrands/purra@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Lybrands
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file purra_interaction-0.5.0-py3-none-any.whl.
File metadata
- Download URL: purra_interaction-0.5.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03f3617191163fa00f9440c5c15b83bd26dd4b5c0817fcec135cb838f09c8621
|
|
| MD5 |
380b0248e7f76d4b5556cfb1fb756972
|
|
| BLAKE2b-256 |
a9656d855991d6d3494559420a1a9df5eab12a9b9272374fd1835037ee5208ec
|
Provenance
The following attestation bundles were made for purra_interaction-0.5.0-py3-none-any.whl:
Publisher:
release.yml on Lybrands/purra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
purra_interaction-0.5.0-py3-none-any.whl -
Subject digest:
03f3617191163fa00f9440c5c15b83bd26dd4b5c0817fcec135cb838f09c8621 - Sigstore transparency entry: 2728672798
- Sigstore integration time:
-
Permalink:
Lybrands/purra@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Lybrands
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd1a2fd6206999edf98a1a5b2047cca47517a64a -
Trigger Event:
workflow_dispatch
-
Statement type: