-
Notifications
You must be signed in to change notification settings - Fork 54
feat: add ui/update-model-context #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6727390
69b7570
0085768
b848642
5369d33
0447af5
7392629
9e920c9
27f950a
a809478
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And should this be ui/update-semantic-state?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ import { PostMessageTransport } from "./message-transport"; | |
| import { | ||
| LATEST_PROTOCOL_VERSION, | ||
| McpUiAppCapabilities, | ||
| McpUiUpdateModelContextRequest, | ||
| McpUiUpdateModelContextResultSchema, | ||
| McpUiHostCapabilities, | ||
| McpUiHostContext, | ||
| McpUiHostContextChangedNotification, | ||
|
|
@@ -809,6 +811,40 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> { | |
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Send context updates to the host to be included in the agent's context. | ||
| * | ||
| * Unlike `sendLog`, which is for debugging/telemetry, context updates | ||
| * are inteded to be available to the model in future reasoning, | ||
| * without requiring a follow-up action (like `sendMessage`). | ||
| * | ||
| * @param params - Context role and content (same structure as ui/message) | ||
| * @param options - Request options (timeout, etc.) | ||
| * | ||
| * @example Update model context with current app state | ||
| * ```typescript | ||
| * await app.sendUpdateModelContext({ | ||
| * role: "user", | ||
| * content: [{ type: "text", text: "User selected 3 items totaling $150.00" }] | ||
| * }); | ||
| * ``` | ||
| * | ||
| * @returns Promise that resolves when the context update is acknowledged | ||
| */ | ||
| sendUpdateModelContext( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updateModelContextthe current pattern is to avoid double verbs (w/ exception of |
||
| params: McpUiUpdateModelContextRequest["params"], | ||
| options?: RequestOptions, | ||
| ) { | ||
| return this.request( | ||
| <McpUiUpdateModelContextRequest>{ | ||
| method: "ui/update-model-context", | ||
| params, | ||
| }, | ||
| McpUiUpdateModelContextResultSchema, | ||
| options, | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Request the host to open an external URL in the default browser. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably also need to mention that the host MAY defer sending the context to the model, and it MAY dedupe identical ui/update-context calls.
Potentially we could add a boolean that says it replaces / purges any previously pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SHOULD provide the context to the model in future turns?