DSH / Atlas
2026-11-13implementedarchitecture

PTC output truncation without execution cancellation

PTC 输出截断不取消执行

Stopping a program because its logs exceed the output budget can interrupt a sequence of external actions. Earlier effects remain, but the caller cannot tell which later actions ran. Repeating the program to obtain less output can repeat those effects. A full log budget can also hide a subsequent exception by replacing its kind with an output-limit failure.

English

Problem

Stopping a program because its logs exceed the output budget can interrupt a sequence of external actions. Earlier effects remain, but the caller cannot tell which later actions ran. Repeating the program to obtain less output can repeat those effects. A full log budget can also hide a subsequent exception by replacing its kind with an output-limit failure.

Decision

Captured output has bounded retention. Exhaustion preserves an ordered prefix, discards subsequent output and sets outputTruncated; it does not cancel execution or discard retained variables. Existing deadlines, cancellation, heap limits and control-message limits still apply. Finalization prioritizes the required completion value or bounded failure diagnostic within the combined payload budget. Truncated diagnostics preserve their failure kind. Required completion values remain lossless and fail if they cannot fit.

This supersedes only captured-output termination and diagnostic reclassification in typed tool returns, and overflow-driven state disposal in retained PTC. Those records still own lossless values and retained-state lifetime; explicit output still owns inspection and image projection.

Alternatives considered

Terminate on output exhaustion. It limits output production earlier, but turns a presentation limit into interrupted external work without rollback.

Return success with a truncated completion value. It violates the caller's requirement for complete JSON data. Only captured output and diagnostic text may be shortened.

Consequences

Successful truncated runs remain successful tool results. Callers inspect current state for missing information instead of replaying completed actions. Output suppression does not bound allocations in argument evaluation or native code; existing resource controls retain that responsibility. Tests cover subsequent actions, retained variables, initialization, ordered images, byte limits and later exceptions, deadlines and cancellation.

中文

问题

因日志超出输出预算而停止程序,可能打断一系列外部动作。此前的效果仍然保留,但调用方无法判断后续哪些动作已经执行。为了减少输出而重跑程序,可能重复这些效果。日志预算耗尽还可能使后续异常被替换成输出超限失败,掩盖真实类型。

决策

捕获输出采用有界保留。预算耗尽时保留有序前缀,丢弃后续输出并设置 outputTruncated,但不取消执行或丢弃保留变量。原有截止时间、取消、堆限制和控制消息限制继续生效。最终结算在组合负载预算内优先保留必需完成值或有界失败诊断。截断诊断保留原来的失败类型。必需完成值保持无损,无法容纳时仍然失败。

本决策只取代类型化工具返回值中的捕获输出超限终止和诊断重新分类,以及保留状态 PTC中的超限清空状态规则。这些记录仍负责无损值和保留状态生命周期;显式输出仍负责检查展示与图片投影。

考虑过的替代方案

输出耗尽时终止。 能更早限制输出生产,但将展示限制变成没有回滚的外部工作中断。

截断完成值后返回成功。 违反调用方对完整 JSON 数据的要求。只有捕获输出和诊断文本可以缩短。

后果

成功但输出截断的执行仍是成功工具结果。调用方读取当前状态以获取遗漏信息,不重放已完成动作。输出抑制不限制参数求值或原生代码中的分配,这仍由现有资源控制负责。测试覆盖后续动作、保留变量、初始化、有序图片、字节上限以及后续异常、截止到期和取消。