Skip to content

InjectedBlock

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

Experimental

Text the app adds to a user turn, such as a reminder or recalled memories, kept apart from the user’s own words. Use it instead of a TextBlock when the text comes from the app, not the user. It belongs in a user message, after the existing content. In any other message it is left out, with a warning.

ContextInjector and MemoryManager write their text as injected blocks, so code that should only see the user’s own words can skip them.

It stays in the message like any other content, so every later request sends that message the same way. The agent sends it to the model as plain text in that message. A direct call to a model, such as model.stream(), leaves it out.

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:1047

Experimental

ParameterType
dataInjectedBlockData

InjectedBlock

readonly type: "injectedBlock";

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

Experimental

Discriminator for injected content.


readonly injected: InjectedBlockData;

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

Experimental

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:1055

Experimental

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

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

JSONSerializable.toJSON


static fromJSON(data): InjectedBlock;

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

Experimental

Creates an InjectedBlock instance from its wrapped data format.

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

InjectedBlock

InjectedBlock instance