一份研究报告已经保存,后台也记录了 Token。把这次 Run 的费用加起来,填到报告旁边,是不是就完成了成本统计?
只有在一个非常强的前提下才可能这样做:这次运行只服务这一份报告,所有调用都被完整记录,价格口径一致,没有共享工作,也没有未知费用。
真实 Agent 往往不满足这些条件。一次请求可能同时生成正文和图表;Child 查到的材料可能被多个输出复用;重试可能发生在没有返回完整用量之前。能找到报告相关的请求,不等于知道报告独占了多少钱。
一、先分清我们在算哪本账
讨论 Agent 成本时,最容易把四个不同问题混在一起。
其中“物理尝试”尤其重要。一个逻辑请求可能触发多次真实发送;同一次发送又可能同时出现在网关回执、追踪平台和运行汇总里。
前一种情况不能合并掉失败尝试,后一种情况不能重复加钱。因此,计量要从原物理尝试身份开始,而不是从报表行数开始。
二、一次研究,两份产物,为什么不能各收一遍钱
下面是完全合成的教学例子,不代表真实费率或用户账单。
某次研究有三个可确认的物理尝试:A 的已知估算费用为 0.01 美元,B 为 0.04 美元,C 没有足够用量信息,费用未知。A、B 共同服务一个逻辑请求,这个请求既发布了报告正文,也生成了一个图表文件。
如果在“报告成本”里显示 0.05 美元,又在“图表成本”里显示 0.05 美元,再把两项相加,读者会得到 0.10 美元。但目前可确认的已知请求费用仍然只有 0.05 美元,而且 C 的缺口没有消失。
错误不在加法,而在集合关系:报告视图和图表视图引用了同一批尝试,它们不是两组互不相交的费用。
所以系统需要明确标记:这是关联视图,不可相加;这是已知估算小计,不是完整总额;共享部分尚未分配。
平均分摊也不是天然正确。把 0.05 美元各分一半,可以是一项事先声明的管理会计规则,却不是从请求回执中发现的客观事实。没有选定规则时,应当保留“未分摊”,而不是用一个漂亮的小数掩盖缺失的决策。
三、我们先实现的是关联,不是替用户决定分摊
在这次实现里,报告正文与文件各自沿原有持久身份读取。正文使用发布块及其版本;文件使用产物身份、内容哈希等原始记录,而不是页面临时显示的名称。
对正文,读取器先请原发布模块确认当前已结算版本,以及绑定的原 Main 请求。确认后,再关联这个请求已观察到的物理尝试。旧版本、不存在的版本或没有足够绑定的记录,不能靠时间接近补配。
对文件,则核对原产物身份和导出回执。文件保存成功、被登记进历史、语义上属于哪份周报,是不同的事实,不由成本读取器顺手认证。
指定发布版本后由原发布模块确认;若关联依据不可用,则保留原交付读取。确认原调用后读取物理尝试,分别保留已知估算和未知用量,形成不可相加的成本视图;这两种结果都不影响原交付读取。
上述流程只有原发布模块确认了指定版本与原调用,才进入尝试关联。关联不可用时,缺失的是这份成本视图的依据,不是已经独立保存的正文。已知估算与未知用量可以同时存在。
这条链能回答“发布这一块正文的原请求有哪些已观察尝试”,却不能回答“为了写这块正文,所有必要工作是什么”。此前的资料读取、Child 工作、共享研究都可能参与,单个发布请求并不包含整个因果链。
因此当前视图明确保留 requestMayServeOtherOutputs、viewsAreAdditive=false 和 sharedCostAllocation=unallocated。完整报告归属金额仍然未知。这不是忘了做求和,而是拒绝把请求关联冒充完整归因。
四、未知不是零,供应商报告零也不是总成本为零
某次请求没有返回用量,可能是中断发生在回执之前,也可能是记录链路缺失。无论哪一种,都不能因为金额字段为空就改成零。
另一个方向也一样:供应商在响应里报告余额扣款为零,可能描述的是当前响应的特定计费维度。订阅价格、额度消耗、标价和其他外部服务成本,仍是不同概念。
我们因此分别保留供应商报告的余额扣款、BYOK 费用、标价与额度观察,不合成一个来源不明的 cost。这些是响应时的观测,不是经过最终对账的发票。
下面是对前述合成案例的展示建议,不是生产接口的原样复制:
合成展示中,已知请求估算为 0.05 美元;完整请求费用和报告独占成本未知,另有一次费用未知,共享部分未分摊,各视图不能相加。
金额保留十进制口径,未知总额保留 null。如果前端一定要显示一句话,可以写:“已观察请求估算 0.05 美元;另有一次费用未知,共享部分未分摊。”这比“本报告花费 0.05 美元”更接近实际证据。
同样,不应该把每页成本索引的小计直接累加成 Run 总账。分页覆盖、重复身份和各视图之间的重叠关系,都需要先核对。
五、成本系统坏了,不应把已经交付的报告一起弄坏
成本观察通常是辅助功能,却很容易在组合时变成新的全局失败点:正文已经保存,读取报告时附带查询费用,费用查询抛错,整个接口于是返回失败。
这样一来,用户无法取得的不是报告,而是“报告加一个可选费用视图”这个组合。辅助功能扩大了自己的失败范围。
这次受控验证特意让成本观察读取失败,再从新的读取进程访问已保存产物。要守住的行为是:费用显示不可用,原正文、文件身份与独立读取仍可保留;不重发模型请求,也不为了补账再次生成报告。
权限失败则不能用这种降级绕过。用户没有权利读取某份报告,成本模块不能靠“只显示金额”透露其存在或内容。可选观察失败与原数据访问授权,是两条不同边界。
六、什么时候才能真正比较“这份报告更便宜”
先把比较对象说清楚:是请求级估算、账户级总支出,还是按某项规则分摊后的交付物成本?不同口径可以各有用途,但不能混用。
然后核对三件事:物理尝试与价格覆盖是否一致,共享费用规则是否事先固定,交付内容和质量是否可比。少读一份关键资料、漏掉失败调用,或者把 Child 成本藏在别处,都可能让数字看起来下降,却没有提高效率。
当覆盖不完整时,仍可报告已知部分与缺口,帮助定位资源消耗。只是不能进一步推出“整份报告节省了多少”。完整因果归因和供应商对账,是这条成本链后续需要解决的问题。
七、留下了调用证据,为什么还是不能直接算出报告总成本?
2026 年 10 月,我们把研究调用的逻辑输入、可观察输出和来源依赖交给独立的研究调用证据存储模块保存,解决的是请求与证据副本的身份、保留和回读,而不是一次模型尝试的真实账单。
这里尤其不能把 研究调用副本缺失当成 请求没有发生;也不能因为某次供应商响应报告 balance charge 0,就称整份报告“免费”。原执行、被动采集、物理用量、内部 Credits 与最终扣费各有 Owner。
因此,这篇文章继续负责“计量、关联、分摊和对账”这四个不同问题;研究证据生命周期专讲一份输入/输出副本为何能或不能保存和重读。两篇合在一起能解释已知数与未知数,但不制造不存在的完整成本因果数据。
结语:先把身份和口径做对,再争取一个总数
成本系统不一定要一开始就算出所有答案,但必须让已知与未知分得开,让同一尝试不会因为出现在两张报表上就收费两次。
对 Agent 报告,我更愿意先交付一个能回查的请求关联视图,而不是一个来源不明的精确金额。它能说明哪些调用已被观察、哪些金额只是估算、哪些工作被共享,也不会让辅助记账反过来损害原交付。
关联回答“这笔工作在哪里”,分摊回答“这笔工作归谁”,对账回答“最终实际付了多少”。 三个问题分开之后,成本优化才有一个可以信任的起点。
延伸阅读:请求、Token 与 Credits · 多专家贡献如何取证 · 可观测全景中的 Trace 完整性
更多工程案例见 ETF Agent 技术文集。欢迎为文集点一个 Star。
原文阅读:Agent 生成一份报告,到底应该怎么算成本?。
本文由 AI图鉴自动抓取并翻译,版权归原作者所有;如需查看原文请点下方链接。
A study has been kept and token was recorded backstage. By adding up the costs of Run to the report, did you complete the cost count?
This is possible only in a very strong case: this operation serves only this report, and all calls are fully recorded, priced at the same calibre, without shared jobs and without unknown costs.
True Agen often does not meet these conditions. One request may generate both the body and the chart at the same time; Child found material may be reused by multiple outputs; and retry may have occurred before full usage was returned. Finding a request for a report would not be tantamount to knowing how much it was monopolized.
I, first, tell us what we're dealing with.
When discussing Agent costs, it is easier to mix four different issues.
Of these, “physical experiments” are particularly important. A logical request may trigger multiple real dispatches; the same dispatch may appear in a gateway callback, a tracking platform and a running aggregation.
The former case cannot be combined with the failed attempt, and the latter case cannot be duplicated. Therefore, measurement begins with the original physical attempt to identify, not with the number of lines in the report.
Two, one study, two products. Why can't we take each other? Money.
The following is a completely synthesized teaching example, which does not represent real rates or user bills.
There were three confirmed physical attempts in one study: the known estimated cost for A was US$ 0.01, B was US$ 0.04, C did not have sufficient information and the cost was unknown. A.B. A logical request for common services, both in the body of the report publish and in a graphic document.
If $0.05 is shown in the Report Cost and $0.05 is shown in the Chart Cost, the reader receives $0.10 by adding the two. However, currently identifiable known requests still cost only $0.05 and the shortfall in C has not disappeared.
The error is not added, but in a group relationship: the report view and the chart view refer to the same set of attempts, which are not two sets of separate costs.
The system therefore needs to be clearly marked: this is a linkage view, which cannot be added to it; this is a known subtotal of estimates, not a full sum; and the share is not yet distributed.
Nor is it natural to be equally assessed. The split of 0.05 United States dollars could be a pre-declared management accounting rule, but not an objective fact found in the request reply. In the absence of a selection rule, the term “unassessed” should be retained, rather than covering the missing decision-making with a nice decimal.
iii. What we've achieved first is a connection, not a distribution for the user.
In this exercise, the body of the report and the documents were read in their respective permanent identities. The text uses block publish and its version; the document uses original records such as product identity, content Hash, and so on, instead of the name shown on the page.
For the text, the reader requests the original publish module to confirm the current settled version and the bound original Main request. Once confirmed, the physical attempt observed in the request is linked. Old versions, non-existent versions or records that do not contain sufficient bindings cannot be close to supplementation in time.
In the case of documents, the identity of the product is checked and the notification is exported. The fact that the document was successfully preserved, registered in history, and the semantic type of weekly report is different and not certified by a cost reader.
Specifies the publish version to be confirmed by the original publish module; if the association basis is not available, retain the original delivery for reading. Confirms that the original call is followed by a physical attempt to read the original call, and retains the known estimate and the unknown amount, respectively, to form an irreconcilable cost view; neither result affects the original delivery reading.
The process mentioned above is only attempted if the original publish module confirms the specified version and the original call. When linkages are not available, what is missing is the basis for this cost view, not the text that has been saved independently. Known estimates can be available with unknown uses.
The chain answers “what are the observed attempts of the original request for the text of publish” but does not answer “what is necessary to write the text”. Previous information reading, Child work, shared research may all be involved, and individual publish requests do not contain the whole causal chain.
Therefore, the current view expressly retains the names of MayMayServeOtherOutputs, ViewsAreActive=false and SharedCestAllocation=unallocated. Full reporting of attribution amounts remains unknown. This is not to forget to make peace, but rather to refuse to present the claim as a complete attribution.
IV. Unknown is not zero, and supplier reporting zero is not a zero total cost
In one case, the request did not return the amount, either because the interruption occurred prior to the receipt of the letter or because of the missing record link. In either case, the amount field cannot be converted to zero because it is empty.
The same is true for another direction: suppliers report zero deductions in their responses and may describe the specific costing dimensions of the current response. Subscription prices, quota consumption, pricing and other external service costs remain different concepts.
We therefore retain the balance deductions reported by the suppliers, the BYOK fees, the bid price and the quota observation, respectively, without synthesizing an unknown source, cost. These were observations in response and were not invoices that were eventually reconciled.
The following is a presentation of the above-mentioned synthetic case, not a copy of the production interface as it is:
In the composite presentation, the known request is estimated at $0.05; full request costs and reporting are unknown, another cost is unknown, share parts are not shared and views cannot be added.
The amount is preserved as a decimal caliber and the unknown sum is retained as a null. If a sentence is to be shown at the front end, it may read: “The observer request is estimated at US$ 0.05; an additional cost is unknown and the share is not shared”. This is closer to actual evidence than “US$ 0.05 for this report”.
Similarly, the subtotal of the cost index per page should not be added directly to the Run ledger. The overlap between page breaks, duplicate identities and views needs to be checked first.
V. Cost systems are broken and reports delivered should not be broken together
Cost observation, which is usually a support function, can easily become a new global failure point when combined: the body is saved, the report is read with query costs, the cost query is dropped and the entire interface fails.
As a result, users are unable to obtain a combination of “reports with an optional cost view”. The auxiliary function expands the range of its failures.
This controlled certification specifically failed to allow cost observations to read and then access the products from the new reading process. The conduct to be followed is that the cost is not shown to be available and the original text, document identification and independent reading can be retained; the model request is not reissued, nor is the report generated for replenishment purposes.
The failure of permission cannot be bypassed by such a downgrading. Users do not have the right to read a report, and the cost module cannot disclose its existence or content by “showing only the amount”. Optional observation failures and original data access authorizations are two different borders.
When can the report be really cheaper?
First, let the comparator be clear: is it a request-level estimate, an account-level total expenditure or a rule-based apportionment of the cost of the delivered goods? Different calibres can be used for different purposes, but cannot be mixed.
Three things were then checked: whether physical attempts were consistent with price coverage, whether cost-sharing rules were fixed in advance, and whether delivery content and quality were comparable. Less reading a key piece of information, missing a failed call, or hiding Child costs elsewhere could make numbers look lower, but not more efficient.
Where coverage is incomplete, known parts and gaps can still be reported to help locate resource consumption. It is simply not possible to further introduce “how much savings have been achieved throughout the report”. Complete attribution and vendor reconciliation are issues that need to be addressed in the follow-up to this cost chain.
vii. Leaves evidence of call and why cannot the total cost of reporting be calculated directly?
In October 2026, we relied on the logical input, the observation output and the source of the research call to be preserved by the independent research call evidence storage module, which addressed the identity, retention and rereading of the request and the copy of the evidence, rather than the true bill of the model attempt.
In particular, the lack of a copy of the call for the study cannot be considered as the fact that the request did not take place; nor can the entire report be called "free" because a supplier responded to the report. Original execution, passive collection, physical usage, internal Credits, and final deductions.
The article therefore continues to cover the four different issues of “measurement, association, sharing and reconciliation”; and studies the life cycle of evidence on why a copy of the input/output can or cannot be saved and reread. The combination of the two parts explains the known and unknown but does not produce complete cost causal data that do not exist.
Concluding remarks: Identities and calibres against totals
The cost system does not have to come up with all the answers at the outset, but it must be separated from the known and unknown, so that the same attempt does not cost twice because it appears in two statements.
For the Agent report, I would prefer to deliver a request-related view that can be checked back instead of a precise amount from which it is unknown. It would indicate which transfers had been observed, which amounts were only estimated, which jobs were shared and would not, in turn, allow supporting accounting to undermine the original delivery.
The related answer was “Where is the job” and the shared answer was “Who is the job” and the reconciliation answer was “how is it actually actually paid”. When the three issues are separated, there is a trusted starting point for cost optimization.
Extension reading: Request, Token and Credits Multi-expert contribution how to take evidence and observe the fullness of Trace in the landscape
More project cases can be found in the ETF Agent technical collection. Welcome to a collection for Star.
Original reading: Agent produces a report, how should it be cost?
Auto-fetched and translated by AI Atlas. All rights belong to the original author.