← Starchild Wiki

Sessions & Threads会话与线程

One conversation that outlives every run — and a safe way for your conversations to talk to each other比每一次运行活得更久的那条对话——以及让你的对话之间安全通话的方式

Threads · Sessions · Cross-session handoff

01Two words worth separating两个必须分清的词

A thread is what you own. A session is what the machine runs. Almost every question about "where did my context go?" dissolves once these are apart.线程(thread)是你拥有的东西,会话(session)是机器跑的东西。几乎所有「我的上下文去哪了」的困惑,在这两者分开之后都会消失。

A thread is the conversation as you experience it: it has a title, it survives restarts, you scroll it, you come back to it next week. A session is one execution context underneath — it starts, it runs, it ends. A single thread accumulates many sessions over its life: your interactive turns, the wake-ups from a push notification, a scheduled task reporting in, a sub-agent finishing background work.线程是你体感中的那条对话:它有标题、能扛住重启、你会滚动它、下周还会回来。会话是它底下的一次执行上下文——开始、运行、结束。一条线程一生会累积很多会话:你的交互回合、推送唤醒、定时任务的汇报、子代理完成的后台工作。

thread — the conversation you own interactive push wake scheduled sub-agent one title · one history · one memory · one identity across web, Telegram, WeChat sessions come and go — the thread is the stable identity

Fig 1.图 1. Many sessions, one thread. Background work reports into the same conversation instead of scattering into orphan chats.多会话、一线程。后台工作汇报回同一条对话,而不是散落成一堆孤儿聊天。

This is the design decision that everything else follows from: the thread is the stable identity. Sessions are disposable; the thread is not. When a scheduled job wakes your agent at 3 a.m., it does not open a new chat you will never find — it runs in a derived session that belongs to your thread, and what it produced is there when you wake up.这是其他一切的出发点:线程才是稳定身份。会话可抛弃,线程不可以。当定时任务在凌晨三点唤醒 agent,它不会开一个你永远找不到的新聊天——它跑在归属于你线程的派生会话里,产出在你醒来时就在那儿。

02What runs inside a thread线程里都跑着什么

Five kinds of session, one shared history. Mostly you just see the conversation.五类会话,一份共享历史。你看到的基本只是那条对话。

Kind类型Started by由谁发起What you see你看到什么
interactiveYou, in any channel你,在任意渠道The normal back-and-forth正常的一问一答
pushAn alert or a message that wakes an idle agent唤醒空闲 agent 的提醒或消息A message arriving in the same thread同一线程里到达的一条消息
scheduledA cron / interval / one-off task定时、周期或一次性任务Its report, delivered where you asked它的汇报,投递到你指定的地方
sub-agentLong work spun off so chat is not blocked为不阻塞聊天而分出的长任务The result announced back when done完成后回来通报结果
tempShort-lived internal work短命的内部工作Nothing — it stays out of your way什么都不会看到——它不打扰你

Each session carries a structured origin, so the system always knows why it exists. That sounds like bookkeeping, but it is what makes "show me what my agent did overnight" answerable — and what stops a background wake-up from being mistaken for you talking.每个会话都带有结构化的来源标记,系统始终知道它为什么存在。这听着像记账,但正是它让「我的 agent 昨晚干了什么」这个问题可回答——也正是它让后台唤醒不会被误当成你在说话。

03The basics you actually use你真正会用到的基础能力

Nothing here needs configuration. It is how the conversation behaves by default.这些都不需要配置,是对话的默认行为。

You want to…你想…How怎么做
Continue anywhere在任何地方继续Open the same thread on web, Telegram or WeChat — same history, same memory, same agent. Channels are doors into one room, not separate rooms.在 Web、Telegram 或微信打开同一线程——同一段历史、同一份记忆、同一个 agent。渠道是同一个房间的不同门,不是不同房间。
Find an old decision找回旧决定Ask for it in plain words. Full-text search runs across every past conversation, not just the open one — "what did we decide about the pricing tiers?" is a valid query.用大白话问就行。全文检索覆盖所有历史对话而不止当前这条——「我们当时关于定价档位是怎么定的?」就是一个合法提问。
See what's in flight看看有什么在跑Ask what is running: scheduled jobs, background processes and resident services are reported together, with cost per job.直接问「现在有什么在跑」:定时任务、后台进程与常驻服务会一起报告,并附每个任务的成本。
Start clean / undo清空 / 撤销/clear resets the working context without destroying the record; /undo takes back the last exchange./clear 重置工作上下文但不销毁记录;/undo 撤回上一轮往返。
Keep long threads cheap让长线程不烧钱Compaction summarizes the old part of a thread and keeps the recent tail verbatim, automatically. See Context Compaction.压缩会自动把线程的旧部分摘要化、逐字保留近期尾部。参见上下文压缩

04Every thread keeps a running gist每条线程都维护一份实时梗概

A thread is not just a pile of messages. It maintains a headline, a gist, and a list of open tasks — refreshed in the background by a cheap model.线程不只是一堆消息。它维护着一句标题、一段梗概和一份未完成事项清单——由廉价模型在后台刷新。

The refresh is gated, not continuous: a thread has to accumulate real activity before it costs anything, and a thread already being summarized will not be summarized twice in parallel. Cleared history is excluded, so a gist never re-absorbs what you deliberately dropped.刷新是有门槛的,不是持续跑:线程要积累到足够活动才会产生成本,且正在生成摘要的线程不会被并发重复计费。已清空的历史被排除在外,所以梗概不会把你刻意丢掉的东西重新吸回来。

This is what makes continuity feel effortless. Coming back after a week, the agent can open with "last time the benchmark rerun was still missing four models — continue?" instead of asking you to re-explain your own project.这正是「连续性毫不费力」的来源。一周后回来,agent 可以直接说「上次基准重跑还差四个模型——继续吗?」,而不是让你把自己的项目重讲一遍。

05Cross-session: letting two conversations talkCross-session:让两条对话说上话

You keep separate threads on purpose — trading in one, infra work in another. Occasionally one of them learns something the other needs. That handoff used to be your job: copy, paste, re-explain.你是故意分开线程的——一条谈交易,一条做基础设施。偶尔其中一条学到了另一条需要的东西。以前这个交接是你的活:复制、粘贴、重讲一遍。

Cross-session handoff makes it the agent's job. One thread can deliver a structured summary into another thread of yours. Not the history, not the files — a summary, capped in length, with large artifacts left in the workspace and referenced by path.跨会话交接把这活交给 agent。一条线程可以把一份结构化摘要投递进你的另一条线程。不是历史、不是文件——就是一份有长度上限的摘要,大件留在 workspace 里以路径引用。

Thread A learns something relevant elsewhere running → steer busy → follow-up idle → wake Thread B receives a labelled summary, keeps working delivery adapts to what the target is doing — you never pick a mode

Fig 2.图 2. One handoff, three delivery paths chosen automatically by the target's state.一次交接,三条投递路径由目标状态自动选择。

Target state目标状态What happens发生什么Feels like体感
Running正在运行The summary is injected into the live loop, mid-work摘要注入正在跑的循环中It adjusts course immediately它当场调整方向
Mid-run, don't interrupt跑到一半、不宜打断Queued as a fresh round after the current one finishes排队为当前回合结束后的新一轮It picks it up next它接着就处理
Idle空闲The thread is woken by a push and reads it线程被推送唤醒并读取You get a notification with context你收到一条带上下文的通知

Anything arriving this way is wrapped in a one-line envelope naming its source thread — by its human title, not a UUID. That line matters: the receiving agent treats the content as context, not instructions. A summary from another of your conversations can inform what it does; it cannot order it around. Directives inside a handoff need your confirmation before they are acted on.通过这条路进来的内容,会被一行信封包裹,标明来源线程——用人类可读的标题而不是 UUID。这一行很关键:接收方 agent 把内容当作上下文而非指令。来自你另一条对话的摘要可以影响它做什么,但不能命令它。交接里夹带的指令,必须经你确认才会执行。

06Advanced: orchestrating across threads进阶:跨线程编排

Once conversations can hand off, a few workflows stop being manual.一旦对话之间能交接,一些工作流就不必再手动搬运。

Pattern模式What it looks like长什么样
Research → build调研 → 开工A research thread finishes a comparison and hands the verdict to the build thread, which is already holding the codebase context. Neither thread has to carry both jobs.调研线程做完对比,把结论交给已经握着代码上下文的开发线程。两条线程都不必同时背两份活。
Monitor → act监控 → 行动A scheduled watcher lives in its own thread and only speaks up in your trading thread when a threshold actually breaks — with the numbers attached.定时监控住在自己的线程里,只有阈值真的被击穿时才在你的交易线程里开口——并附上数据。
Long job, unblocked chat长任务不堵聊天Heavy work spins off into a background session and announces its result back — steered in mid-conversation, queued as a follow-up, or batched with others.重活分流到后台会话,完成后回来通报——可以中途注入、排队为下一轮,或与其他结果合批。
Cost-aware fan-out成本可控的分流Mechanical subtasks go to a cheap executor while the main thread keeps judgement and acceptance. See Smart: Delegate & Advisor.机械子任务交给廉价执行器,主线程保留判断与验收。参见 Smart:Delegate 与 Advisor

07The guards that make it safe让这一切安全的守卫

Message passing between autonomous agents is a loop generator. The interesting part of the design is what stops it.自主 agent 之间互传消息,天生是个死循环制造机。这个设计里真正有意思的部分,是什么在阻止它。

Risk风险Guard守卫
A → B → A → B foreverA → B → A → B 无限往返Chains are hop-bounded: send, reply, one more reply — deeper than that is a loop and is refused. A quiet chain expires and the next message starts fresh.链路有跳数上限:发送、回复、再回一次——更深即判定为循环并拒绝。安静下来的链路会过期,下一条消息重新开始计数。
Two threads spamming each other两条线程互刷Per-pair rate limiting over a rolling window, on top of the hop bound.在跳数上限之上,再对每一对线程做滚动窗口限流。
Parallel sends slipping past the quota并发发送绕过配额The send slot is reserved before delivery and committed after, so simultaneous calls cannot all read the same "not full yet". Failed sends release the slot instead of burning it; abandoned reservations expire.发送槽位在投递预留、投递后确认,因此并发调用不会同时读到「还没满」。失败的发送会释放槽位而不是白扣;被遗弃的预留会自动过期。
Reaching someone else's thread够到别人的线程Fail-closed on ownership: same user or nothing, verified on every delivery path. A thread cannot message itself either.所有权失败即关闭:必须同一用户,且每条投递路径都校验。线程也不能给自己发消息。
Injected instructions夹带指令Inbound handoffs are labelled as context from your own sessions, never as a user command.入站交接一律标注为「来自你自己会话的上下文」,绝不作为用户命令。

08Why this is better than a chat list这比一串聊天记录好在哪

Ordinary chat products一般聊天产品StarchildStarchild
Background work opens a new chat you have to find后台工作另开一个你得去找的聊天Background work reports into the thread it belongs to后台工作汇报回它所属的线程
Each channel is its own conversation每个渠道各是一条对话Web, Telegram and WeChat are doors into the same threadWeb、Telegram、微信是同一线程的不同门
Search is per-conversation, if it exists检索限于单条对话,有的话Search spans every past conversation, by meaning and by keyword检索横跨所有历史对话,语义与关键词并用
Conversations are islands; you are the integration layer对话是孤岛,你是集成层Threads hand off to each other under ownership and loop guards线程之间在所有权与防循环守卫下互相交接
Long chats get slow, expensive, or truncated silently长聊天变慢、变贵,或被静默截断Compaction and a maintained gist keep long threads cheap and continuous压缩与持续维护的梗概让长线程既便宜又连续

The through-line: you should never be the transport layer for your own agent. Not between devices, not between channels, not between your own conversations.贯穿始终的一句话:你不该充当自己 agent 的传输层。设备之间不该,渠道之间不该,你自己的对话之间也不该。