docs: publish structured runtime context

This commit is contained in:
lda
2026-09-05 00:34:58 +07:00 Verified
parent 71dc5ba8e8
commit c389590a9c
17 changed files with 431 additions and 92 deletions
@@ -175,3 +175,26 @@ for frame in trace.frames:
Catch the specific public errors useful to the application and retain a final
`WorkflowClientError` fallback. Unknown server errors remain inspectable
`ProtocolError` values with `code`, `message`, and `data`.
## Structured foreach context
Prefer declared input bindings via the foreach reference:
```python
orders = graph.foreach(
id="orders",
over=state_path("orders"),
as_="order",
)
charge = graph.use(
charge_order,
input=[input_from(orders.item, "order")],
)
graph.set_route(orders, "loop", charge)
graph.set_route(charge, "ok", orders)
```
Normal capabilities receive foreach values through declared inputs. Advanced
handlers may inspect `ctx.foreach["orders"].index` and stable runtime
identities. Child workflows do not inherit caller context and must receive
input. `loop_item`, `loop_index`, and aliases are migration conveniences.