-
Notifications
You must be signed in to change notification settings - Fork 44
feat: add ui/update-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?
Conversation
commit: |
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.
Pull request overview
This PR introduces the ui/update-context request to allow Guest UI applications to inform the host agent about app state changes that should be stored in the conversation context for future reasoning, without triggering follow-up actions. This addresses the need to distinguish between logging messages (notifications/message), interactive messages that expect follow-ups (ui/message), and context updates that inform the agent's reasoning.
Key changes:
- Added
ui/update-contextrequest type with role and ContentBlock[] parameters - Extended host capabilities to include optional
contextcapability for negotiation - Implemented
sendContext()method in App class andoncontexthandler in AppBridge class
Reviewed changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Re-exports new McpUiUpdateContextRequest/Result types and schemas |
| src/spec.types.ts | Defines TypeScript interfaces for update-context request/result and adds context capability to McpUiHostCapabilities |
| src/generated/schema.ts | Adds Zod schemas for validating update-context requests and results |
| src/generated/schema.test.ts | Adds type inference tests to verify schema/type compatibility |
| src/generated/schema.json | Contains JSON schema definitions for update-context with full ContentBlock support |
| src/app.ts | Implements sendContext() method for Guest UI to send context updates to host |
| src/app-bridge.ts | Implements oncontext handler for Host to receive context updates from Guest UI |
| src/app-bridge.test.ts | Adds integration tests covering basic sendContext functionality with single and multiple content blocks |
| specification/draft/apps.mdx | Documents ui/update-context in the protocol specification with examples and host behavior guidelines |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 6 out of 9 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Something to discuss: I wonder if we want to go full multimedia on this one.
Also, in OAI Apps SDK the updates are essentially structuredContent, and text might also often be the most useful kind of update, so both would place us in the territory of Pick<CallToolResult, 'content' | 'structuredContent' | 'isError'> more than a message content block array
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.
And should this be ui/update-semantic-state?
antonpk1
left a comment
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.
Thanks for the proposal! I think we should design the state that only the last 'context-update' is used, and all past context updates are disregarded.
Here's a specific example: imagine a text-editor app. The user can write and edit text and wants to be able to ask the agent to help/reflect/act on the current text state.
Problem with the current proposal: if we send a 'context-update' with full text on every character change, it will quickly pollute the entire context window and won't work well.
At the same time, if an app wants to share context with a chronological history of events like in current proposal, nothing prevents them from accumulating an array and passing that as a 'context-update'.
This message captures the original intent behind
notify(notifications/message) - allow the UI to update the agent's context without triggering a follow-up action.notifications/messageremains another message type with MCP's original intent.Addresses #61.
Note: the params's type (
content: ContentBlock[]) may be problematic for the MVP. It's subject to the same decision as #119 (comment)