Skip to content

feat(narrative): read a block's body as one line - #2280

Merged
eric8810 merged 1 commit into
mainfrom
narrative-flat-block-bodies
Nov 27, 2026
Merged

eric8810 merged 1 commit into
mainfrom
narrative-flat-block-bodies

Conversation

@eric8810

Copy link
Copy Markdown
Collaborator

Fixes #2252(第 2 点;第 1、3 点已由 #2263 处理)

改了什么

只有块的输入,以及它开启的轮次的标题,现在把第一个块的正文压成一行:正文里每一段连续空白(包括换行、缩进)变成一个空格,不加任何分隔符,再按现有规则截到 120 字符。

dim-state source=dim/environment/clients: 1 client connection attached: tui pid=4123 …
dim-agent-message …: Agent default, your team leader, assigned you this work: tool:hold {}

此前只取正文第一行,第一行只是一句引子时,行里没有内容。

为什么不用分隔符

· 这类符号是原文里没有的字,模型可能把它当成内容或结构,带来语义变化。压成空格只丢掉"原来在哪里分行",原排版仍可 open 查看。

范围

  • 只作用于块正文;用户文本、回复、结果仍取第一行,不改 recall 已有的输出面。
  • 投影仍不识别生产方;open 仍显示原文;about 照旧匹配全文;一行 600 字符、一页 20 条的上限不变。
  • 内存投影与 SQLite 查询路径共用同一个 blocks_line,storage flow 的一致性断言照旧通过。

文档

Recall.md(en/zh)§3.4 输入行与行长度规则、§3.6 轮次标题。

验证

  • cargo clippy --workspace --all-targets --locked -- -D warnings、cargo run --locked -p xtask -- check 通过。
  • cargo test --workspace --locked --no-fail-fast:除几个负载下的已知时序抖动(compaction / hooks 相关,与本改动无关,单独重跑均通过)外全部通过。
  • a_blocks_line_keeps_its_body_as_one_line_and_drops_only_its_own_closing_tag 新增多行、缩进、制表符、\r\n 的正文用例。

A blocks-only input and the turn it opens read the first block's body
as one line: each run of whitespace, line breaks included, becomes one
space, and nothing else is added. A body whose first line only leads
into the rest (an environment state, an assigned task) now says what
follows. Opening the input still shows the block as written.

Refs #2252

@yyhhyyyyyy yyhhyyyyyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 664dc3a9, the PR reads a block's body as one line for a blocks-only input and a turn title: each run of whitespace, line breaks included, becomes one space, then the existing 120-character cut applies. User text, replies and results keep their first line; open still shows the original block text and about still matches the full text. The in-memory projection and the SQLite path share blocks_line, and the English and Chinese Recall Section 3.4/3.6 text is updated for the new line form. The change solves point 2 of #2252 without a producer-specific rule.

The new case covers a nested tag, an inner closing tag, an empty body, an untagged multi-line body, and a multi-line body with indentation, a tab and CRLF. The recall, SQLite and agent-read flow expectations are updated. The focused capabilities flow test, the SQLite recall test and both member_work transport tests pass. cargo fmt --all -- --check, git diff --check and node scripts/adr-check.mjs --base 7d9148bb pass. CI at this head is green: changes, macos-native, verify (linux) and ci-ok pass; acp-registry skips and the other jobs skip. The PR is open, mergeable true with no conflicts; the blocked state is the review decision, and #2273 and #2274 are unrelated.

Two optional P3 notes are inline.

APPROVE


**Every line has a fixed maximum length.** A line is one line: a quoted text is its first line.
**Every line has a fixed maximum length.** A line is one line: a quoted text is its first line,
except a block's body, which reads as one line with its whitespace joined (§3.4).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 (optional). This exception is easy to read as every block body, but a line write still uses its first line. A multi-line message from another line is read by line_write and body_line at crates/dim-agent-capabilities/src/narrative.rs:1442, so Recall shows only the first line, while this sentence says a block's body joins its whitespace. Scope the exception to the first block's body on a blocks-only input and a turn title, and update docs/zh/design/plugins/Recall.md:129, or say that a line write keeps its first line.

"<note><b></b></note>",
"<note></note>",
"plain first line\nsecond line",
"<note>\n 1 client attached:\n\n tui\tpid=4123 \r\n</note>",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 (optional). The new case does not exercise the 120-character cut. This body is short, so the test passes whether the code truncates before or after flattening. Add a long multi-line body and assert the rendered line is 120 characters and ends with an ellipsis; the agreed direction applies the existing cut after flattening.

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 664dc3a96d0e91c1cba379e39ae22938f9f6b472. The blocks-only input and its turn title flatten the first block's body before the 120-character cut. The prior closing-tag behavior is preserved, normal text and results keep their first-line behavior, and open still shows the original body. I verified Unicode and length boundaries in an isolated fixture. The exact PR CI passed on Linux and the selected macOS native checks, including evidence for Recall and SQLite/in-memory projection parity. Windows CLI and Web were not selected. No blocking findings.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

叙事投影:块行的结束标签、环境状态块噪音与消息轮次标题

3 participants