Complete "Sending large follow-up messages" pattern documentation

Add new pattern showing how to combine `updateModelContext()` with
`sendMessage()` when data exceeds message size limits. The example
demonstrates offloading a large transcript to model context first,
then sending a brief trigger message.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jonathan Hefner 2026-01-19 20:11:43 -06:00
commit e626b84d44

View file

@ -81,18 +81,6 @@ async function App_basicUsage() {
//#endregion App_basicUsage
}
/**
* Example: Sending a message to the host's chat.
*/
async function App_sendMessage(app: App) {
//#region App_sendMessage
await app.sendMessage({
role: "user",
content: [{ type: "text", text: "Weather updated!" }],
});
//#endregion App_sendMessage
}
/**
* Example: Check host capabilities after connection.
*/
@ -329,6 +317,33 @@ async function App_sendMessage_textFromInteraction(app: App) {
//#endregion App_sendMessage_textFromInteraction
}
/**
* Example: Send follow-up message after offloading large data to model context.
*/
async function App_sendMessage_withLargeContext(
app: App,
fullTranscript: string,
speakerNames: string[],
) {
//#region App_sendMessage_withLargeContext
const markdown = `---
word-count: ${fullTranscript.split(/\s+/).length}
speaker-names: ${speakerNames.join(", ")}
---
${fullTranscript}`;
// Offload long transcript to model context
await app.updateModelContext({ content: [{ type: "text", text: markdown }] });
// Send brief trigger message
await app.sendMessage({
role: "user",
content: [{ type: "text", text: "Summarize the key points" }],
});
//#endregion App_sendMessage_withLargeContext
}
/**
* Example: Log app state for debugging.
*/