Skip to content

Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.

TypeScript

feat(observability): show how often a wake produced nothing

Xialie Zhuangf483d0d2fb0c
diff --git a/src/api/client.ts b/src/api/client.ts
index cbfadd3..193e220 100644
--- a/src/api/client.ts
+++ b/src/api/client.ts
@@ -456,6 +456,24 @@ export interface ApiTriagePriceRow {
estimated: boolean
}
+/** One row of `GET /agents/observability/wakes`. Group and direct are kept
+ * apart deliberately: a DM legitimately answers far more often, so averaging
+ * the two hides the number that matters. */
+export interface ApiSilentWakeBucket {
+ conversationKind: string
+ runs: number
+ silentRuns: number
+ silentRate: number
+ silentSpendUsd: number
+}
+
+export interface ApiWakeEconomics {
+ sinceHours: number
+ buckets: ApiSilentWakeBucket[]
+ /** The RATIOS are measured either way; only the dollar column is modelled. */
+ costEstimated: boolean
+}
+
export interface ApiTriageEconomics {
sinceHours: number
triageCount: number
@@ -1265,6 +1283,13 @@ export const api = {
const suffix = q.toString() ? `?${q.toString()}` : ''
return http<ApiTriageEconomics>(`/agents/observability/triage${suffix}`)
},
+ getWakeEconomics: (filters?: { agentId?: string | null; sinceHours?: number }) => {
+ const q = new URLSearchParams()
+ if (filters?.agentId) q.set('agentId', filters.agentId)
+ if (filters?.sinceHours) q.set('sinceHours', String(filters.sinceHours))
+ const suffix = q.toString() ? `?${q.toString()}` : ''
+ return http<ApiWakeEconomics>(`/agents/observability/wakes${suffix}`)
+ },
getDevtoolsCapabilities: () => http<ApiDevtoolsCapabilities>('/devtools/capabilities'),
listAgentWorkspace: (agentId: string) =>
http<ApiAgentWorkspaceFile[]>(`/devtools/agent-workspace?agentId=${encodeURIComponent(agentId)}`),
diff --git a/src/desktop/ObservabilityView.tsx b/src/desktop/ObservabilityView.tsx
index 13799b5..3bfdb35 100644
--- a/src/desktop/ObservabilityView.tsx
+++ b/src/desktop/ObservabilityView.tsx
@@ -7,6 +7,7 @@ import {
type ApiAgentWorkspaceFile,
type ApiAgentWorkspaceFileContent,
type ApiTriageEconomics,
+ type ApiWakeEconomics,
} from '@/api/client'
import { Checkbox } from '@/components/Checkbox'
import { Select } from '@/components/Select'
@@ -18,9 +19,9 @@ import { useT, type MessageKey } from '@/lib/i18n'
import { cn } from '@/lib/utils'
type StatusFilter = ApiAgentRunStatus | 'all'
-type DevPanel = 'traces' | 'workspace' | 'triage'
-const DEV_PANELS: DevPanel[] = ['traces', 'workspace', 'triage']
-const PANEL_LABEL_KEY: Record<DevPanel, MessageKey> = { traces: 'obs.panelTraces', workspace: 'obs.panelWorkspace', triage: 'obs.panelTriage' }
+type DevPanel = 'traces' | 'workspace' | 'triage' | 'wakes'
+const DEV_PANELS: DevPanel[] = ['traces', 'workspace', 'triage', 'wakes']
+const PANEL_LABEL_KEY: Record<DevPanel, MessageKey> = { traces: 'obs.panelTraces', workspace: 'obs.panelWorkspace', triage: 'obs.panelTriage', wakes: 'obs.panelWakes' }
const TRIAGE_WINDOWS: { hours: number; key: MessageKey }[] = [
{ hours: 6, key: 'obs.window6h' }, { hours: 24, key: 'obs.window24h' }, { hours: 72, key: 'obs.window3d' }, { hours: 168, key: 'obs.window7d' },
]
@@ -689,6 +690,174 @@ function PriceMenuTable({ rows }: { rows: { model: string; inPer1M: number; cach
/** The triage cost-effectiveness ledger — a self-contained full-width panel.
* Answers the user's question: is the small-brain gate actually saving money,
* given triage is always cold (uncached) while big-brain turns are cache-warm? */
+/** How often a wake produced nothing.
+ *
+ * The triage panel answers "was the cheap brain worth it". This one answers
+ * the question behind #70: a group message wakes every member, each pays the
+ * big brain to read the same room, and most conclude it was not theirs. The
+ * server has measured that since #93; until now the number had no surface, so
+ * "did the routing change help" was an argument rather than a reading.
+ *
+ * Group and direct are never averaged — a DM legitimately answers far more
+ * often, and blending the two hides the only rate worth acting on. */
+function WakeEconomicsPanel(props: {
+ panel: DevPanel
+ setPanel: (p: DevPanel) => void
+ agents: { id: string; name: string }[]
+ agentId: string
+ setAgentId: (v: string) => void
+ hours: number
+ setHours: (n: number) => void
+ data: ApiWakeEconomics | null
+ loading: boolean
+ err: string | null
+ onRefresh: () => void
+}) {
+ const t = useT()
+ const { data } = props
+ const buckets = data?.buckets ?? []
+ const totals = buckets.reduce(
+ (acc, b) => ({
+ runs: acc.runs + b.runs,
+ silentRuns: acc.silentRuns + b.silentRuns,
+ spend: acc.spend + b.silentSpendUsd,
+ }),
+ { runs: 0, silentRuns: 0, spend: 0 },
+ )
+ const group = buckets.find((b) => b.conversationKind === 'group')
+ return (
+ <main className="flex h-full min-h-0 flex-col overflow-hidden bg-paper">
+ <div className="border-b border-ink-100 px-6 py-4">
+ <div className="flex items-start justify-between gap-3">
+ <div>
+ <h1 className="font-display text-[25px] font-medium tracking-tight text-ink-900">{t('obs.wakesTitle')}</h1>
+ <div className="mt-1 text-[12px] text-ink-500">{t('obs.wakesSubtitle')}</div>
+ </div>
+ <RefreshButton loading={props.loading} onClick={props.onRefresh} />
+ </div>
+ <div className="mt-4 flex flex-wrap items-end gap-3">
+ <div className="grid grid-cols-4 gap-1 rounded-[11px] border border-ink-100 bg-cloud p-1">
+ {DEV_PANELS.map((item) => (
+ <button
+ key={item}
+ onClick={() => props.setPanel(item)}
+ className={cn(
+ 'rounded-[8px] px-3 py-2 text-[12px] font-semibold transition',
+ props.panel === item ? 'bg-sky2-50 text-skype-deep shadow-soft' : 'text-ink-500 hover:text-ink-700',
+ )}
+ >
+ {t(PANEL_LABEL_KEY[item])}
+ </button>
+ ))}
+ </div>
+ <label className="text-[10.5px] font-bold uppercase tracking-[0.12em] text-ink-400">
+ {t('obs.agent')}
+ <Select
+ value={props.agentId}
+ onValueChange={props.setAgentId}
+ options={[{ value: 'all', label: t('obs.allAgents') }, ...props.agents.map((a) => ({ value: a.id, label: a.name }))]}
+ className="mt-1 w-44 normal-case tracking-normal"
+ />
+ </label>
+ <label className="text-[10.5px] font-bold uppercase tracking-[0.12em] text-ink-400">
+ {t('obs.window')}
+ <Select<string>
+ value={String(props.hours)}
+ onValueChange={(v) => props.setHours(Number(v))}
+ options={TRIAGE_WINDOWS.map((w) => ({ value: String(w.hours), label: t(w.key) }))}
+ className="mt-1 w-24 normal-case tracking-normal"
+ />
+ </label>
+ </div>
+ </div>
+
+ {props.err && (
+ <div className="mx-6 mt-4 rounded-[10px] bg-coral-soft px-3 py-2 text-[12px] text-coral-deep">{props.err}</div>
+ )}
+
+ <div className="min-h-0 flex-1 overflow-auto px-6 py-5">
+ {!data ? (
+ <div className="grid h-full place-items-center text-[13px] text-ink-400">{props.loading ? t('common.loading') : t('common.noData')}</div>
+ ) : totals.runs === 0 ? (
+ <div className="mx-auto max-w-[1100px] rounded-[10px] border border-ink-100 bg-cloud px-3.5 py-3 text-[12px] leading-[1.6] text-ink-500">
+ {t('obs.wakesNoData')}
+ </div>
+ ) : (
+ <div className="mx-auto max-w-[1100px] space-y-5">
+ {/* Only the dollars are modelled; the rates come from stored token
+ counts and real message timings. Say which is which. */}
+ {data.costEstimated && (
+ <div className="rounded-[10px] border border-coral-soft bg-coral-soft px-3.5 py-2.5 text-[11.5px] leading-[1.6] text-coral-deep">
+ {t('obs.wakesEstimateWarn')}
+ </div>
+ )}
+
+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
+ <StatCard
+ label={t('obs.statSilentRate')}
+ value={totals.runs > 0 ? fmtPct(totals.silentRuns / totals.runs) : '—'}
+ tone={totals.silentRuns / Math.max(1, totals.runs) > 0.3 ? 'warn' : undefined}
+ sub={t('obs.statSilentRateSub', { silent: totals.silentRuns, runs: totals.runs })}
+ />
+ <StatCard
+ label={t('obs.statSilentGroup')}
+ value={group && group.runs > 0 ? fmtPct(group.silentRate) : '—'}
+ tone={group && group.silentRate > 0.3 ? 'warn' : undefined}
+ sub={t('obs.statSilentGroupSub', { runs: group?.runs ?? 0 })}
+ />
+ <StatCard
+ label={t('obs.statSilentSpend')}
+ value={fmtUsd(totals.spend)}
+ tone={totals.spend > 0 ? 'neg' : undefined}
+ sub={t('obs.statSilentSpendSub')}
+ />
+ <StatCard
+ label={t('obs.statWakeRuns')}
+ value={String(totals.runs)}
+ sub={t('obs.statWakeRunsSub', { hours: data.sinceHours })}
+ />
+ </div>
+
+ <div className="rounded-[10px] border border-ink-100 bg-paper px-3.5 py-3">
+ <div className="text-[9.5px] font-bold uppercase tracking-[0.12em] text-ink-300">{t('obs.wakesByKind')}</div>
+ <table className="mt-2 w-full text-[11.5px]">
+ <thead className="text-[9px] font-bold uppercase tracking-[0.1em] text-ink-400">
+ <tr>
+ <th className="py-1 text-left">{t('obs.colKind')}</th>
+ <th className="py-1 text-right">{t('obs.colWakes')}</th>
+ <th className="py-1 text-right">{t('obs.colSilent')}</th>
+ <th className="py-1 text-right">{t('obs.colSilentRate')}</th>
+ <th className="py-1 text-right">{t('obs.colSilentSpend')}</th>
+ </tr>
+ </thead>
+ <tbody className="divide-y divide-ink-100">
+ {buckets.map((b) => (
+ <tr key={b.conversationKind}>
+ <td className="py-1">
+ <span className={cn(
+ 'rounded-full px-1.5 py-0.5 text-[9px] font-bold uppercase',
+ b.conversationKind === 'group' ? 'bg-sky2-50 text-skype-deep' : 'bg-ink-100 text-ink-600',
+ )}>
+ {b.conversationKind === 'group' ? t('obs.kindGroup') : t('obs.kindDirect')}
+ </span>
+ </td>
+ <td className="py-1 text-right tabular-nums text-ink-600">{b.runs}</td>
+ <td className="py-1 text-right tabular-nums text-ink-600">{b.silentRuns}</td>
+ <td className="py-1 text-right tabular-nums text-ink-700">{fmtPct(b.silentRate)}</td>
+ <td className="py-1 text-right tabular-nums text-ink-600">{fmtUsd(b.silentSpendUsd)}</td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ <div className="mt-2.5 text-[11px] leading-[1.6] text-ink-500">{t('obs.wakesFootnote')}</div>
+ </div>
+ </div>
+ )}
+ </div>
+ </main>
+ )
+}
+
function TriageEconomicsPanel(props: {
panel: DevPanel
setPanel: (p: DevPanel) => void
@@ -718,7 +887,7 @@ function TriageEconomicsPanel(props: {
<RefreshButton loading={props.loading} onClick={props.onRefresh} />
</div>
<div className="mt-4 flex flex-wrap items-end gap-3">
- <div className="grid grid-cols-3 gap-1 rounded-[11px] border border-ink-100 bg-cloud p-1">
+ <div className="grid grid-cols-4 gap-1 rounded-[11px] border border-ink-100 bg-cloud p-1">
{DEV_PANELS.map((item) => (
<button
key={item}
@@ -934,9 +1103,12 @@ export function ObservabilityView() {
const [workspaceLoading, setWorkspaceLoading] = useState(false)
const [workspaceErr, setWorkspaceErr] = useState<string | null>(null)
const [triage, setTriage] = useState<ApiTriageEconomics | null>(null)
+ const [wakes, setWakes] = useState<ApiWakeEconomics | null>(null)
const [triageHours, setTriageHours] = useState(24)
const [triageLoading, setTriageLoading] = useState(false)
const [triageErr, setTriageErr] = useState<string | null>(null)
+ const [wakesLoading, setWakesLoading] = useState(false)
+ const [wakesErr, setWakesErr] = useState<string | null>(null)
// Tree state: which folder paths are expanded. New file lists default to
// every folder open (most agents have <20 files, flat-feeling is right).
const [expandedFolders, setExpandedFolders] = useState<Set<string>>(new Set())
@@ -1036,6 +1208,22 @@ export function ObservabilityView() {
if (panel === 'workspace') void loadWorkspaceFiles()
}, [loadWorkspaceFiles, panel])
+ const loadWakes = useCallback(async () => {
+ setWakesLoading(true)
+ setWakesErr(null)
+ try {
+ setWakes(await api.getWakeEconomics({ agentId: agentId === 'all' ? null : agentId, sinceHours: triageHours }))
+ } catch (e) {
+ setWakesErr(e instanceof Error ? e.message : String(e))
+ } finally {
+ setWakesLoading(false)
+ }
+ }, [agentId, triageHours])
+
+ useEffect(() => {
+ if (panel === 'wakes') void loadWakes()
+ }, [panel, loadWakes])
+
const loadTriage = useCallback(async () => {
setTriageLoading(true)
setTriageErr(null)
@@ -1074,6 +1262,24 @@ export function ObservabilityView() {
[runs, selectedId],
)
+ if (panel === 'wakes') {
+ return (
+ <WakeEconomicsPanel
+ panel={panel}
+ setPanel={setPanel}
+ agents={agents}
+ agentId={agentId}
+ setAgentId={setAgentId}
+ hours={triageHours}
+ setHours={setTriageHours}
+ data={wakes}
+ loading={wakesLoading}
+ err={wakesErr}
+ onRefresh={() => void loadWakes()}
+ />
+ )
+ }
+
if (panel === 'triage') {
return (
<TriageEconomicsPanel
@@ -1110,7 +1316,7 @@ export function ObservabilityView() {
/>
</div>
- <div className="mt-4 grid grid-cols-3 gap-1 rounded-[11px] border border-ink-100 bg-cloud p-1">
+ <div className="mt-4 grid grid-cols-4 gap-1 rounded-[11px] border border-ink-100 bg-cloud p-1">
{DEV_PANELS.map((item) => (
<button
key={item}
diff --git a/src/locales/en.ts b/src/locales/en.ts
index eba0eca..e168883 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -840,6 +840,29 @@ export const en = {
'obs.tierSmall': 'small brain',
'obs.tierBig': 'big brain',
'obs.est': 'est',
+ 'obs.panelWakes': 'Wakes',
+ 'obs.wakesTitle': 'Wake Economics',
+ 'obs.wakesSubtitle': 'How often does a wake produce nothing? A group message wakes every member, each pays the big brain to read the same room, and most conclude it was not theirs.',
+ 'obs.wakesEstimateWarn':
+ '⚠ The RATES on this page are measured — they come from stored token counts and real message timings. Only the dollar column is modelled, using the same unit prices as Triage Economics, at least one of which is a fallback rather than a rate you supplied. Set CUMORA_MODEL_PRICES_JSON to make it exact.',
+ 'obs.wakesNoData': 'No wakes with recorded token usage in this window yet. A run only counts once its engine reports usage — cloud immediately, BYOA after the daemon reports back.',
+ 'obs.statSilentRate': 'Silent wakes',
+ 'obs.statSilentRateSub': '{silent} of {runs} produced no message',
+ 'obs.statSilentGroup': 'Silent in groups',
+ 'obs.statSilentGroupSub': '{runs} group wakes — the number routing moves',
+ 'obs.statSilentSpend': 'Spent on silence',
+ 'obs.statSilentSpendSub': 'big-brain cost of the silent runs (est.)',
+ 'obs.statWakeRuns': 'Wakes measured',
+ 'obs.statWakeRunsSub': 'last {hours}h · runs that reached a model',
+ 'obs.wakesByKind': 'Group vs direct',
+ 'obs.colKind': 'Kind',
+ 'obs.colWakes': 'Wakes',
+ 'obs.colSilent': 'Silent',
+ 'obs.colSilentRate': 'Silent %',
+ 'obs.colSilentSpend': 'Silent $',
+ 'obs.kindGroup': 'Group',
+ 'obs.kindDirect': 'Direct',
+ 'obs.wakesFootnote': 'A wake counts as silent when the agent posted no message into any conversation that woke it, within 10 minutes of the run starting. Group and direct are never averaged: a DM legitimately answers far more often, and blending the two hides the only rate worth acting on. This reports what happened, not what would have been saved.',
'obs.triageTitle': 'Triage Economics',
'obs.triageSubtitle': 'Does the small-brain gate save money? Each triage is a cold session (uncached input); the big-brain turns it shields are cache-warm.',
'obs.triageEstimateWarn':
diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts
index d216881..c6a90db 100644
--- a/src/locales/zh-CN.ts
+++ b/src/locales/zh-CN.ts
@@ -841,6 +841,29 @@ export const zhCN: Partial<Record<keyof typeof en, string>> = {
'obs.tierSmall': '小脑',
'obs.tierBig': '大脑',
'obs.est': '估算',
+ 'obs.panelWakes': '唤醒',
+ 'obs.wakesTitle': '唤醒经济学',
+ 'obs.wakesSubtitle': '有多少次唤醒什么也没产出?一条群消息会唤醒每个成员,每个都要付大脑的钱去读同一个房间,而多数最后判断这事不归自己。',
+ 'obs.wakesEstimateWarn':
+ '⚠ 本页的各项「比率」是实测的——来自已存储的 token 计数和真实的消息时间。只有金额那一列是估算,用的是与分流经济学相同的单价,其中至少有一项是兜底价而非你提供的费率。设置 CUMORA_MODEL_PRICES_JSON 可让它变精确。',
+ 'obs.wakesNoData': '该时间窗内还没有带 token 用量记录的唤醒。一次运行要等引擎上报用量才会计入——云端即时上报,BYOA 要等本机守护进程回报。',
+ 'obs.statSilentRate': '静默唤醒',
+ 'obs.statSilentRateSub': '{runs} 次中有 {silent} 次没有发出消息',
+ 'obs.statSilentGroup': '群聊中的静默',
+ 'obs.statSilentGroupSub': '{runs} 次群唤醒——路由要改变的正是这个数',
+ 'obs.statSilentSpend': '花在沉默上',
+ 'obs.statSilentSpendSub': '静默运行消耗的大脑成本(估算)',
+ 'obs.statWakeRuns': '已计入的唤醒',
+ 'obs.statWakeRunsSub': '最近 {hours} 小时 · 真正调用了模型的运行',
+ 'obs.wakesByKind': '群聊 vs 私聊',
+ 'obs.colKind': '类型',
+ 'obs.colWakes': '唤醒',
+ 'obs.colSilent': '静默',
+ 'obs.colSilentRate': '静默率',
+ 'obs.colSilentSpend': '静默花费',
+ 'obs.kindGroup': '群聊',
+ 'obs.kindDirect': '私聊',
+ 'obs.wakesFootnote': '一次唤醒被计为「静默」,是指在运行开始后的 10 分钟内,该 agent 没有向任何唤醒它的会话发出消息。群聊与私聊从不合并平均:私聊本来就回复得多得多,混在一起会掩盖唯一值得据以行动的那个比率。这里报告的是实际发生了什么,而不是「本来能省多少」。',
'obs.triageTitle': '分流经济学',
'obs.triageSubtitle': '小脑把关到底省不省钱?每次分流都是冷启动会话(未缓存的输入),而被它挡住的大脑对话是缓存命中的。',
'obs.triageEstimateWarn':