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): elapsed_ms on a Router call is the prediction, not the whole call

Adeshina Lasisie0ac46b70543
diff --git a/docs/hooks/api.md b/docs/hooks/api.md
index c3c105b6..ae6b057e 100644
--- a/docs/hooks/api.md
+++ b/docs/hooks/api.md
@@ -58,7 +58,7 @@ class PredictContext:
| `head_max_len` | `int \| None` | always | yes (start) | per-call token budget for the question head. `None` uses the agent config. |
| `usage` | `dict \| None` | end | yes (end) | `{"input_tokens", "output_tokens"}`, summed over the states of the call. |
| `started_at` | `float` | always | no | `time.perf_counter()` when the call began. |
-| `elapsed_ms` | `float \| None` | end | no | wall time for the whole call, milliseconds. |
+| `elapsed_ms` | `float \| None` | end | no | wall time in milliseconds, measured from `started_at`. On an Agent that is the whole call. On a Router `started_at` is reset after routing and loading, so it is the prediction only -- a cold model load is not in it. |
| `error` | `BaseException \| None` | failure path | no | the exception, set before `on_error` and `on_predict_end`. |
### `PredictContext.skip(results)`
diff --git a/docs/hooks/lifecycle.md b/docs/hooks/lifecycle.md
index 441170d0..8d95a9e8 100644
--- a/docs/hooks/lifecycle.md
+++ b/docs/hooks/lifecycle.md
@@ -106,6 +106,10 @@ Key points:
- `on_route` runs before the model is loaded, so a hook can pin a checkpoint and avoid loading
another one.
+- `ctx.started_at` is reset after `route` and `load`, immediately before `on_predict_start`, so
+ the `ctx.elapsed_ms` an end hook reads is the prediction alone. Routing and a cold model load --
+ seconds, for a checkpoint that was not resident -- are outside it. Time the whole call from the
+ caller, or from `on_route`, if that is what you need.
- Router-level predict hooks wrap the whole call. They are **not** forwarded into the Agent;
an attached Agent with its own hooks runs those too, which is expected.
- A Router-level `ctx.skip()` still adds `routing`, so the return shape is stable.