Skip to content

Conversation

@jtpio
Copy link
Member

@jtpio jtpio commented Dec 23, 2025

Fixes #146

v6 now provides built-in support for agents, so we don't need to depend on the OpenAI Agents SDK anymore.

Changes

  • Update to the AI SDK v6
  • Drop @openai/agents dependencies
  • Drop custom MCP adapter and use @ai-sdk/mcp instead
  • Fix tool approval flow
  • Update the list of models for each provider
  • Check if custom providers still work -> seems to be working fine with jupyterlab-browser-ai

@jtpio jtpio added this to the 0.10.0 milestone Dec 23, 2025
@jtpio jtpio marked this pull request as ready for review December 24, 2025 16:39
@brichet
Copy link
Collaborator

brichet commented Dec 26, 2025

Thanks @jtpio for working on this.

When testing it, the approval tools is not called anymore on my side

output.webm

.default(true)
.describe('Whether to record execution timing')
}),
needsApproval: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the previous comment, it seems to be intentional.

Should we add a way to let user set the tools that need approval (similar to what we have for the commands) ?
Probably in a follow up PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add it back like it was before, and reconsider after #219

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 246dcf8

Copy link
Collaborator

@brichet brichet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jtpio, this is a great improvement.
I've tested it successfully so far!

*/
export function createDiscoverCommandsTool(commands: CommandRegistry): ITool {
return tool({
name: 'discover_commands',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a title attribute if we want to keep something equivalent.
No sure there is any use case to it, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 246dcf8

);
if (existingMessageIndex !== -1) {
const existingMessage = this.messages[existingMessageIndex];
export function buildToolCallHtml(options: IToolCallHtmlOptions): string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, this is really nice to build it out of the model itself. 👍

this._chatPanel = options.chatPanel;
this._chatModel = this._chatPanel.model as AIChatModel;
this._trans = options.trans;
this._agentManager = options.agentManager;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have 2 opposite thoughts about this:

  1. we could retrieve it with this.chatPanel.model.agentManager to avoid adding a dependency
  2. we could get rid of the chatPanel dependency, and only depends on a node

The advantage of the second approach is that it makes the approval-buttons independent of the chat, and allows more easily to expose it as a standalone extension.

Copy link
Collaborator

@brichet brichet Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it, the more I am confused about the ApprovalButtons implementation, perhaps because of the history of the object (and what I think was not possible before), or (probably) I miss something.

The current behavior is:

  • the chat panel receives an interruption, and create a DOM node with APPROVAL_BUTTONS: text in there
  • the ApprovalButtons listen for any change in the chat node, looks for APPROVAL_BUTTONS: text, and replace the corresponding node with a button

Why not creating an ApprovalButtons object in the chat itself, and build the buttons using it (something like approvalButtons.buildButtons(approvalId)), instead of building a temporary DOM node with APPROVAL_BUTTONS: text ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I wasn't sure if it was worth looking too much into this now. The current approach of building HTML "by hand" is not great, but maybe it's something that should be investigated in @jupyter/chat or a sibling library, as part of jupyterlab/jupyter-chat#276?

Or we try to make use of the current message of the current message footer extension point for the approval buttons?

Another idea could be for @jupyter/chat to allow adding custom message renderers or something similar, that would allow passing custom reusable components (tool call box, approval UI, todo list).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idea could be for @jupyter/chat to allow adding custom message renderers or something similar, that would allow passing custom reusable components (tool call box, approval UI, todo list).

This would probably be more generic than using the message footer extension point.
A sibling library providing markdown/rendered component could be a good idea, and may be used in other markdown renderer, not only in chat.

@jtpio
Copy link
Member Author

jtpio commented Dec 30, 2025

When testing it, the approval tools is not called anymore on my side

This is likely because there is a dedicated run_cell tool, and this list applies to commands only. We can add the need to approval back like before:

needsApproval: true,

Copy link
Collaborator

@brichet brichet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jtpio, it looks good to me.

@brichet brichet merged commit 9450039 into jupyterlite:main Jan 12, 2026
9 checks passed
@jtpio jtpio deleted the aisdk-6 branch January 12, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to ai-sdk and openai-agent

2 participants