Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions changelog.d/3144-own-chat-checkpoint-count.fixed.md
Original file line number Diff line number Diff line change
@@ -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)).
7 changes: 5 additions & 2 deletions core/src/host/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
Expand Down
20 changes: 20 additions & 0 deletions core/test/group-work.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 21 additions & 1 deletion patches/ds-bot/0001-core-fixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions patches/ds-bot/0012-room-membership.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down Expand Up @@ -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}`
}
Expand Down
Loading