Perceptic Workflow SDK
Python SDK for Perceptic Workflow definitions. This package provides cross-language Temporal workflow types that are compatible with the Java workflow definitions in perceptic-core-client.
Installation
uv add perceptic-workflow-sdk
Usage
Runtime Input Contract
Workflows started through Perceptic Core receive plain JSON input data.
- The first
@workflow.runargument should be a JSON-compatible structure (dict[str, Any]by default). - Perceptic Core does not wrap inputs in an SDK envelope type.
- Consumers are responsible for interpreting and validating the JSON shape they expect.
Workflow Events
from perceptic_workflow import (
WorkflowEvent,
InfoEvent,
CheckpointEvent,
UserInputEvent,
UserInputRequestEvent,
WorkflowCheckpointStatus,
)
# Create events
info_event = InfoEvent(
event_id=1,
type="progress",
payload={"step": "processing"},
timestamp=datetime.now()
)
Implementing Workflows
The SDK provides a mixin class for implementing Perceptic-compatible workflows:
from typing import Any
from pydantic import BaseModel
from temporalio import workflow
from perceptic_workflow import PercepticWorkflow, WorkflowEvent
class ResearchInput(BaseModel):
query: str
context: str
@workflow.defn
class MyWorkflow(PercepticWorkflow):
def __init__(self):
self._events: list[WorkflowEvent] = []
self._paused = False
@workflow.run
async def run(self, inputs: dict[str, Any]) -> dict:
request = ResearchInput.model_validate(inputs)
return {
"query": request.query,
"context": request.context,
}
@workflow.query(name=PercepticWorkflow.QUERY_GET_STATUS)
def get_status(self) -> WorkflowStatus:
return WorkflowStatus(status="running", description="Waiting for input" if self._paused else "Running")
@workflow.query(name=PercepticWorkflow.QUERY_GET_EVENTS)
def get_events(self, after_event_id: int | None = None) -> dict[str, Any]:
if after_event_id is None:
return {"events": self._events}
return {"events": [e for e in self._events if e["eventId"] > after_event_id]}
Decorator Validation
PercepticWorkflow no longer performs runtime validation of Temporal handler
decorators during class creation. This avoids import-time failures for abstract
workflow bases and mixin-based inheritance patterns.
Handler contract enforcement is expected to happen through linting and type-check tooling in your development pipeline:
uv run ty check
uv run workflow-typecheck
workflow-typecheck implementation notes
workflow-typecheck is implemented by
src/perceptic_workflow/_checks/workflow_decorator_check.py and performs a static
AST scan of Python classes that inherit from PercepticWorkflow (or from a
class that already does). For the known handler methods, it enforces:
- the method has a Temporal handler decorator (
@workflow.queryor@workflow.update) - the decorator kind matches the expected contract
- the
name=argument matches thePercepticWorkflowhandler constant
Current diagnostics:
PWF001: expected Temporal decorator is missingPWF002: wrong decorator kind (queryvsupdate)PWF003: wrong or missing handlername=...
How to extend the check:
- Add or update required handlers in
REQUIRED_HANDLERSwhen a new Perceptic handler method is added or an existing one changes. - Add base class names to
MIXIN_COMPATIBLE_BASESif additional workflow base classes should be recognized as Perceptic-compatible roots. - Extend
_extract_name_kwarg/_is_workflow_decorator_callif we support additional decorator call shapes or name expressions.
When this check must be updated:
- A
PercepticWorkflowhandler method is renamed, added, removed, or changes from query to update (or vice versa). - Any
PercepticWorkflow.<HANDLER_CONSTANT>used in handler decorators is renamed or replaced. - We introduce a new inheritance pattern for workflow mixins or a new canonical workflow base class.
- We change how Temporal decorators are authored (for example, different
decorator access paths or non-current
name=expression style).
How to edit safely:
- Update the contract mappings first (
REQUIRED_HANDLERS,MIXIN_COMPATIBLE_BASES). - Keep diagnostics specific and actionable (
PWF001-PWF003style). - Add or update tests in
tests/test_workflow_typecheck_regression.pyfor the new/changed behavior. - Validate with:
uv run workflow-typecheckuv run pytest tests/test_workflow_typecheck_regression.pyuv run ty check
Troubleshooting
ValidationErrorduring workflow activation usually means your@workflow.runsignature expects the wrong input shape.- Use a JSON-compatible first workflow argument (for example
dict[str, Any]), then validate/coerce into your domain model insiderun. - For run-start requests, send
inputsonly; Perceptic Core forwards that JSON payload directly.
Compatibility
This package is designed to be compatible with:
- perceptic-core-client (Java)
- perceptic-core-workflow-runtime (Java)
The workflow definitions and event types are generated from the same JSON Schema sources to ensure cross-language compatibility.
Metadata
Release files for perceptic-workflow-sdk 0.54.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| perceptic_workflow_sdk-0.54.0.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| perceptic_workflow_sdk-0.54.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / perceptic_workflow_sdk-0.54.0.tar.gz
| Download URL | perceptic_workflow_sdk-0.54.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58cf35f79228e84fcc6db6fff644e977ccb7e158a88d5980fb5f89883f1b436d
|
|
BLAKE2b-256 checksum How to use checksums |
ed723121011cddaa9072b70df96391222cc7f69e5e4c3b0db3f398a196f8d693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 25, 2026.
Transparency logRelease files / perceptic_workflow_sdk-0.54.0-py3-none-any.whl
| Download URL | perceptic_workflow_sdk-0.54.0-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
806c921b1c1331290778ea759ef4c7831108dca083cf9fa24a6dee8d16bbf506
|
|
BLAKE2b-256 checksum How to use checksums |
cb46b1ffe67305bf7f6c02d4da50ea23e00dc62a484c2f0be35a64575b3854d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 25, 2026.
Transparency log