Python port of js/testapps/flow-sample1.
No model is used; these flows exercise the framework itself — traced steps,
streaming, context propagation, error handling (caught and uncaught), and a
long-running flow you can stare at in Dev UI to confirm spans appear live.
| Flow | What it shows |
|---|---|
basic |
Two ai.run() traced steps |
parent |
One flow calling another |
withInputSchema |
Typed object input via Pydantic |
withContext |
Reading the request context inside a flow |
streamy |
Streaming count chunks at 1s intervals |
streamyThrowy |
Stream a few chunks, then raise mid-stream |
throwy |
Run a step, then raise from the flow body |
throwy2 |
Raise from inside a traced step |
flowMultiStepCaughtError |
Catch an error from a middle step and keep going |
multiSteps |
Several traced steps with reused span names |
largeSteps |
~1MB string outputs per step (stress the trace pipe) |
test-long-broadcast |
Multi-minute flow with nested spans (broadcast test) |
uv sync
uv run src/main.pyThis runs basic, parent, withInputSchema, multiSteps, and
flowMultiStepCaughtError and prints their results. The streaming, throwing,
and long-broadcast flows are skipped here — pick them from Dev UI.
genkit start -- uv run src/main.pyOpen http://localhost:4000 and pick a flow from the sidebar.
- basic —
"hello"→ returnsfoo: subject: hello. Two spans show. - streamy —
5with streaming on → five{count: N}chunks at 1s intervals, thendone: 5, streamed: 5 times. - streamyThrowy —
5with streaming on → three chunks, then aRuntimeError: whoopsthat surfaces in the trace. - throwy / throwy2 —
"hello"→ flow errors out; the failing span is highlighted in Dev UI. - multiSteps —
"world"→ returns42; check that the reusedstep1name appears twice in the trace. - test-long-broadcast —
{"steps": 5, "step_delay_ms": 5000}→ ~25s flow with nested fetch/process/save spans you can watch arrive live.