gpt-workflow for Python
gpt-workflow is a synchronous, typed Python wrapper around the deterministic
gpt-workflow CLI. It blocks
until each command finishes, captures the CLI's NDJSON and diagnostics, and
does not print or retry work automatically.
Prerequisites
- Python 3.12 or newer
- Bun 1.3 or newer
- an authenticated Codex CLI for workflows that call agents
The Python and npm distributions are synchronized at 0.3.4. This release
always executes bunx --bun gpt-workflow@0.3.4; it never resolves @latest or
a separately installed gpt-workflow executable.
Install the Python package after it is published:
python -m pip install gpt-workflow==0.3.4
Run and inspect workflows
Set gpt_workflow.cwd once to the repository that owns the workflow. It must
be a pathlib.Path; relative script paths and durable run storage are resolved
from it.
from pathlib import Path
import gpt_workflow
gpt_workflow.cwd = Path("/absolute/path/to/repository")
execution = gpt_workflow.run(
".codex/workflows/summarize.js",
{"topic": "deterministic orchestration"},
default_model="your-codex-model",
)
print(execution.result)
print(execution.status.run_id)
print(execution.run_directory)
for summary in gpt_workflow.runs():
print(summary.run_id, summary.status)
status = gpt_workflow.status(execution.status.run_id)
available_models = gpt_workflow.models()
Omitting the second argument leaves workflow args undefined. Passing None
sends explicit JSON null. WorkflowResult contains the JSON result, detailed
WorkflowStatus, and durable run directory. runs() returns lightweight
summaries; status() loads detailed phase, agent, token, failure, and fallback
journal state; models() returns unique canonical model names in CLI order.
Unknown compatible JSON fields are retained in each value's extra mapping.
This no-agent workflow is deterministic and spends no model tokens:
export const meta = {
name: "python-smoke",
description: "Python SDK smoke test"
}
return { answer: 42 }
Errors and interruption
Configuration and validation fail before work starts with idiomatic exceptions:
WorkflowDirectoryUnset, FileNotFoundError, TypeError, ValueError,
BunError, or CLIProtocolError. Once a trustworthy run exists, failures use
WorkflowError subclasses whose status and run_directory are always set.
These distinguish invalid workflows and arguments, unavailable models, Codex
App Server failures, budgets and limits, Git failures, JSON boundaries,
cancellation, and unclassified workflow execution.
Ctrl-C before run.started remains an ordinary KeyboardInterrupt. After the
run starts, the wrapper forwards SIGINT, gives the CLI a bounded opportunity to
flush persisted failure state, then raises WorkflowInterrupted. That exception
is also a KeyboardInterrupt and carries status and run_directory.
v1 scope
This release intentionally keeps Bun as a system prerequisite and exposes only
synchronous APIs. CI, PyPI publication, bundled Bun support such as a
gpt-workflow[bun] extra, and async APIs are deferred to later work.
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 gpt_workflow-0.3.4.tar.gz.
File metadata
- Download URL: gpt_workflow-0.3.4.tar.gz
- Upload date:
- Size: 39.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb8539b23396eda75087fc2e2ae0195c8b61e850f78ead916bf22317d7f3a937
|
|
| MD5 |
b7765bc91abf96f6d15320d5cc192f3a
|
|
| BLAKE2b-256 |
120776b573836c1b252a96b7769b5d2bdc11496072f4407d330d13e0af64f034
|
File details
Details for the file gpt_workflow-0.3.4-py3-none-any.whl.
File metadata
- Download URL: gpt_workflow-0.3.4-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
302f820f259f64a99389f226a8d1d4b950f2455af534ec825c7a88b842b0c510
|
|
| MD5 |
2dc8e7e2e571baafcd9dbfcadc848cf7
|
|
| BLAKE2b-256 |
42872c35a532f30d61e1c41e1d3bfa2c1fe58040d2e0f1ba3897ba583ba7beb8
|