Skip to content

用量数据完整性:重试 / 压缩 / fork-subagent 的可计费可见性 #36

Closed

Description

@DoodleBears

Moves: v1.1 → v1.0(2026-09-29)

Decision context

1.0 只做 token 用量(不做金额);记账政策:凡可见且计费的调用都计入其所属 PersonaBot 并记录 purpose;unowned Session 不进任何 bot 的图表。本票产出「哪些调用可计费 / 可见」的核对表,以及明确无法追溯的缺口;实现由 #428(Profile T4)承接,DSH 侧优先复用 deriveTurnTokenUsage(覆盖 assistant/message 与 assistant/attempt stream usage)。


Question

DSH 的 session 日志是否覆盖全部可计费调用:assistant/attempt(失败重试)与 assistant/message(结算)、压缩 / 自动标题等系统调用、运行在子 session 的 subagent / fork——各自是否出现在可查询日志里、如何归属。

需要产出

  • "哪些调用可计费 / 可见"的核对表(含 sessionQuery 读取路径)
  • 明确无法追溯的缺口(若有)

Activity

  1. added this to the v1.1 milestone on Sep 18, 2026
  2. added
    V1.1Milestone v1.1; mirrors the GitHub milestone
    area:docsDocumentation, research, or planning artifact
    feature:usageUsage and cost attribution
    scope:researchEvidence-gathering or mechanism spike
    and removed
    V1.1Milestone v1.1; mirrors the GitHub milestone
    on Sep 22, 2026
  3. modified the milestones: v1.1, v1.0 on Sep 28, 2026
  4. DoodleBears commented on Sep 28, 2026

    @DoodleBears
    ContributorAuthor

    Verified checklist (2026-09-29, DSH 0.2.0-rc.1)

    以 pinned DSH 类型与本地包核对(dsh-token-meter/lib/types/usage-projection.js、turn-usage.d.ts、dsh-session/lib/types/types.d.ts、dsh-llm/lib/types/assistant-stream.d.ts):

    调用 可见性 计费口径
    assistant/message(结算) 顶层 data.usage: TokenUsage(input/output/cacheRead/cacheWrite 四桶,互斥;billedInput = 三输入桶之和) 权威样本,计入
    assistant/attempt(失败/重试/取消的尝试) 无顶层 usage;其 data.stream 最后一个 usage chunk 即该次尝试的 provider usage 计入(provider 已计费);llm/retry / llm/retry-started 标明替换关系
    压缩 / 自动标题等系统调用 走同一 LLM 管线,落在所属 Session 的 assistant 事件里 计入(无独立 purpose 标记,按所属 Session 角色归集)
    Subagent / fork 子 Session 子 Session 有独立日志,header 带 parentSession / origin: 'subagent';fork 子日志含父前缀(inheritedEventCount) 沿 lineage 归到根 PersonaBot;重建时必须 events.slice(inheritedEventCount) 去重
    进行中的流式调用 未结算前不落 durable log 不计入(结算后按上表可见)

    折 turn 由 DSH 导出的 deriveTurnTokenUsage(turn-local events) 完成(@deepseek-ai/dsh-token-meter/client):覆盖重试替换、四桶与 provider/model routes;生命周期不完整时返回 undefined。价格/金额 DSH 永不提供(#35 v1.1)。

    无法追溯的缺口:无逐调用成本;无 purpose 标记(压缩/标题与普通调用无法区分);sessionProjections.tokenUsage 只有 Session 总量(无 day/model 维度),仅作对账。实现随 #428。

  5. DoodleBears commented on Sep 28, 2026

    @DoodleBears
    ContributorAuthor

    核对表已给出(见上);T4 实现按此口径归集与去重。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:docsDocumentation, research, or planning artifactfeature:usageUsage and cost attributionscope:researchEvidence-gathering or mechanism spikewayfinder:researchWayfinder research ticket

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions