Skip to content

InjectedBlock

Defined in: src/types/messages.ts:1109

Text the app adds to a user turn, such as a reminder, kept apart from the user’s own words so readers of agent.messages can skip it. ContextInjector writes its text as injected blocks. It belongs in a user message, after the existing content; in any other message it is left out.

When the model takes temporary messages (modelInfo.capabilities.temporaryMessages), the provider sends it as a system message the model reads only until the next user message, which the model ranks above the user. Every other model receives only the latest user message’s injected text, as plain text. Keep content from outside the conversation, such as tool output or retrieved documents, out of it.

The text is kept under injected, the same shape as the saved data, so an InjectedBlock is never read as a TextBlock.

const message = new Message({
role: 'user',
content: [new TextBlock('Refactor the tokenizer.'), new InjectedBlock({ text: 'cwd: /repo', source: 'env' })],
})
new InjectedBlock(data): InjectedBlock;

Defined in: src/types/messages.ts:1120

ParameterType
dataInjectedBlockData

InjectedBlock

readonly type: "injectedBlock";

Defined in: src/types/messages.ts:1113

Discriminator for injected content.


readonly injected: InjectedBlockData;

Defined in: src/types/messages.ts:1118

The injected data: the text the app adds to the user turn and the component that added it.

toJSON(): {
injected: InjectedBlockData;
};

Defined in: src/types/messages.ts:1128

Serializes the InjectedBlock to a JSON-compatible ContentBlockData object. Called automatically by JSON.stringify().

{
injected: InjectedBlockData;
}
NameTypeDefined in
injectedInjectedBlockDatasrc/types/messages.ts:1128

JSONSerializable.toJSON


static fromJSON(data): InjectedBlock;

Defined in: src/types/messages.ts:1138

Creates an InjectedBlock instance from its wrapped data format.

ParameterTypeDescription
data{ injected: InjectedBlockData; }Wrapped InjectedBlockData to deserialize
data.injectedInjectedBlockData-

InjectedBlock

InjectedBlock instance