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.
Example
Section titled “Example”const message = new Message({ role: 'user', content: [new TextBlock('Refactor the tokenizer.'), new InjectedBlock({ text: 'cwd: /repo', source: 'env' })],})Implements
Section titled “Implements”JSONSerializable<{injected:InjectedBlockData; }>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new InjectedBlock(data): InjectedBlock;Defined in: src/types/messages.ts:1120
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | InjectedBlockData |
Returns
Section titled “Returns”InjectedBlock
Properties
Section titled “Properties”readonly type: "injectedBlock";Defined in: src/types/messages.ts:1113
Discriminator for injected content.
injected
Section titled “injected”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.
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): { injected: InjectedBlockData;};Defined in: src/types/messages.ts:1128
Serializes the InjectedBlock to a JSON-compatible ContentBlockData object. Called automatically by JSON.stringify().
Returns
Section titled “Returns”{ injected: InjectedBlockData;}| Name | Type | Defined in |
|---|---|---|
injected | InjectedBlockData | src/types/messages.ts:1128 |
Implementation of
Section titled “Implementation of”JSONSerializable.toJSON
fromJSON()
Section titled “fromJSON()”static fromJSON(data): InjectedBlock;Defined in: src/types/messages.ts:1138
Creates an InjectedBlock instance from its wrapped data format.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data | { injected: InjectedBlockData; } | Wrapped InjectedBlockData to deserialize |
data.injected | InjectedBlockData | - |
Returns
Section titled “Returns”InjectedBlock
InjectedBlock instance