How-toSelected

Main Session + Thread pattern cuts agent token costs

Why we picked it

The counterintuitive point is that the strongest model belongs in the worker threads, not the coordinator — inverting how many developers set up agent pipelines. Builders deploying long-running bots on metered APIs can adopt the cache-expiry compaction trick immediately to lower costs without changing models. Compared with naive single-session designs, it trades a retrieval step for large savings on context re-sends, useful for teams in cost-sensitive ASEAN markets where API spend adds up fast.

Dotey (Beiji) shared a workflow pattern on X for reducing token consumption in agent interactions: split work into a main session plus separate threads. The main session handles triage and routing rather than heavy reasoning, so a mid-tier model like Sonnet 5.5 suffices; tasks are delegated to threads, which run stronger models such as Opus 5.5. In his Claude Project setup, the main session uses Sonnet 5.5 while subtasks run on Opus 5.5.

Body

The token savings come mainly from smarter cache handling. Main sessions receive occasional messages, so cache expires between turns; instead of resending full history and tool calls, he sends only the latest few messages and reconstructs context via session retrieval tools. Threads behave like traditional concentrated sessions with high cache hit rates, and the best practice is to compact the context near cache expiry — around 50 minutes if the cache lasts an hour. An even more refined approach is letting the main session pick the model per task difficulty.

For developers running bot-style agents where a single main session burns through usage quotas quickly, this architecture directly affects API costs. The pattern applies to any provider with prompt caching and multi-model tiers, including Anthropic's Claude family.

Original · 宝玉

主会话 + Thread 的模式,优化好的话 Token 消耗其实还好。 首先主会话反而不需要特别强的模型,Sonnet 5.5 这个级别都够用了,因为它的主要职责是甄别和路由,或者说调度。 就跟公司前台一样,你不需要招一个专家,只要知道什么任务该找谁。 主会话里面很多任务都可以让 Thread 去完成,反倒是 Thread 应该用相对强一些的模型。当然更科学的办法是主会话在调度的时候根据任务难度去选择合适的模型。 比如我在用 Claude Project 的时候,主会话是 Sonnet 5.5,子任务是 Opus 5.5。 另外就是 Prompt Caching 的利用。 像主会话这种,特点是偶尔来个消息,很难利用好缓存,所以缓存如果过期了,不应该跟把所有历史会话和工具调用都发过去,而是只把最新的几条消息记录发过去,再配合 Session 的检索工具,可以很容易的收集齐上下文。 而对于 Thread,则是像传统的 Session 会话,会集中时间有很多对话,通常 Cache 利用率很高,但是也可能会出现缓存过期后又来新的消息,所以最佳策略是在缓存快过期的时候,比如 50 分钟(如果缓存一个小时的话)的时候,压缩一下上下文。 Gary Zhang @GaryZhang124 问题是,Grok bot这个如果走单主会话的交互太耗额度了。 x.com/dotey/status/2… 🔗 View Quoted Tweet📊 5 ⚡

Industry Coordinates & Source Verification

This report is categorized under AITOP's "How-to" desk, focusing on China's AI industry and domestic foundation model ecosystem. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows and US-China foundation model benchmarks and commercialization comparison. Key entities and technical topics under continuous tracking include Claude, Prompt Caching, agents, context management.

Source attribution: curated from 宝玉 (@dotey).