What a middleware's admit stage is given (#2854): who the turn is for, and a way to have the stage's own model calls counted.
It is less than a hook's ModelContext on purpose. Admission runs before the turn has a run, a task or a checkpoint, so that a query it refuses or rewrites is never stored as submitted: there is no thread state to read or update, no event to emit, no question to ask and no tool to call, and so nothing here offers them. A stage that needs any of those belongs in beforeAgent.
A stage that calls a model - an LLM judge - wraps its client with accounted. Its calls are counted in the thread's usage and announced with a durable ModelCallCompleted as a hook's are, when the turn's input step commits; they are made before the run exists, so its token budget (RunBudgets.maxTokens) does not refuse them, though it counts them.
Value parameters
- agent
-
the agent whose stack the stage is in
- principal
-
who the run is for (
RunConfig.principal) - tenantId
-
the tenant of the run being admitted (
RunConfig.tenantId) - threadId
-
the thread the turn is for
Attributes
- Companion
- object
- Source
- AdmissionContext.scala
- Graph
-
- Supertypes
