Interface: TurnContext
Defined in: lib/contracts/turn_runner_context.ts:329
The validated, strongly-typed context object threaded through every middleware step in a single agent turn.
Remarks
Constructed from a RawTurnContext by @nhtio/adk!TurnRunner.run. Middleware functions receive this object and use it to read and share state across pipeline steps.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
abort | readonly | (reason?: unknown) => void | Aborts the turn's AbortController with the supplied reason. Middleware should call this when refusing the turn — the runner reads aborted between every stage and short-circuits cleanly: turnEnd still fires, no error event is emitted, and during dispatch dispatchEnd.status === 'aborted' carries the operational signal. | lib/contracts/turn_runner_context.ts:672 |
aborted | readonly | boolean | true when the turn's AbortController signal has fired. | lib/contracts/turn_runner_context.ts:663 |
abortSignal | readonly | AbortSignal | The AbortSignal from the turn's AbortController. | lib/contracts/turn_runner_context.ts:665 |
deleteMemory | readonly | (id: string) => void | Promise<void> | Removes a memory from the persistence layer by ID. | lib/contracts/turn_runner_context.ts:714 |
deleteMessage | readonly | (id: string) => void | Promise<void> | Removes a message from the persistence layer by ID. | lib/contracts/turn_runner_context.ts:728 |
deleteRetrievable | readonly | (id: string) => void | Promise<void> | Removes a retrievable record from the persistence layer by ID. | lib/contracts/turn_runner_context.ts:722 |
deleteStandingInstruction | readonly | (v: string | Tokenizable) => void | Promise<void> | Removes a standing instruction from the persistence layer. | lib/contracts/turn_runner_context.ts:708 |
deleteThought | readonly | (id: string) => void | Promise<void> | Removes a thought from the persistence layer by ID. | lib/contracts/turn_runner_context.ts:734 |
deleteToolCall | readonly | (id: string) => void | Promise<void> | Removes a tool call from the persistence layer by ID. | lib/contracts/turn_runner_context.ts:740 |
emitMessage | readonly | EmitMessageFn | Emits a message event on the runner; may be called at any point during the turn. | lib/contracts/turn_runner_context.ts:760 |
emitThought | readonly | EmitThoughtFn | Emits a thought event on the runner; may be called at any point during the turn. | lib/contracts/turn_runner_context.ts:762 |
emitToolCall | readonly | EmitToolCallFn | Emits a toolCall event on the runner; may be called at any point during the turn. | lib/contracts/turn_runner_context.ts:764 |
emitToolExecutionEnd | readonly | EmitToolExecutionEndFn | Emits a toolExecutionEnd event on the observability bus; forwarded from DispatchContext by DispatchRunner when a tool finishes executing inside a dispatch. | lib/contracts/turn_runner_context.ts:768 |
emitToolExecutionStart | readonly | EmitToolExecutionStartFn | Emits a toolExecutionStart event on the observability bus; forwarded from DispatchContext by DispatchRunner when a tool is invoked inside a dispatch. | lib/contracts/turn_runner_context.ts:766 |
fetchMemories | readonly | () => | Memory[] | Promise<Memory[]> | Fetches memories relevant to this turn; delegates to the callback supplied at construction. | lib/contracts/turn_runner_context.ts:690 |
fetchMessages | readonly | () => | Message[] | Promise<Message[]> | Fetches conversation messages relevant to this turn; delegates to the callback supplied at construction. | lib/contracts/turn_runner_context.ts:692 |
fetchRetrievables | readonly | () => | Retrievable[] | Promise<Retrievable[]> | Fetches retrievable records relevant to this turn; delegates to the callback supplied at construction. | lib/contracts/turn_runner_context.ts:716 |
fetchThoughts | readonly | () => | Thought[] | Promise<Thought[]> | Fetches thought traces relevant to this turn; delegates to the callback supplied at construction. | lib/contracts/turn_runner_context.ts:694 |
fetchToolCalls | readonly | () => | ToolCall[] | Promise<ToolCall[]> | Fetches tool call records relevant to this turn; delegates to the callback supplied at construction. | lib/contracts/turn_runner_context.ts:696 |
fetchTools | readonly | () => | Tool<SpooledArtifact>[] | Promise<Tool<SpooledArtifact>[]> | Fetches tools available for this turn; delegates to the callback supplied at construction. | lib/contracts/turn_runner_context.ts:698 |
id | readonly | string | Unique identifier for this turn, generated as a UUIDv6 at construction time. | lib/contracts/turn_runner_context.ts:661 |
mutateMemory | readonly | (v: Memory) => void | Promise<void> | Updates an existing memory in the persistence layer. | lib/contracts/turn_runner_context.ts:712 |
mutateMessage | readonly | (v: Message) => void | Promise<void> | Updates an existing message in the persistence layer. | lib/contracts/turn_runner_context.ts:726 |
mutateRetrievable | readonly | (v: Retrievable) => void | Promise<void> | Updates an existing retrievable record in the persistence layer. | lib/contracts/turn_runner_context.ts:720 |
mutateStandingInstruction | readonly | (v: string | Tokenizable) => void | Promise<void> | Updates an existing standing instruction in the persistence layer. | lib/contracts/turn_runner_context.ts:706 |
mutateThought | readonly | (v: Thought) => void | Promise<void> | Updates an existing thought in the persistence layer. | lib/contracts/turn_runner_context.ts:732 |
mutateToolCall | readonly | (v: ToolCall) => void | Promise<void> | Updates an existing tool call in the persistence layer. | lib/contracts/turn_runner_context.ts:738 |
refreshStandingInstructions | readonly | () => | (string | Tokenizable)[] | Promise<(string | Tokenizable)[]> | Refreshes and returns the standing instructions; delegates to the callback supplied at construction. | lib/contracts/turn_runner_context.ts:700 |
standingInstructions | readonly | Set<Tokenizable> | Standing instructions applied to every turn, in insertion order. | lib/contracts/turn_runner_context.ts:678 |
stash | readonly | Registry | Arbitrary key-value store that middleware can read and write across pipeline steps. | lib/contracts/turn_runner_context.ts:674 |
storeMediaBytes | readonly | (id: string, bytes: ConduitBytes) => | MediaReader | Promise<MediaReader> | Persists tool-generated media bytes into consumer storage and returns a @nhtio/adk!MediaReader. Low-level conduit — returns a value, touches no turn state; build a @nhtio/adk!Media from the reader and persist the owning primitive separately. | lib/contracts/turn_runner_context.ts:746 |
storeMemory | readonly | (v: Memory) => void | Promise<void> | Stores a new memory in the persistence layer. | lib/contracts/turn_runner_context.ts:710 |
storeMessage | readonly | (v: Message) => void | Promise<void> | Stores a new message in the persistence layer. | lib/contracts/turn_runner_context.ts:724 |
storeRetrievable | readonly | (v: Retrievable) => void | Promise<void> | Stores a new retrievable record in the persistence layer. | lib/contracts/turn_runner_context.ts:718 |
storeRetrievableBytes | readonly | (id: string, bytes: ConduitBytes) => | SpoolReader | Promise<SpoolReader> | Persists extracted retrievable text bytes into consumer storage and returns a @nhtio/adk!SpoolReader. Wrap it in a @nhtio/adk!SpooledArtifact for Retrievable.content and persist the record via TurnContext.storeRetrievable separately. | lib/contracts/turn_runner_context.ts:755 |
storeStandingInstruction | readonly | (v: string | Tokenizable) => void | Promise<void> | Stores a new standing instruction in the persistence layer. | lib/contracts/turn_runner_context.ts:704 |
storeThought | readonly | (v: Thought) => void | Promise<void> | Stores a new thought in the persistence layer. | lib/contracts/turn_runner_context.ts:730 |
storeToolCall | readonly | (v: ToolCall) => void | Promise<void> | Stores a new tool call in the persistence layer. | lib/contracts/turn_runner_context.ts:736 |
systemPrompt | readonly | Tokenizable | The system prompt guiding the agent's behaviour for this turn. | lib/contracts/turn_runner_context.ts:676 |
tools | readonly | ToolRegistry | Turn-scoped tool registry constructed from the runner's baseline tools; middleware may trim or extend it. | lib/contracts/turn_runner_context.ts:772 |
turnMemories | readonly | Set<Memory> | Memories loaded for this turn; populated by middleware after calling fetchMemories(). | lib/contracts/turn_runner_context.ts:680 |
turnMessages | readonly | Set<Message> | Conversation messages loaded for this turn; populated by middleware after calling fetchMessages(). | lib/contracts/turn_runner_context.ts:684 |
turnRetrievables | readonly | Set<Retrievable> | Retrievable records loaded for this turn; populated by middleware after calling fetchRetrievables(). | lib/contracts/turn_runner_context.ts:682 |
turnThoughts | readonly | Set<Thought> | Thought traces loaded for this turn; populated by middleware after calling fetchThoughts(). | lib/contracts/turn_runner_context.ts:686 |
turnToolCalls | readonly | Set<ToolCall> | Tool call records loaded for this turn; populated by middleware after calling fetchToolCalls(). | lib/contracts/turn_runner_context.ts:688 |
waitFor | readonly | OpenGateFn | Opens a turn gate and suspends until it resolves, rejects, times out, or is aborted. | lib/contracts/turn_runner_context.ts:770 |