Repository navigation
Looper v2.13.143
Looper v2.13.143
Release Decision
Who should upgrade: Operators who run the Manager on an api Profile (the api runtime). Everyone else can stay on v2.13.142: no other runtime changes behavior.
What this release solves: #687 lets the user's stop end an api Manager's reply by cancelling the request, which the api runtime refused until now. It marks usage unknown instead of zero when a request ends without it, and adds per-request details to the run record and one structured log line per request.
Breaking changes: No. The api runtime and its session now declare can_interrupt, so stop is accepted instead of refused; nothing is removed.
How to verify: Check the installed version.
Contributors: Maintainer @foolzzz authored #687; no community contribution was included in this patch release.
looper --version # looper 2.13.143Behavior changes
- Stop (#687):
ApiRuntime.can_interrupt(looper/agents/runtimes/api/adapter.py) andApiSession.can_interrupt(looper/agents/runtimes/api/session.py) become true.ApiSession.run_turnkeeps the turn'sTurnCanceland a done event;interrupt()requests the cancel, waits up to 5 seconds for the turn to end (a tool call that is still finishing is never cancelled mid-write) and returnsStopMethod.CANCEL. With no turn running it returns nothing. A stop requested before the turn starts, after the platform tool specs load, or a cancelled turn that made no request ends as a user-stop result with empty usage andStopMethod.CANCEL. A cancelled turn that made requests also reportsStopMethod.CANCEL. The description also says the stored conversation stays valid after a stop; the changed production code contains no separate transcript handling for it, so that claim rests on the new tests. - Usage unknown, not zero (#687): token totals are summed only over requests that reported a count, and stay unset when none did (before, a missing count added as 0). In
ClaudeClirun finishing (looper/agents/claude_cli.py), a result withusage_completefalse clearscost_usd. - Run record (#687): a new
RuntimeAdapter.result_noteshook (looper/agents/runtimes/__init__.py, default empty) is merged into the finished run's notes; the api adapter returns the result'sapiblock. That block now also carriesincomplete(the number of requests with incomplete usage), and itsupstream_idsare passed throughlog_redaction.redact. - Log line (#687): each request of a turn writes one
api requestrecord at info level on thelooper.agents.runtimes.apilogger with agent, protocol, model, base-URL host name, status, duration, first-token time, retries, input, cache read, cache write and output tokens, completeness and the redacted upstream id. - Docs (#687): the status lines of the API runtime RFC and the long-horizon context plan (both zh-CN) now say stop and usage records are implemented on the branch.
- Tests (#687): new
tests/test_api_stop_db.pyandtests/test_api_usage_records_db.py;tests/test_api_session.py,tests/test_api_runtime_kind.py,tests/test_api_manager_turns_db.pyandtests/test_per_turn_interrupt.pyare updated. - Model-visible changes: none. No prompt, tool declaration or tool result changes; the model sees the same requests. A stopped turn now ends earlier than before; the host-side log line and record notes are not sent to the model.
- Line counts: the description reports tests 510 and production 67 added lines (fixtures excluded).
Upgrade and rollback
Re-run install.sh once v2.13.143 is published. No schema migration. Rolling back to v2.13.142 makes stop on an api Manager reply refused again and drops the per-request notes and log line from new runs; records already written keep their notes.
Optional Capability Activation & Use
No new optional capability activation is introduced in this release.
Validation
Retained implementation evidence: the description of #687 lists the tests that cover the change (tests/test_api_stop_db.py, tests/test_api_usage_records_db.py, tests/test_api_session.py, tests/test_api_runtime_kind.py, tests/test_api_manager_turns_db.py, tests/test_per_turn_interrupt.py, tests/test_provider_pricing.py, tests/test_run_usage.py, tests/test_llm_records_db.py, tests/test_api_loop.py, tests/test_api_responses.py), "automated reviews" and "CI before the merge". It gives no counts or verdicts, and no local full-suite result is recorded. This draft did not re-run any of it.
CI: CI runs after the release is drafted; its result is not recorded here.
Not tested for this draft: Local test runs, a local full suite, a live service, a real provider or chat channel, the built wheel. The release documentation gate checks the body only.
中文摘要
升级决策
**谁需要升级:**在 api Profile(api 运行时)上运行 Manager 的运维者。其他人可留在 v2.13.142:其他运行时的行为不变。
解决了什么:#687 让用户的停止操作可以通过取消请求来结束 api Manager 的回复(此前 api 运行时拒绝停止);请求结束时没有用量则标记为未知而不是 0;并为运行记录增加每个请求的细节,每个请求写一条结构化日志。
**是否有破坏性变更:**否。api 运行时及其会话现在声明 can_interrupt,停止由拒绝变为接受;没有移除任何内容。
**如何验证:**运行 looper --version 核对版本为 2.13.143。
**贡献者:**维护者 @foolzzz 提交 #687;本次 patch release 无社区贡献。
looper --version # looper 2.13.143行为变化与入口
- 停止(#687):
ApiRuntime.can_interrupt(looper/agents/runtimes/api/adapter.py)和ApiSession.can_interrupt(looper/agents/runtimes/api/session.py)变为 true。ApiSession.run_turn保存该轮的TurnCancel和完成事件;interrupt()发出取消请求,最多等待 5 秒让该轮结束(仍在收尾的 tool 调用不会在写入中途被取消),返回StopMethod.CANCEL。没有进行中的轮次时返回空。在轮次开始前、平台工具 spec 加载后请求停止,或被取消的轮次没有发出任何请求,都以用户停止结果、空用量和StopMethod.CANCEL结束;已发出请求的被取消轮次同样报告StopMethod.CANCEL。描述还称停止后已存对话保持有效;改动的生产代码中没有单独的对话记录处理,这一点只由新增测试支撑。 - **用量未知而非零(#687):**token 总数只对报告了数值的请求求和,没有任何请求报告时保持未设置(此前缺失的数值按 0 计入)。
looper/agents/claude_cli.py的运行收尾中,usage_complete为 false 的结果会清除cost_usd。 - **运行记录(#687):**新增
RuntimeAdapter.result_notes钩子(looper/agents/runtimes/__init__.py,默认为空),其结果合并进已完成运行的 notes;api 适配器返回结果中的api块。该块现在还带incomplete(用量不完整的请求数),upstream_ids经log_redaction.redact处理。 - **日志(#687):**一轮中的每个请求在
looper.agents.runtimes.apilogger 上以 info 级别写一条api request记录,含 agent、协议、模型、base URL 主机名、状态、耗时、首 token 时间、重试次数、输入、缓存读、缓存写和输出 token、完整性以及脱敏后的上游 id。 - **文档(#687):**API 运行时 RFC 和长程上下文计划(均为 zh-CN)的状态行改为说明停止与用量记录已在分支实现。
- **测试(#687):**新增
tests/test_api_stop_db.py和tests/test_api_usage_records_db.py;更新tests/test_api_session.py、tests/test_api_runtime_kind.py、tests/test_api_manager_turns_db.py和tests/test_per_turn_interrupt.py。 - **面向模型的变化:**无。提示词、tool 声明和工具结果均不变,模型看到的请求相同。被停止的轮次现在会更早结束;主机侧的日志行和记录 notes 不会发给模型。
- **行数:**描述报告新增测试 510 行、生产代码 67 行(不含 fixtures)。
升级与回退
v2.13.143 发布后重跑 install.sh。无表结构迁移。回退到 v2.13.142 会让 api Manager 回复的停止重新被拒绝,新运行不再有每请求的 notes 和日志行;已写入的记录保留其 notes。
可选能力启用与使用
本版本未新增可选能力启用入口。
验证
保留的实现证据:#687 的描述列出覆盖该改动的测试(tests/test_api_stop_db.py、tests/test_api_usage_records_db.py、tests/test_api_session.py、tests/test_api_runtime_kind.py、tests/test_api_manager_turns_db.py、tests/test_per_turn_interrupt.py、tests/test_provider_pricing.py、tests/test_run_usage.py、tests/test_llm_records_db.py、tests/test_api_loop.py、tests/test_api_responses.py)、“自动评审”和“合并前的 CI”,没有给出数量或结论,也没有记录本地完整套件结果。本草稿未重新运行。
**CI:**CI 在发布草稿后运行,其结果未在此记录。
**本次草稿未测试:**本地测试、本地完整套件、运行中的服务、真实 provider 或聊天渠道、构建出的 wheel。发布文档 gate 只检查正文。