Intelligence · class
AgentSession
One agent: a floor that always runs, and one slot holding what comes next.
Explained in Agents and behaviour.
class AgentSession<W = unknown>import { AgentSession } from '@driftengine/ai';In depth
The current slot is never empty. When an intent finishes, the buffer drains into it; when the buffer is empty, the policy floor supplies. An agent with no provider configured behaves exactly as one whose provider is slow — less cleverly, and without ever standing still.
tick is the whole surface a consumer needs inside its fixed step. It returns the
intent to execute and never returns null.
Constructor
new
constructor(options: AgentSessionOptions<W>)| Parameter | Type | Description |
|---|---|---|
options | AgentSessionOptions<W> |
Properties
| Name | Type | Description |
|---|---|---|
agentIdreadonly | string |
Accessors
| Name | Type | Description |
|---|---|---|
stateget | AgentState | |
currentget | Intent | null | Never null once tick has run once. |
bufferedget | Intent | null | |
usageget | Readonly<AiUsage> | |
degradedget | boolean | True once a budget is exhausted: still moving, no longer asking. |
degradedReasonget | string | The budget's own sentence, or empty while nothing is exhausted. |
discardedIntentsget | number | Buffered intents discarded because their guard had gone false. |
leadMsget | number | The lead the watermark uses: the provider's measured p90, or -1 before it knows. |
Methods
observe
observe(observation: Observation): voidSomething happened that the agent may care about.
| Parameter | Type | Description |
|---|---|---|
observation | Observation |
More
Never acted on here — an observation taken mid-tick would mutate the simulation
halfway through a step. It waits for the next tick.
tick
tick(tickNumber: number, nowMs: number): IntentAdvance one fixed step and return the intent to execute.
| Parameter | Type | Description |
|---|---|---|
tickNumber | number | |
nowMs | number |
More
Never returns null. That is the track's whole claim and it is asserted directly.
complete
complete(nowMs: number): voidThe consumer says the current intent is over, ahead of its expected extent.
| Parameter | Type | Description |
|---|---|---|
nowMs | number |
dispose
dispose(reason?: string): void| Parameter | Type | Description |
|---|---|---|
reason? | string |