Turn End schema — AI Protocol reference
The turn end — why an ask turn stopped, and whether the person may ask the server to carry the same turn on from where it stopped.
The turn end — why an ask turn stopped, and whether the person may ask the server to carry the same turn on from where it stopped.
Who writes it, who reads it
- Producer: the host that runs the ask turn. At the end of a streamed
turn, before the stream's
finish, it sends one UI-message-stream data part namedTURN_END_PART_TYPEwhosedatais aTurnEndSchemaobject. It stores the same object with the turn's last message, and the conversation routes return it there asAiConversationMessageSchema.turnEnd, so a reloaded conversation knows it too. A turn replayed by itsturnId(nothing ran) sends none. - Reader: the console's chat (
extractTurnEndin@object-ui/plugin-chatbot). It reads the part, or the stored field, through this schema; one the schema refuses is no turn end at all, and the answer renders as it does without one.
What the chat does with it
Under the conversation's last answer, while nothing is streaming, the chat
offers a Continue control when resumable is true and resumesLeft is
above zero. Pressing it sends a chat request carrying
resume: { turnId } (AiChatRequestSchema.resume) and no new user message;
the server rebuilds the stopped turn from what it stored and streams the
rest of the answer into the same turn. The request carries no top-level
turnId (a resume names its turn itself), and its messageId is the
answer's id: the resume stream's start chunk carries that id or none, or
the chat draws the rest as a second answer. Whether a turn may be resumed
is the server's decision alone: the chat never infers it from reason, and
the server refuses a resume it did not offer.
Source: packages/spec/src/ai/turn-end.zod.ts
TypeScript Usage
import { TurnEndSchema } from '@objectstack/spec/ai';
import type { TurnEnd } from '@objectstack/spec/ai';
// Validate data
const result = TurnEndSchema.parse(data);TurnEnd
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| reason | string | ✅ | Why the turn ended, in the producer's own words: answered when the model ended it, tool_ended when a tool did, the limit that sent it to a wrap-up answer (time_limit, token_budget, max_iterations, …), or the kind of refusal that stopped it. Informational: the chat decides nothing from it |
| wrapUp | boolean | ✅ | true when the answer is the wrap-up the turn gave on reaching a limit, written from what the turn had read so far, rather than an answer the model finished on its own |
| resumable | boolean | ✅ | The server's verdict that a resume of this turn would be accepted now. The chat offers Continue only when it is true and resumesLeft is above zero |
| resumesLeft | integer | ✅ | How many more times this turn may be resumed; 0 once none are left |
| turnId | string | ✅ | The turn this end belongs to: the turnId a resume names in AiChatRequestSchema.resume.turnId |
Record Context Tools
Record Context Tools schemas of the ObjectStack AI Protocol: GetRecordContextInput and 9 more — each property with its type, default and a TypeScript example.
Automation Protocol
The ObjectStack Automation Protocol in 16 reference pages: every schema in @objectstack/spec with its properties, types, defaults and a TypeScript example.