Skip to content

Conversation

@PavelKorobchuk
Copy link
Contributor

Renamed CIBA/Token vault methods according to this file
Updated to AI SDK 5, updated examples:

  • check-user-calendar:
Screenshot 2025-10-23 at 12 28 09 Screenshot 2025-10-23 at 12 29 17
  • buy-stock:
Screenshot 2025-10-22 at 14 31 59
  • getLocalTime:
Screenshot 2025-10-23 at 13 01 54
  • scheduleTask:
Screenshot 2025-10-23 at 12 57 59
  • show scheduled tasks:
Screenshot 2025-10-23 at 13 00 01
  • cancel scheduled task:
Screenshot 2025-10-23 at 13 01 21

package.json Outdated
"agents": "^0.0.77",
"ai": "^4.3.13",
"agents": "^0.2.11",
"ai": "^5.0.0",
Copy link
Contributor

@priley86 priley86 Oct 24, 2025

Choose a reason for hiding this comment

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

is resume functionality working w/ latest alongside cloudflare here? This is great if so, but was not seeing this behavior when upgrading alongside some of the Vercel + Next.js examples before (and was seeing resume functionality get hung up).

Believe these versions were validated to work elsewhere:

    "@ai-sdk/openai": "2.0.24",
    "@ai-sdk/react": "2.0.33",
    "ai": "5.0.33",

ex:
https://github.com/auth0-samples/auth0-ai-samples/blob/main/call-apis-on-users-behalf/others-api/vercel-ai-next-js/package.json#L24-L35

As long as package-lock is checked in and resume works, i suppose it is ok.

Eventually, we will need an update in core auth0-ai-js repo to fully update Vercel to latest (ai@5.0.78 as of now) and ensuring other examples.

We should definitely get a fast follow for this + zod v4 update later (or zod 4 optional)... definitely seems like something we can do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Comment on lines 85 to 89
const pendingToolCallConfirmation = agentMessages.some(
(m: UIMessage) =>
m.parts?.some(() => TokenVaultInterrupt.isInterrupt(toolInterrupt)) ||
TokenVaultInterrupt.isInterrupt(toolInterrupt)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const pendingToolCallConfirmation = agentMessages.some(
(m: UIMessage) =>
m.parts?.some(() => TokenVaultInterrupt.isInterrupt(toolInterrupt)) ||
TokenVaultInterrupt.isInterrupt(toolInterrupt)
);
const pendingToolCallConfirmation = agentMessages.some(
(m: UIMessage) =>
m.parts?.some(
(part) =>
(part?.type?.startsWith("tool-") &&
toolsRequiringConfirmation.includes(
part.type?.split("-")[1] as keyof typeof tools
) &&
"state" in part &&
part?.state === "input-available") ||
TokenVaultInterrupt.isInterrupt(toolInterrupt)
) || TokenVaultInterrupt.isInterrupt(toolInterrupt)
);

Copy link
Contributor

Choose a reason for hiding this comment

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

seems ok to just follow existing pattern here. This pendingToolCallConfirmation is only used to change the textbox's placeholder text it seems (both for interrupt and approval states).

Screenshot 2025-10-29 at 9 35 26 AM

{agentMessages.map((m: UIMessage, index) => {
const isUser = m.role === "user";
const showAvatar =
index === 0 || agentMessages[index - 1]?.role !== m.role;
Copy link
Contributor

Choose a reason for hiding this comment

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

seeing duplicate div key's giving some warnings in console below (likely unrelated this change), but suggestion would be:

return (
  <div key={`${m.id}-${index}`}>
 ...

priley86
priley86 previously approved these changes Oct 29, 2025
[key: string]: any;
}

type MixinMethods = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this as it will require the developer to keep it in sync with @auth0/auth0-cloudflare-agents-api. If you don't like this extend syntax, you can just use inherits from AsyncUserConfirmationResumer(OwnedAgent(AuthAgent(AIChatAgent))).

Create the class before extending it.

Copy link
Contributor

@priley86 priley86 Oct 30, 2025

Choose a reason for hiding this comment

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

in retrospect, i agree. I did not like having to self extend these mixins, and was looking for a vanilla ts way of ensuring that behavior w/ the class extended & exposed. I prefer to keep w/ the npm extend helper, which appears to provide this and gives good type support (and good intellisense).

src/server.ts Outdated

app.use(
auth({
domain: process.env.AUTH0_DOMAIN!,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the default:

https://github.com/auth0-lab/auth0-hono/blob/main/src/config/envConfig.ts#L54-L67

also process.env might be undefined if this is not available, auth0-hono handles the configuration without process.env from cloudflare vars

https://github.com/auth0-lab/cloudflare-agents-starter/blob/main/wrangler.jsonc#L12

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants