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.
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:1047
Experimental
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:1040
Experimental
Discriminator for injected content.
injected
Section titled “injected”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.
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”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().
Returns
Section titled “Returns”{ injected: InjectedBlockData;}| Name | Type | Defined in |
|---|---|---|
injected | InjectedBlockData | src/types/messages.ts:1055 |
Implementation of
Section titled “Implementation of”JSONSerializable.toJSON
fromJSON()
Section titled “fromJSON()”static fromJSON(data): InjectedBlock;Defined in: src/types/messages.ts:1065
Experimental
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