Agent SDK: Workload Identity and Auth Callback

Feature request for product/service

Cursor SDK

Describe the request

We build Keycard, which gives agents short-lived, policy-checked credentials instead of stored API keys. We’ve specced a Keycard integration for the Agent SDK (0.3.0) on top of bearerAuth(verify) and the per-session connection auth callback, and both fit well.

A couple gaps and one question:

  1. Workload identity for hosted deployments. A signed, short-lived OIDC token per deployment, like GitHub Actions or Vercel provide, would let hosted agents authenticate to external services without a long-lived secret in secretNames. Today that secret is the one stored credential our integration can’t remove.

  2. Let an auth callback ask for sign-in. action.auth_requested with an authUrl already pauses the turn for oauth: true connections. An auth callback can only throw, which fails the turn. A way for the callback to say “this user needs to sign in at this URL” would let it use the same pause.

  3. Do hosted sessions stay in one process? We keep the caller’s verified token in memory between the inbound request and the connection callback, so a turn in a different process can’t act for them. If hosted sessions can move between processes, a host-only per-session value that isn’t saved with the session would close that gap.

Happy to share what we built if it’s useful.

Operating System (if it applies)

Windows 10/11
MacOS
Linux

Hey @LaireLaFlare, thanks for the write-up!

A short-lived identity token per hosted deployment is on our radar, and the team is looking at it.

On sessions and processes: don’t count on a hosted session staying in one process. Hosted agents can be stopped and replaced between turns, and a later turn (a follow-up, a reminder wake, or a retry) can resume the session on a fresh instance. Only sessions, ctx.host.kv and ctx.host.files carry over, so a token held in memory from the inbound request may not be there when the connection callback runs.

Also keep in mind that whatever your bearerAuth verifier returns becomes session.auth, which is saved with the session, so don’t put the raw token there. There’s no host-only, unsaved per-session value today.

Nothing to share on auth callback right now.

Thanks @Colin, that’s helpful. It confirms what I suspected: since 0.3.0 removed the persistent hosting option (one-line changelog, no reason or replacement: cursor.com/docs/agent-sdk/changelog), hosted agents are per-event and can be replaced between turns, with only sessions, ctx.host.kv and ctx.host.files carrying over.

That works for event-driven agents, but an always-running option is very useful for persistent Slack apps on Socket Mode: slash commands, modals, and a Home tab that need a long-lived process rather than a fresh instance per event. The alpha README’s “WebSocket channel routes: not supported (yet)” is the only roadmap hint I’ve seen.

  1. Could you share why persistent was removed, and whether an always-on or WebSocket-style hosted option is on the roadmap?
  2. Can an existing, company-owned and approved Slack app be the event source for a hosted agent? Hosted Slack intake seems tied to a Cursor-managed app (Events API), while Socket Mode with agent-sdk slack init --manual looks limited to self-hosted serve. Supporting a pre-approved owned app would save enterprises from approving an extra Cursor-managed app.

+1 on the per-deployment identity token too. That would remove the last long-lived secret from our hosted setup.

Hey @amoravec,

On persistent: hosted agents are built around fresh compute per event, with state carried in sessions, ctx.host.kv and ctx.host.files. An always-running process didn’t fit that model, so the option was retired in 0.3.0. We don’t have an always-on or WebSocket-style hosted mode to share right now.

If you need a long-lived process today, self-hosting with agent-sdk serve keeps one running on your own infrastructure, and it can connect to your own Slack app over Socket Mode (agent-sdk slack init --manual).

When using your own Slack app with a hosted agent, today hosted Slack intake goes through a Cursor-managed app. Supporting a company-owned, pre-approved app on hosted is on our radar but nothing to share today.