惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Cyber Attacks, Cyber Crime and Cyber Security
N
News and Events Feed by Topic
Schneier on Security
Schneier on Security
Forbes - Security
Forbes - Security
Webroot Blog
Webroot Blog
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
A
Arctic Wolf
Google Online Security Blog
Google Online Security Blog
T
Troy Hunt's Blog
T
Tenable Blog
L
Lohrmann on Cybersecurity
C
Cisco Blogs
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Threat Research - Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
T
The Exploit Database - CXSecurity.com
有赞技术团队
有赞技术团队
V2EX - 技术
V2EX - 技术
GbyAI
GbyAI
P
Proofpoint News Feed
雷峰网
雷峰网
Cisco Talos Blog
Cisco Talos Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Cloudbric
Cloudbric
K
Kaspersky official blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
M
MIT News - Artificial intelligence
H
Heimdal Security Blog
Vercel News
Vercel News
S
SegmentFault 最新的问题
U
Unit 42
Help Net Security
Help Net Security
S
Schneier on Security
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
I
Intezer
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Palo Alto Networks Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
宝玉的分享
宝玉的分享
Latest news
Latest news

Hacker News - Newest: "AI"

AI can't read an investor deck AI as an attorney? Student uses ChatGPT, Gemini to sue UW over alleged racial discrimination Hacking MCP Servers in AI Systems – The Rug Pull: Tool Changes After Approval GitHub - MeepCastana/KubeezCut: Free Web based video editor GitHub - GenAI-Gurus/awesome-eu-ai-act: Curated tools, official sources, OSS, templates, and guides for EU AI Act compliance. Can AI judge journalism? A Thiel-backed startup says yes, even if it risks chilling whistleblowers Coming soon: 10 Things That Matter in AI Right Now DARPA built an AI to fact-check enemy weapons claims What explains heterogeneity in AI adoption? When AI Meets Muscle: Context-Aware Electrical Stimulation Promises a New Way to Guide Human Movements - Department of Computer Science AI Changed How We Build. It Did Not Change What Matters. Linux rules on using AI-generated code - Copilot is OK, but humans must take 'full responsibility for the… Meta spins up AI version of Mark Zuckerberg to engage with employees Code Mode: Let Your AI Write Programs, Not Just Call Tools | TanStack Blog GitHub - Delavalom/graft: Go framework for building AI agents. Type-safe tools, multi-provider (OpenAI, Anthropic, Gemini, Bedrock), zero vendor SDKs. India's TCS tops estimates, says new AI models did not dent services demand Gen Z's fading AI hype Strong feeling: we are in a folded AI reality GitHub - machinarii/total-recall-catalog: A reference catalog of latest knowledge retrieval, memory & RAG systems GitHub - mensfeld/code-on-incus: Give each AI agent its own isolated machine with root, Docker, and systemd. Active defense detects and stops threats automatically.. Quantization, LoRA, and the 8% Problem: Benchmarking Local LLMs for Production AI Iran war: We spoke to the man making Lego-style AI videos that experts say are powerful propaganda Powell, Bessent discussed Anthropic's Mythos AI cyber threat with major U.S. banks GitHub - immartian/bellamem: Persistent belief-graph memory for AI agents. Retrieves decisive context by importance — not recency, not RAG, not /compact. recursive-mode: The Repo-Native Operating System for AI Engineering After the attack on Sam Altman's home, will AI CEO's go on the offensive? The biggest advance in AI since the LLM Opus 4.6 vs GPT 5.4 One Prompt Unity World Generation Test “AI polls” are fake polls Client Challenge Can AI be a 'child of God'? Inside Anthropic's meeting with Christian leaders How to Switch AI Chatbots and Why You Might Want To GitHub - MattMessinger1/agentic_refund_guardrail: Safe refund policy layer for AI agents — Python + TypeScript. Same behavior, shared tests. Adam/papers/emergent_values_whitepaper.md at master · strangeadvancedmarketing/Adam Ask HN: How do you stop playing 20 questions with your AI coding tools How far can automation and AI support psychotherapy? - @theU GitHub - stagas/rtdiff: realtime git diff gui and AI-assisted commits A Mac Studio for Local AI — 6 Months Later A History of the Early Years of AI at the University of Edinburgh Why AI Coding Tools Still Feel Stuck on Localhost MSN AI Datacenters Are Becoming Strategic Targets twitter.com Penn Researchers Use AI to Surface Unreported GLP-1 Side Effects in Reddit Posts Show HN: MoodSense AI (ML and FastAPI and Gradio, Deployed on Hugging Face) Moodsense Ai - a Hugging Face Space by aman179102 AI models are terrible at betting on soccer—especially xAI Grok GitHub - xialeistudio/echoic GitHub - HimashaHerath/github-dev-wrapped: AI-powered weekly GitHub activity reports deployed to GitHub Pages GitHub - alejandrobalderas/claude-code-from-source: Architecture, patterns & internals of Anthropic's AI coding agent — reverse-engineered from source maps AI and Tech brief: Ireland ascendant GitHub - Titovilal/context0: Context0 - Never Surrender Training for a Marathon with an AI Coach: What Worked and What Didn't Cyber Pulse: Agentic Intel - Apps on Google Play I Built an AI PR Reviewer That Catches Bugs by Not Looking for Bugs Gen Z workers are so fearful AI will take their job they’re intentionally sabotaging their company’s AI rollout | Fortune How AI Is Reimagining the Game of Golf–For Both Players and Courses GitHub - nattergabriel/reseed: A CLI tool for managing and distributing agent skills across projects Is SVG the final frontier? My AI workflow evolved from prompts to a near-autonomous workflow MLSharp Help - 3DGS Viewer & Generator I put my cognitive field based AI's runtime on GitHub Is Numble the first AI-proof game? A3: Kubernetes for autonomous AI agent fleets | Emergent Principles Deepali Vyas ("The Elite Recruiter") GitHub - msmarkgu/RelayFreeLLM: A restful API designed to route user prompts to various AI model providers. Unionized ProPublica staff are on strike over AI, layoffs, and wages Unleashing the Advantage of Quantum AI We're heading for an AI-fueled 'dementia crisis,' brain scientist warns The AI-Assisted Breach of Mexico's Government Infrastructure [pdf] GitHub - stef41/lmscan: 🔍 Detect AI-generated text and fingerprint which LLM wrote it. Open-source GPTZero alternative. Zero dependencies, works offline. MSN GitHub - visionscaper/collabmem: Enabling long-term collaboration with Agentic AI - building up episodic and world model memory over time with in-context awareness We gave an AI a 3 year retail lease in SF and asked it to make a profit | Andon Labs AI Code is Hollowing Out Open Source, and Maintainers are Looking the Other Way What leaked "SteamGPT" files could mean for the PC gaming platform's use of AI AI is the boss at this retail store. What could go wrong? GitHub - Wuzu11517/agentic-proxy: Local proxy meant to help reduce With Drones, Geophysics and ArtificiaI Intelligence, Researchers Prepare to Do Battle Against Land Mines A Single Operator, Two AI Platforms, Nine Government Agencies: The Full Technical Report 在 Steam 上购买 FriedrichAI: Offline AI 立省 10% GitHub - inevolin/resume-cli: Hit Claude usage limits? Resume any AI coding session elsewhere. Switch tools at zero friction. GitHub - atripati/ark: AI Runtime Kernel — a context operating system for AI agents. Eliminates tool bloat, loads only what’s needed, and gives LLMs their reasoning space back. How to Build a Secure AI PR Reviewer with Claude, GitHub Actions, and JavaScript This Startup Wants You to Pay Up to Talk With AI Versions of Human Experts Intel Arc Pro B70 Brings 32GB VRAM to Local AI for $949 WordPress 7.0: The Good, the AI, and the Still Missing AI on the couch: Anthropic gives Claude 20 hours of psychiatry IatroBench: Pre-Registered Evidence of Iatrogenic Harm from AI Safety Measures AI Agents Know About Supabase. They Don't Always Use It Right. The history and future of AI at Google, with Sundar Pichai Inside an AI‑enabled device code phishing campaign How Meta Used AI to Map Tribal Knowledge in Large-Scale Data Pipelines AI for Systems: Using LLMs to Optimize Database Query Execution Forecasting the Economic Effects of AI Introducing Tinker: Play with AI, bring your ideas to life AI sheds light on an ancient gaming mystery People really hate AI but not as much as Iran—or Democrats | Fortune What is an AI Product Engineer? Phoebe Gates wants her $185 million AI startup to succeed with 'no ties to my privilege or my last name': 'I have a chip on my shoulder' | Fortune
We built a Custom Transport for Vercel's AI SDK
zknill · 2026-05-13 · via Hacker News - Newest: "AI"

Ably is a realtime messaging platform, it's a pub/sub product where you can publish messages to channels and clients subscribed to those channels will receive those messages in realtime.

It turns out that the Ably realtime platform is really well suited to being the transport that sits between your AI models and the clients receiving the generated responses.

We're trying to meet developers where they currently are, and one of those places is the Vercel AI SDK. So we built a custom transport for the Vercel AI SDK that uses Ably as the transport layer. We want to expose all the features the Ably AI Transport supports to the AI SDK; multi-device, multi-user, resumable streams, human handoff, history compaction, barge-in and interruption, and more.

So this post covers what we managed to support when building against the AI SDK. It was an exercise in trying to make a library do something it wasn't originally designed for.

AI SDK or AI UI SDK?

So the Vercel AI SDK comes in two flavors, the AI SDK to run on the server and the AI UI SDK to run on the client. The UI SDK provides a bunch of react hooks and is where we'd focus most of our efforts.

The main react hook that you need to know about is useChat(...)

const { messages, sendMessage, status } = useChat({
  transport: ablyChatTransport,
});

return (
  <div>
    {messages.map((m) => (
      <div key={m.id}>{m.role}: {m.parts.map(p => p.text).join('')}</div>
    ))}
    <input onKeyDown={(e) => {
      if (e.key === 'Enter') sendMessage({ prompt: e.currentTarget.value });
    }} />
  </div>
);

useChat is the react hook that creates a chatbot interface that you'd expect from an AI assistant. It provides a 'messages' array that contains the messages in the conversation, and a 'sendMessage' function that you can use to send a message to the LLM.

The default transport over SSE

The default transport for the UI SDK is based on HTTP. The client makes an HTTP POST request carrying the user prompt and the conversation history. The client holds the connection open, waiting for an SSE response from the server containing the response tokens.

HTTP is an obvious choice when the SDK was built by a team from Vercel; a serverless app platform based predominately on HTTP.

HTTP streaming SSE is a simple and common design but it falls down when you try and add more advanced features, because:

  • It's not multi-device. If you have the chat open on your phone and your laptop, only one of those devices will receive the response.
  • It's not multi-user. If you have multiple users chatting with the same bot, they won't see each other's messages or responses.
  • It's not really resumable. SSE has lastEventId which technically supports resume, but that only works if your server stores the individual SSE events and can replay them on reconnect. Most don't in practice. And if the user refreshes the page, the connection is gone and there's no way to pick up where you left off.
  • Cancellation sucks. The HTTP SSE stream isn't bidirectional, so cancellation means closing the HTTP connection entirely. Even the SDK's own stop() function is broken. It fires the abort signal but returns immediately without waiting for the stream to terminate, so buffered chunks keep arriving after you've supposedly stopped. There's also an open issue where stop() returns, the UI status stays streaming, and the server keeps generating tokens until completion. No barge-in or interruption support either.
  • There's no history, you need to build that separately.
  • There's no automatic compaction of tokens into full responses.

These are real problems that folks have encountered, the SDK has open issues for losing partial messages on stream errors and failing to resume streams mid-response.

These are all features that are fully supported by the Ably transport, but aren't easily supported in HTTP based SSE responses.

The UI SDK exposes this transport using a ChatTransport interface, with the methods:

  • sendMessages() (send a prompt, return a stream of response chunks)
  • reconnectToStream() (resume after disconnect), 

Implement these and you can swap out the default HTTP transport for anything.

useChat assumes one request and one response

The biggest issue we had when building the custom transport was that useChat was designed around a single-request single-response flow. It assumes that for every message you send, you get one response back. This is a problem because the Ably transport is designed to support multiple responses for a single message and multiple users participating in a single conversation.

useChat's state machine expects a series of chunks in response to a single user prompt.

User sends: "What is pub/sub?"

useChat reads these chunks from the stream returned by sendMessages():

  { type: 'step-start' }
  { type: 'text-start',  id: 'text-1' }
  { type: 'text-delta',  id: 'text-1', delta: 'Pub/sub is ' }
  { type: 'text-delta',  id: 'text-1', delta: 'a messaging pattern ' }
  { type: 'text-delta',  id: 'text-1', delta: 'where publishers send...' }
  { type: 'text-end',    id: 'text-1' }
  { type: 'step-finish', finishReason: 'stop' }
  { type: 'finish' }

status:  ready → submitted → streaming → ready

Each chunk is either a control message like start or finish, or a content message like text-delta containing tokens from the LLM response.

The single request single response assumption in useChat is obviously an issue if you want to support multiple users in the same conversation, because only one of those users has sent the prompt, but the prompt and response should be fanned out to all the users in the conversation.

Internally, useChat tracks one activeResponse at a time. If two messages are sent concurrently, the second overwrites the first, the onFinish lifecycle hook fires once instead of twice, and you can end up crashing on undefined state. The community has asked for multi-message streaming but there's no support for it yet.

useChat's setMessages(...) backdoor

Sharing the conversation state between multiple users is easy over Ably channels, but updating that state in useChat is hard because of the single request single response design.

But useChat has a secret weapon, a setMessages(...) function that you can use to set the messages state directly. This is a backdoor that allows you to bypass the state machine and set the conversation state to whatever you want.

This is what we ended up doing, we used setMessages(...) to set the message state directly, with the full conversation no matter which user sent the prompt. This allowed us to support multi-user conversations.

The problem with this approach is that setMessages(...) completely bypasses the state machine, which immediately breaks a lot of the built-in features of useChat like lifecycle hooks and tool-call notifications.

Building around the limitations

Sometimes you just have to do the best with what you've got, and what we've got is a square peg and a round hole. useChat was never designed to support the kinds of features we're trying to add to it. So we built around the limitations by tracking 'own-turns' (i.e. prompts submitted by this client, and the LLM response to that prompt) and 'observer-turns' (i.e. prompts submitted by other clients, and the response).

Own-turns can trigger the full lifecycle, they go through the regular sendMessages(...) flow in useChat and process lifecycle hooks and tool-calls as normal.

Observer-turns are set directly with setMessages(...) and bypass the lifecycle hooks and tool-call notifications, but at least they show up in the conversation for all users. We also have to temporarily buffer observer-turns if there's currently an own-turn in progress, because the state machine doesn't support interleaving messages from multiple responses.

So what extra can you do with useChat and the Ably transport?

Actually quite a lot, the Ably transport can add these features to useChat:

  • Multi-device with automatic fan out
  • Multi-user conversations, with more than one user submitting prompts and receiving responses in the same conversation.
  • Resumable streams, if you lose your connection you can reconnect and receive the rest of the response automatically.
  • Human handoff, you can have a human take over the conversation at any time and respond to the user prompts because we already have multi-user support.
  • Interruptions, cancellation, barge-in, you can interrupt or steer the LLM conversation at any time by sending a new prompt, even if the previous response hasn't finished yet. This is possible because the Ably transport uses channels, and channels are a bi-directional streaming layer.
  • History compaction, the tokens from LLM responses are automatically compacted together into a single message in the conversation history, so live clients receive tokens progressively in realtime, but new clients joining the conversation later receive the full response in one message.

There's a whole bunch more to the Ably AI Transport than we have talked about here. But even with the limitations of useChat, just changing from an HTTP transport to the Ably transport you can unlock a whole bunch of extra features like multi-device, multi-user, resumable streams, human handoff, interruptions, and history compaction.

If you don't want to be constrained by useChat at all, the Ably AI Transport SDK also provides useClientTransport and useView — react hooks that give you direct access to the transport and the conversation tree without going through useChat's state machine. You still get the Vercel AI SDK's stream format, but you're not fighting the single-response assumptions. Check out our AI Transport SDK if you're interested.