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

推荐订阅源

O
OpenAI News
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
博客园 - 三生石上(FineUI控件)
美团技术团队
博客园 - 叶小钗
博客园 - 司徒正美
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
博客园 - 聂微东
博客园 - 【当耐特】
罗磊的独立博客
月光博客
月光博客
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
小众软件
小众软件
P
Privacy International News Feed
V
V2EX
T
The Exploit Database - CXSecurity.com
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
A
Arctic Wolf
T
Threatpost
博客园 - Franky
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
H
Hacker News: Front Page
雷峰网
雷峰网
C
Cybersecurity and Infrastructure Security Agency CISA
J
Java Code Geeks
P
Palo Alto Networks Blog
H
Heimdal Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
The Last Watchdog
The Last Watchdog
T
Tor Project blog
爱范儿
爱范儿
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
C
Cisco Blogs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
腾讯CDC
V
Visual Studio Blog
S
Schneier on Security
大猫的无限游戏
大猫的无限游戏
T
Threat Research - Cisco Blogs

Chat SDK Documentation

Teams Low-Level APIs | Chat SDK CLI | Chat SDK Platform Adapters | Chat SDK Cards | Chat SDK Getting Started | Chat SDK Introduction | Chat SDK Modals | Chat SDK Slack Low-Level APIs | Chat SDK Streaming | Chat SDK Testing | Chat SDK Overview | Chat SDK toAiMessages | Chat SDK Cards | Chat SDK Overview | Chat SDK Markdown | Chat SDK Modals | Chat SDK AI SDK Tools | Chat SDK Types | Chat SDK Message Subject | Chat SDK Conversation History | Chat SDK Transcripts | Chat SDK Slack bot with Next.js and Redis Actions | Chat SDK Direct Messages | Chat SDK Emoji | Chat SDK Error Handling | Chat SDK File Uploads | Chat SDK Handling Events | Chat SDK Posting Messages | Chat SDK Slash Commands | Chat SDK State Adapters | Chat SDK Threads, Messages, and Channels | Chat SDK Creating a Chat Instance | Chat SDK WhatsApp Business Cloud Channel | Chat SDK Chat | Chat SDK Platform Adapters | Chat SDK Overlapping Messages | Chat SDK Ephemeral Messages | Chat SDK Message | Chat SDK Thread | Chat SDK Building a community adapter | Chat SDK Documenting your adapter | Chat SDK Publishing your adapter | Chat SDK Testing adapters | Chat SDK Code review GitHub bot with Hono and Redis Discord support bot with Nuxt and Redis Durable chat sessions with Next.js, Workflow, and Redis Schedule Slack posts with Next.js, Workflow, and Neon PostableMessage | Chat SDK
State Adapters | Chat SDK
Vercel · 2026-06-09 · via Chat SDK Documentation

Pluggable state adapters for thread subscriptions, distributed locking, and caching.

State adapters handle persistent storage for thread subscriptions, distributed locks (to prevent duplicate processing), and caching. You must provide a state adapter when creating a Chat instance. Browse all available state adapters on the Adapters page.

Thread subscriptions

When your bot calls thread.subscribe(), the state adapter persists that subscription. On subsequent webhooks, the SDK checks subscriptions to route messages to onSubscribedMessage handlers. With a production adapter, subscriptions survive restarts and work across multiple instances.

Distributed locking

When a webhook arrives, the SDK acquires a lock on the thread to prevent duplicate processing. This is critical for serverless deployments where multiple instances may receive the same event.

By default, if a lock is already held, the incoming message is dropped with a LockError. For long-running handlers (e.g. AI agent streaming), you can configure onLockConflict: 'force' to force-release the existing lock and allow the new message through:

const chat = new Chat({
  userName: 'my-bot',
  adapters: { slack },
  state: createRedisState(),
  onLockConflict: 'force',
});

You can also pass a callback for custom logic:

onLockConflict: (threadId, message) => {
  return message.text.includes('stop') ? 'force' : 'drop';
}

Note that force-releasing a lock does not cancel the previous handler — it continues running. Only the lock is released, so two handlers may briefly run concurrently on the same thread.

Caching

State adapters provide key-value storage with TTL for thread state (thread.setState()), message deduplication, and other internal caching.