new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Cookbook · all subjects

api and types

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

addToolInputExamplesMiddleware signature

The function signature is: function addToolInputExamplesMiddleware(options?: { prefix?: string; format?: (example: { input: JSONObject }, index: number) => string; remove?: boolean; }): LanguageModelMiddleware

addToolInputExamplesMiddleware parameters

Parameters: prefix (string, optional, default 'Input Examples:') - prefix prepended before the input examples section. format (function, optional) - custom formatter for each example receiving the example object and its index, default is JSON.stringify(example.input). remove (boolean, optional, default true) - whether to remove the inputExamples property from the tool after adding them to the description.

Four-level message architecture layers

The AI SDK uses a four-level message architecture: UI messages contain data parts shaped for UI rendering; model messages are an abstracted, user-friendly version for good DX used in generate/stream calls; language model messages are a standardized spec intended to be stable; provider-specific messages are the final conversion for specific API requirements.

UI messages location and purpose

UI messages are defined in packages/ai/src/ui/ui-messages.ts and contain data parts shaped for UI rendering.

Model messages location and purpose

Model messages are defined in packages/provider-utils/src/types/model-message.ts and represent an abstracted, user-friendly version for good developer experience, used in generate and stream calls.

Language model messages location and purpose

Language model messages are defined in packages/provider/src/language-model/v4/language-model-v4-prompt.ts and represent a standardized spec intended to be stable across the SDK.

Provider-specific messages conversion

Provider-specific messages are the final conversion layer for specific API requirements, implemented in provider-specific classes such as OpenAIResponsesLanguageModel using methods like getArgs() and doGenerate().

Give your agent this brain