Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/core/src/tools/todoWrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ class TodoWriteToolInvocation extends BaseToolInvocation<
const previousPlan = await readTodoPlanFromFile(sessionId);
const oldTodos = previousPlan.todos;
const oldTodosMap = new Map(oldTodos.map((todo) => [todo.id, todo]));
// Deliberately NOT gated on `isSessionWorkflowEnabled()`, and the
// `blockedBy` schema description is not gated either. Both are plan
// data-model semantics, not presentation: gating them on what is a
// visualization switch would give `todo_write` two dialects, so the
// same call would produce different stored plans depending on whether
// anyone happens to be looking at the graph. The behaviour therefore
// reaches sessions with Session Workflow off, which is intended — see
// the preservation merge below for the exact blast radius.
const hasActivePlan = oldTodos.some(
(todo) => todo.status !== 'completed',
);
Expand All @@ -317,6 +325,23 @@ class TodoWriteToolInvocation extends BaseToolInvocation<
const data = JSON.parse(modified_content) as Record<string, unknown>;
candidateTodos = data['todos'];
} else {
// Blast radius of the omitted-`blockedBy` preservation, stated once
// because it is ungated (see `hasActivePlan` above): it changes an
// update only when all three hold — the previous plan still has an
// unfinished item, the same id carried a non-empty `blockedBy`, and
// this call omits `blockedBy` for it. A plan that never used

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Both cases confirmed, and the fix went the other way: rather than extend the enumeration, 2d6d780 drops the claim that produced the gap.

The block no longer bills itself as the exact blast radius, and the pointer to it ("see the preservation merge below for the exact blast radius") is gone with the block above. What is left states necessary conditions only:

// Preservation only fires when the previous plan still has an
// unfinished item and the same id carried a non-empty `blockedBy`
// that this call omits; `[]` is not nullish, so it still clears.

That survives (1) — the cycle fallback discarding the stamped list means the three conditions are not sufficient, which "only fires when" never asserted. The fallback also keeps its own seven-line explanation fifteen lines below, in the same branch and visible in the same screenful, so restating it here would have been the third copy of the same fact.

I did not take the suggested wording because the whole point of this revision was length: the PR owner asked for the comments to be cut, and the two blocks went 25 lines → 8. Adding the two clauses back would put most of that back.

(2) is not a claim this comment makes — it is a real hazard about what the reply shows the model, not about when preservation fires. It is worth fixing, but echoing the preserved entries in the no-op reply is a behaviour change with a test to add (preservation ∩ no-op, which as you note nothing covers), so it does not belong in a comment-only PR. Noted in Risk & Scope as out of scope; happy to open the follow-up.

中文说明

两种情形都确认成立,修法反过来:2d6d780 没有去扩充枚举,而是撤掉了产生这个缺口的断言本身。

这段注释不再自称 "exact blast radius",上方指向它的那句("see the preservation merge below for the exact blast radius")也随上一段一起删掉了。剩下的只陈述必要条件(见上方代码块)。

这样就绕开了(1):环回退会丢弃被盖章的列表,说明三个条件并不充分,而 "only fires when" 从未断言充分性。而且环回退在下方十五行处保有它自己的七行解释,处于同一分支、同一屏内,在这里再复述一遍就是同一事实的第三份副本。

我没有采用建议的措辞,因为这次修订的全部目的就是长度:PR owner 要求精简注释,两段从 25 行减到 8 行,把那两个从句加回去会把削减掉的大部分又装回去。

(2)不是这段注释所作的断言——它是关于回复向模型展示了什么的真实隐患,而不是关于保留何时触发。它值得修,但在 no-op 回复中回显被保留的条目属于行为变更,还需要新增测试(你指出无人覆盖的 保留 ∩ no-op 形态),因此不属于一个纯注释 PR。已在 Risk & Scope 中标注为范围之外;需要的话我来开这个后续 PR。

// dependencies is untouched, because `undefined?.filter()` is
// `undefined` and the entry is returned as sent. Callers that always
// send the full dependency list are likewise unaffected, and `[]`
// remains the explicit clear (an empty array is not nullish, so it
// wins over the preserved value).
//
// Note the `blockedBy` schema description above ("Active-plan updates
// preserve omitted dependencies for existing IDs; use [] to remove
// them") actively invites that omission, and a tool schema is part of
// the prompt, so it reaches every session including ones with Session
// Workflow off. That text is therefore what widens the exposure of
// this branch rather than being independent of it.
let preservedAnyBlockedBy = false;
candidateTodos = todos.map((todo) => {
// Preserved edges may only reference ids that survive this update:
Expand Down
Loading