Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

chore(release): prepare 0.15.2

xf gong6789f50c9ea1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fa2a974..5894cae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [0.15.2] - 2026-10-21
+
### Added
- **Messages carry a stable `id`.** `UserMessage`, `AssistantMessage`, and
@@ -30,7 +32,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
per-turn `memory_snapshot.captured_at` into it). On a 901-message
conversation 38 of 877 refs drifted between compaction runs, so
`_state_matches_history` returned False and the state was discarded.
- Identity is now the role, the content, and the tool linkage only.
+ A message with an `id` is referenced by that id. A message without one
+ is referenced by role, content, and tool linkage, ignoring `run_id`,
+ `timestamp`, and `metadata`.
- The trigger sized a raw-history send with `real_context_estimate`, which is
anchored to the most recent usage-bearing assistant and adds only what
follows it. Every message *before* the anchor is assumed to be covered by
@@ -911,7 +915,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **[0.2.0]** - 2026-05-10 — see the [release notes](https://github.com/cubeplexai/cubepi/releases/tag/v0.2.0).
- **[0.1.0]** - 2026-05-09 — initial release. See the [release notes](https://github.com/cubeplexai/cubepi/releases/tag/v0.1.0).
-[Unreleased]: https://github.com/cubeplexai/cubeloop/compare/v0.15.1...HEAD
+[Unreleased]: https://github.com/cubeplexai/cubeloop/compare/v0.15.2...HEAD
+[0.15.2]: https://github.com/cubeplexai/cubeloop/compare/v0.15.1...v0.15.2
[0.15.1]: https://github.com/cubeplexai/cubeloop/compare/v0.15.0...v0.15.1
[0.15.0]: https://github.com/cubeplexai/cubeloop/compare/v0.14.1...v0.15.0
[0.14.1]: https://github.com/cubeplexai/cubeloop/compare/v0.13.6...v0.14.1
diff --git a/compat/cubepi/pyproject.toml b/compat/cubepi/pyproject.toml
index 2cad086..c80cc4b 100644
--- a/compat/cubepi/pyproject.toml
+++ b/compat/cubepi/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "cubepi"
-version = "0.15.1"
+version = "0.15.2"
description = "REMOVED: Install cubeloop and migrate imports from cubepi."
readme = "README.md"
license = "MIT"
diff --git a/pyproject.toml b/pyproject.toml
index f68136d..0463dc6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "cubeloop"
-version = "0.15.1"
+version = "0.15.2"
description = "Pythonic async-native agent framework"
readme = "README.md"
license = "MIT"
diff --git a/uv.lock b/uv.lock
index adf7d36..1aa1595 100644
--- a/uv.lock
+++ b/uv.lock
@@ -525,7 +525,7 @@ wheels = [
[[package]]
name = "cubeloop"
-version = "0.15.1"
+version = "0.15.2"
source = { editable = "." }
dependencies = [
{ name = "anthropic" },
@@ -621,7 +621,7 @@ dev = [
[[package]]
name = "cubepi"
-version = "0.15.1"
+version = "0.15.2"
source = { editable = "compat/cubepi" }
[[package]]
diff --git a/website/docs/guides/middleware/compaction.md b/website/docs/guides/middleware/compaction.md
index 06a47a6..0dc5726 100644
--- a/website/docs/guides/middleware/compaction.md
+++ b/website/docs/guides/middleware/compaction.md
@@ -49,9 +49,12 @@ The middleware writes two keys into `AgentContext.extra`:
- `compaction_until_msg_index` — the history boundary summarized so far.
When a checkpointer is attached, CubeLoop saves `ctx.extra` after a turn that produced tool results, on HITL suspension, and at `agent_end`, so the
-next process can resume with the existing summary. If the message refs no longer
-match the current history, the middleware clears the stale state and starts over
-rather than sending an invalid summary.
+next process can resume with the existing summary. A message that has an
+`id` is referenced by that id. Older messages are referenced by a hash of
+role, content, and tool linkage, ignoring `run_id`, `timestamp`, and
+`metadata`. If the refs no longer match the current history, the middleware
+logs a warning, clears the stale state, and starts over rather than sending
+an invalid summary.
## How compaction triggers
@@ -64,7 +67,10 @@ a single agent turn, between tool-call iterations — along two dimensions:
— so it stays accurate under prompt caching, where most of the prompt is served
from cache and would be invisible to a character-only estimate. Before the first
model response (no usage yet), it falls back to a character estimate. Zero-usage
- error/abort messages are skipped so a failure never resets the estimate.
+ error/abort messages are skipped so a failure never resets the estimate. When
+ no summary is in effect, the usage anchor does not cover the prefix, so the
+ check also takes a character estimate of the whole history and uses the
+ larger number.
- **In-run boundaries.** The summary boundary advances at any self-contained
*turn boundary*, not only at user messages. A long agentic run — one user prompt
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/middleware/compaction.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/middleware/compaction.md
index ebf6919..9567008 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/middleware/compaction.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/middleware/compaction.md
@@ -45,8 +45,10 @@ middleware 会向 `AgentContext.extra` 写入两个键:
- `compaction_until_msg_index` —— 已总结到的历史边界。
绑定 checkpointer 时,CubeLoop 会在产生工具结果的轮次结束之后、HITL 暂停时,以及 `agent_end` 时通过 `save_extra` 保存
-`ctx.extra`,所以下一个进程可以带着已有摘要继续。如果消息引用与当前历史不再
-匹配,middleware 会清除旧状态并重新开始,而不是发送无效摘要。
+`ctx.extra`,所以下一个进程可以带着已有摘要继续。已有 `id` 的消息用这个 id
+作为引用。更早的消息用角色、内容和工具关联的哈希作为引用,不计入 `run_id`、
+`timestamp` 和 `metadata`。如果引用与当前历史不再匹配,middleware 会记一条
+警告,清除旧状态并重新开始,而不是发送无效摘要。
## 压缩触发机制
@@ -58,7 +60,8 @@ middleware 会向 `AgentContext.extra` 写入两个键:
`input_tokens + cache_read_tokens + cache_write_tokens` ——所以在 prompt
caching 下依然准确(此时大部分 prompt 由缓存提供,纯字符估算根本看不到)。
首次模型响应前(还没有 usage)回退到字符估算。零值的 error/abort 消息会被
- 跳过,因此一次失败不会重置估算。
+ 跳过,因此一次失败不会重置估算。没有生效中的摘要时,usage 锚点盖不住前缀,
+ 判据会再取整段历史的字符估算,并采用两者中较大的数。
- **run 内边界。** 摘要边界可以在任何**自洽的 turn 边界**前移,不再只限于用户
消息。一个长 agentic run ——一条用户 prompt 后跟着多轮工具调用、中间没有用户
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.15/guides/middleware/compaction.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.15/guides/middleware/compaction.md
index ebf6919..9567008 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.15/guides/middleware/compaction.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.15/guides/middleware/compaction.md
@@ -45,8 +45,10 @@ middleware 会向 `AgentContext.extra` 写入两个键:
- `compaction_until_msg_index` —— 已总结到的历史边界。
绑定 checkpointer 时,CubeLoop 会在产生工具结果的轮次结束之后、HITL 暂停时,以及 `agent_end` 时通过 `save_extra` 保存
-`ctx.extra`,所以下一个进程可以带着已有摘要继续。如果消息引用与当前历史不再
-匹配,middleware 会清除旧状态并重新开始,而不是发送无效摘要。
+`ctx.extra`,所以下一个进程可以带着已有摘要继续。已有 `id` 的消息用这个 id
+作为引用。更早的消息用角色、内容和工具关联的哈希作为引用,不计入 `run_id`、
+`timestamp` 和 `metadata`。如果引用与当前历史不再匹配,middleware 会记一条
+警告,清除旧状态并重新开始,而不是发送无效摘要。
## 压缩触发机制
@@ -58,7 +60,8 @@ middleware 会向 `AgentContext.extra` 写入两个键:
`input_tokens + cache_read_tokens + cache_write_tokens` ——所以在 prompt
caching 下依然准确(此时大部分 prompt 由缓存提供,纯字符估算根本看不到)。
首次模型响应前(还没有 usage)回退到字符估算。零值的 error/abort 消息会被
- 跳过,因此一次失败不会重置估算。
+ 跳过,因此一次失败不会重置估算。没有生效中的摘要时,usage 锚点盖不住前缀,
+ 判据会再取整段历史的字符估算,并采用两者中较大的数。
- **run 内边界。** 摘要边界可以在任何**自洽的 turn 边界**前移,不再只限于用户
消息。一个长 agentic run ——一条用户 prompt 后跟着多轮工具调用、中间没有用户
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.15/intro.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.15/intro.mdx
index 5b2f6ea..192fd7a 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.15/intro.mdx
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.15/intro.mdx
@@ -75,5 +75,7 @@ CubeLoop 0.15 增加 Execution Session,供宿主获取明确的执行结果、
0.15.1 增加工具结果文本上限,并允许 `TodoListMiddleware` 在宿主已校验的后台任务尚未完成时结束当前 run。见[工具结果长度限制](./guides/middleware/tool-result-limit.md)和[待办列表](./guides/middleware/todo.md)。
+0.15.2 给写入后的消息一个稳定的 `id`。压缩摘要被丢弃时会记一条警告,并按整段历史估算长度。见[上下文压缩](./guides/middleware/compaction.md)。
+
源代码、Issue 和讨论都在
[GitHub](https://github.com/cubeplexai/cubeloop)。
diff --git a/website/versioned_docs/version-0.15/api/cubeloop-providers.mdx b/website/versioned_docs/version-0.15/api/cubeloop-providers.mdx
index a992bc6..abc992f 100644
--- a/website/versioned_docs/version-0.15/api/cubeloop-providers.mdx
+++ b/website/versioned_docs/version-0.15/api/cubeloop-providers.mdx
@@ -12,13 +12,14 @@ hide_table_of_contents: false
_class_
-[source](https://github.com/cubeplexai/cubeloop/blob/main/cubeloop/providers/base.py#L104)
+[source](https://github.com/cubeplexai/cubeloop/blob/main/cubeloop/providers/base.py#L110)
**Attributes**
- `role`: `Literal['assistant']`
- `content`: `list[Content | ThinkingContent | ToolCall]`
+- `id`: `str`
- `stop_reason`: `str`
- `error_message`: `str | None`
- `error_type`: `str | None`
@@ -682,7 +683,7 @@ _class_
_class_
-[source](https://github.com/cubeplexai/cubeloop/blob/main/cubeloop/providers/base.py#L124)
+[source](https://github.com/cubeplexai/cubeloop/blob/main/cubeloop/providers/base.py#L131)
**Attributes**
@@ -693,6 +694,7 @@ _class_
- `content`: `list[Content]`
- `details`: `StructuredValue`
- `is_error`: `bool`
+- `id`: `str`
- `timestamp`: `float | None`
- `metadata`: `JsonObject`
- `run_id`: `str | None`
@@ -719,13 +721,14 @@ _class_
_class_
-[source](https://github.com/cubeplexai/cubeloop/blob/main/cubeloop/providers/base.py#L96)
+[source](https://github.com/cubeplexai/cubeloop/blob/main/cubeloop/providers/base.py#L101)
**Attributes**
- `role`: `Literal['user']`
- `content`: `list[Content]`
+- `id`: `str`
- `timestamp`: `float | None`
- `metadata`: `JsonObject`
- `run_id`: `str | None`
diff --git a/website/versioned_docs/version-0.15/guides/middleware/compaction.md b/website/versioned_docs/version-0.15/guides/middleware/compaction.md
index 06a47a6..0dc5726 100644
--- a/website/versioned_docs/version-0.15/guides/middleware/compaction.md
+++ b/website/versioned_docs/version-0.15/guides/middleware/compaction.md
@@ -49,9 +49,12 @@ The middleware writes two keys into `AgentContext.extra`:
- `compaction_until_msg_index` — the history boundary summarized so far.
When a checkpointer is attached, CubeLoop saves `ctx.extra` after a turn that produced tool results, on HITL suspension, and at `agent_end`, so the
-next process can resume with the existing summary. If the message refs no longer
-match the current history, the middleware clears the stale state and starts over
-rather than sending an invalid summary.
+next process can resume with the existing summary. A message that has an
+`id` is referenced by that id. Older messages are referenced by a hash of
+role, content, and tool linkage, ignoring `run_id`, `timestamp`, and
+`metadata`. If the refs no longer match the current history, the middleware
+logs a warning, clears the stale state, and starts over rather than sending
+an invalid summary.
## How compaction triggers
@@ -64,7 +67,10 @@ a single agent turn, between tool-call iterations — along two dimensions:
— so it stays accurate under prompt caching, where most of the prompt is served
from cache and would be invisible to a character-only estimate. Before the first
model response (no usage yet), it falls back to a character estimate. Zero-usage
- error/abort messages are skipped so a failure never resets the estimate.
+ error/abort messages are skipped so a failure never resets the estimate. When
+ no summary is in effect, the usage anchor does not cover the prefix, so the
+ check also takes a character estimate of the whole history and uses the
+ larger number.
- **In-run boundaries.** The summary boundary advances at any self-contained
*turn boundary*, not only at user messages. A long agentic run — one user prompt
diff --git a/website/versioned_docs/version-0.15/intro.mdx b/website/versioned_docs/version-0.15/intro.mdx
index db94a20..6b5abcb 100644
--- a/website/versioned_docs/version-0.15/intro.mdx
+++ b/website/versioned_docs/version-0.15/intro.mdx
@@ -85,5 +85,9 @@ run while host-validated background tasks are still open. See
[Tool Result Limit](./guides/middleware/tool-result-limit.md) and
[Todo List](./guides/middleware/todo.md).
+0.15.2 gives each appended message a stable `id`. A dropped compaction
+summary is logged, and the size check then counts the whole history. See
+[Compaction](./guides/middleware/compaction.md).
+
Source, issues, and discussion live on
[GitHub](https://github.com/cubeplexai/cubeloop).