From 9fe911dbf14ba7839a58d50d07f53f60df2f76b9 Mon Sep 17 00:00:00 2001 From: Day Dreamer <87640074+HugoXK@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:49:31 +0800 Subject: [PATCH] Say how many messages a condensed part still shows (#3144) A current part whose older messages a checkpoint condensed answered with its newest 12 messages and the words "only its newest messages", so a Bot could not tell that three of fifteen were left out; the bare read has said "newest 12 of 15" since #1906. The sentence now names how many of how many the read shows when the cap hid anything, and stays as before when it shows them all. patches/ds-bot/0001-core-fixes.patch and 0012-room-membership.patch are what `node scripts/ds-bot-patches.mjs generate` writes for this groups.js change; they are generated artifacts, not hand edits. `check` reports 10 patches apply cleanly in order and core/ equals ds-bot/ + patches/ds-bot/; `canonical` reports generate is a no-op; build-client --check is clean (no client change). Docs-not-needed: the changed sentence is the tool's own answer wording; docs/subsystems/core-host.md already states that the cap counts (#1906) and #2774 already documents the checkpoint answer, and neither statement changes. --- .../3144-own-chat-checkpoint-count.fixed.md | 1 + core/src/host/groups.js | 7 ++++-- core/test/group-work.test.js | 20 +++++++++++++++++ patches/ds-bot/0001-core-fixes.patch | 22 ++++++++++++++++++- patches/ds-bot/0012-room-membership.patch | 9 +++++--- 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 changelog.d/3144-own-chat-checkpoint-count.fixed.md diff --git a/changelog.d/3144-own-chat-checkpoint-count.fixed.md b/changelog.d/3144-own-chat-checkpoint-count.fixed.md new file mode 100644 index 000000000..3fa272164 --- /dev/null +++ b/changelog.d/3144-own-chat-checkpoint-count.fixed.md @@ -0,0 +1 @@ +When the current part of your own chat has its earlier messages condensed into a checkpoint, `read_own_chat` now says how many of the part's messages it still shows — `only its newest 12 of 15 messages` — instead of `only its newest messages`, so a message the cap left out no longer reads as if it never existed ([#3144](https://github.com/ThinkFlowLab/FlyBot/issues/3144)). diff --git a/core/src/host/groups.js b/core/src/host/groups.js index 07e0c29c6..78ef75cb6 100644 --- a/core/src/host/groups.js +++ b/core/src/host/groups.js @@ -1009,8 +1009,11 @@ export function install(rt) { // keeps the unchanged sentence rather than failing this read. } if (checkpoints === 0) return `Part ${number} is the current one; it is in your context.${partsNote}` - const { lines } = await rt.latestOwnChat(botId, { askingId: id }) - return `Part ${number} is the current one, but its earlier messages are condensed into [Checkpoint ${checkpoints}], so only its newest messages are still in your context:\n${lines.join('\n')}\nSearch it with words to read the rest word for word.${partsNote}` + const { lines, more } = await rt.latestOwnChat(botId, { askingId: id }) + // The cap hides the rest, so the sentence says how many of how many this read shows: + // the bare sentence let 12 of 15 read as the whole of it (#2780). + const newest = more > 0 ? `its newest ${lines.length} of ${lines.length + more} messages` : `its newest ${lines.length} messages` + return `Part ${number} is the current one, but its earlier messages are condensed into [Checkpoint ${checkpoints}], so only ${newest} are still in your context:\n${lines.join('\n')}\nSearch it with words to read the rest word for word.${partsNote}` } return `Part ${number} of your own chat (${rt.clock(part.startedAt)} – ${rt.clock(part.endedAt)}). The handoff note that closed it:\n${rt.noteText(part) ?? '(none: the part ended on a context overflow)'}${partsNote}` } diff --git a/core/test/group-work.test.js b/core/test/group-work.test.js index 540123f6f..6fa5b396a 100644 --- a/core/test/group-work.test.js +++ b/core/test/group-work.test.js @@ -591,6 +591,26 @@ test('a current part condensed by a checkpoint is not called "in your context" ( assert.match(out, /the url is https:\/\/example\.test\/xyz/, 'the newest lines are still shown') }) +// #2780: the bare read says "newest 12 of 15" (#1906), and a condensed current part hides the +// same way, but its sentence named no count — a Bot reading three of fifteen messages read as +// if that was all the part ever held. +test('a condensed current part says how many of its messages it still shows (#2780)', async (t) => { + const history = { b: Array.from({ length: 15 }, (_, seq) => chatLine(seq, `message ${seq} in one part`)) } + const host = await start(t, undefined, history) + host.agentOf('b').session.deriveMessages = () => checkpointMessages(1) + const out = await host.tool('read_own_chat', { part: 1 }, 'b') + assert.equal(shownLines(out).length, 12, out) + assert.match(out, /newest 12 of 15/, `the read hid three messages without saying so: ${out}`) + + // A short part shows all of them, and then no count clause is owed. + const short = { b: Array.from({ length: 3 }, (_, seq) => chatLine(seq, `message ${seq} in one part`)) } + const brief = await start(t, undefined, short) + brief.agentOf('b').session.deriveMessages = () => checkpointMessages(1) + const briefOut = await brief.tool('read_own_chat', { part: 1 }, 'b') + assert.equal(shownLines(briefOut).length, 3, briefOut) + assert.doesNotMatch(briefOut, /newest 3 of 3/, briefOut) +}) + test('a current part with no checkpoint, and an ended or missing part, answer as before (#2774)', async (t) => { const history = { b: [chatLine(0, 'first line'), chatLine(1, 'second line')] } const host = await start(t, undefined, history) diff --git a/patches/ds-bot/0001-core-fixes.patch b/patches/ds-bot/0001-core-fixes.patch index 52e5c247c..3be5e64a5 100644 --- a/patches/ds-bot/0001-core-fixes.patch +++ b/patches/ds-bot/0001-core-fixes.patch @@ -12533,7 +12533,7 @@ diff --git a/test/group-work.test.js b/test/group-work.test.js const text = message => message.content.map(block => block.text ?? '').join('\n') const kinds = result => result.replies.map(reply => [reply.kind ?? 'message', reply.name]) -@@ -287,3 +287,314 @@ test('members still at work show in the team view and in the prompts of the othe +@@ -287,3 +287,334 @@ test('members still at work show in the team view and in the prompts of the othe host.finish('gc', '没问题。') await settle(() => result() !== undefined) }) @@ -12828,6 +12828,26 @@ diff --git a/test/group-work.test.js b/test/group-work.test.js + assert.match(out, /the url is https:\/\/example\.test\/xyz/, 'the newest lines are still shown') +}) + ++// #2780: the bare read says "newest 12 of 15" (#1906), and a condensed current part hides the ++// same way, but its sentence named no count — a Bot reading three of fifteen messages read as ++// if that was all the part ever held. ++test('a condensed current part says how many of its messages it still shows (#2780)', async (t) => { ++ const history = { b: Array.from({ length: 15 }, (_, seq) => chatLine(seq, `message ${seq} in one part`)) } ++ const host = await start(t, undefined, history) ++ host.agentOf('b').session.deriveMessages = () => checkpointMessages(1) ++ const out = await host.tool('read_own_chat', { part: 1 }, 'b') ++ assert.equal(shownLines(out).length, 12, out) ++ assert.match(out, /newest 12 of 15/, `the read hid three messages without saying so: ${out}`) ++ ++ // A short part shows all of them, and then no count clause is owed. ++ const short = { b: Array.from({ length: 3 }, (_, seq) => chatLine(seq, `message ${seq} in one part`)) } ++ const brief = await start(t, undefined, short) ++ brief.agentOf('b').session.deriveMessages = () => checkpointMessages(1) ++ const briefOut = await brief.tool('read_own_chat', { part: 1 }, 'b') ++ assert.equal(shownLines(briefOut).length, 3, briefOut) ++ assert.doesNotMatch(briefOut, /newest 3 of 3/, briefOut) ++}) ++ +test('a current part with no checkpoint, and an ended or missing part, answer as before (#2774)', async (t) => { + const history = { b: [chatLine(0, 'first line'), chatLine(1, 'second line')] } + const host = await start(t, undefined, history) diff --git a/patches/ds-bot/0012-room-membership.patch b/patches/ds-bot/0012-room-membership.patch index b4df76998..a417b19d5 100644 --- a/patches/ds-bot/0012-room-membership.patch +++ b/patches/ds-bot/0012-room-membership.patch @@ -2096,7 +2096,7 @@ diff --git a/src/host/groups.js b/src/host/groups.js const parts = rt.partsOf(botId) const number = Number.isInteger(args.part) ? args.part : undefined if (room !== undefined && member !== undefined) { -@@ -507,23 +507,49 @@ export function install(rt) { +@@ -507,23 +507,52 @@ export function install(rt) { const found = await rt.aroundOwnChat(botId, around) if (found.error) return `${found.error}${partsNote}` if (found.lines.length === 0) return `Nothing was said around ${around}.${partsNote}` @@ -2127,8 +2127,11 @@ diff --git a/src/host/groups.js b/src/host/groups.js + // keeps the unchanged sentence rather than failing this read. + } + if (checkpoints === 0) return `Part ${number} is the current one; it is in your context.${partsNote}` -+ const { lines } = await rt.latestOwnChat(botId, { askingId: id }) -+ return `Part ${number} is the current one, but its earlier messages are condensed into [Checkpoint ${checkpoints}], so only its newest messages are still in your context:\n${lines.join('\n')}\nSearch it with words to read the rest word for word.${partsNote}` ++ const { lines, more } = await rt.latestOwnChat(botId, { askingId: id }) ++ // The cap hides the rest, so the sentence says how many of how many this read shows: ++ // the bare sentence let 12 of 15 read as the whole of it (#2780). ++ const newest = more > 0 ? `its newest ${lines.length} of ${lines.length + more} messages` : `its newest ${lines.length} messages` ++ return `Part ${number} is the current one, but its earlier messages are condensed into [Checkpoint ${checkpoints}], so only ${newest} are still in your context:\n${lines.join('\n')}\nSearch it with words to read the rest word for word.${partsNote}` + } return `Part ${number} of your own chat (${rt.clock(part.startedAt)} – ${rt.clock(part.endedAt)}). The handoff note that closed it:\n${rt.noteText(part) ?? '(none: the part ended on a context overflow)'}${partsNote}` }