Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

docs(hooks): run_id is shared by the predict events, not by on_route/on_load/on_evict

Adeshina Lasisi0463ae15f0f9
diff --git a/docs/hooks/api.md b/docs/hooks/api.md
index 2b4efd3b..21058bb5 100644
--- a/docs/hooks/api.md
+++ b/docs/hooks/api.md
@@ -48,7 +48,7 @@ class PredictContext:
|---|---|---|---|---|
| `states` | `list` | always | yes (start) | the states for this call. `system_one`/`Router.predict` pass one; `Agent.predict_batch` passes many; `Router.predict_batch` passes one per request. A start hook may replace the list. |
| `questions` | `dict` | always | yes (start) | the questions. A start hook may replace the dict. |
-| `run_id` | `str` | always | no | a unique id shared by every hook of this call. Use it to correlate events and spans. |
+| `run_id` | `str` | always | no | a unique id shared by the predict events of this call (`on_predict_start`, `on_predict_end`, `on_error`). `on_route`, `on_load` and `on_evict` are dispatched with contexts of their own, so their `run_id` differs even within one `Router.predict`. Use it to correlate events and spans. |
| `results` | `list \| None` | end (and on a skip) | yes (end) | per-state result dicts, each shaped like `system_one`'s return. `None` until inference finishes. |
| `decision` | `dict \| None` | Router only | yes (route) | the `RouteDecision` (a `dict`) that selected the checkpoint. |
| `model` | `str \| None` | always | no | the checkpoint id: `Agent.model_id` for an Agent, the resolved alias (for example `"english"`) for a Router. |
diff --git a/docs/hooks/tracing.md b/docs/hooks/tracing.md
index dfcd67ad..53cd0f6d 100644
--- a/docs/hooks/tracing.md
+++ b/docs/hooks/tracing.md
@@ -1,7 +1,8 @@
# Tracing
-Every hook of one call receives the same `PredictContext.run_id`, so a tracer can correlate the
-start, end and error events (and any spans it opens) without keeping its own bookkeeping.
+Every predict-event hook of one call receives the same `PredictContext.run_id`, so a tracer can
+correlate the start, end and error events (and any spans it opens) without keeping its own
+bookkeeping.
- [run_id](#run_id)
- [A minimal tracer](#a-minimal-tracer)
@@ -16,7 +17,12 @@ start, end and error events (and any spans it opens) without keeping its own boo
- A `uuid4().hex` string, created once per public call (`predict_batch`, `system_one`,
`Router.predict`, `ONNXAgent.system_one`). `Router.predict_batch` creates one per request
instead, the `run_id` a `Router.predict` call for that request would have had.
-- Shared by every hook of that call, including `on_error` and `on_predict_end`.
+- Shared by every predict-event hook of that call: `on_predict_start`, `on_predict_end` and
+ `on_error` see one `PredictContext`, so one `run_id`.
+- **Not** shared with `on_route`, `on_load` or `on_evict`. Each is dispatched with a context of
+ its own, so a single `Router.predict` hands out three different `run_id`s. Correlate a routing
+ decision with its prediction through `ctx.decision`, which `on_predict_start` also carries, not
+ through `run_id`.
- Not global and not persisted: it identifies a call within the process. Put it in your logs and
outbound payloads to correlate across systems.
- Distinct per call, so two calls never collide.