A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Hide <signature> blocks in Bot chat reasoning
Fei24114b166f4ef6f6
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 6f243504..59e86e40 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -7351,7 +7351,14 @@ function opensReply(steps, current, withReasoning = true) {var thinkingStep = (steps) => steps.find(thinkingLive);var thinkingLive = (step) => step.status === "running" && texts(step).length === 0 && step.blocks.some((block) => block.kind === "reasoning");var texts = (step) => step.blocks.filter((block) => block.kind === "text" && block.text.trim() !== "");-var stepReasoning = (step) => step.blocks.filter((block) => block.kind === "reasoning").map((block) => block.text).join("\n").trim();+var visibleReasoning = (text) => {+ if (text[0] !== "<") return text;+ if ("<signature>".startsWith(text)) return "";+ if (!text.startsWith("<signature>")) return text;+ const end = text.indexOf("</signature>");+ return end === -1 ? "" : text.slice(end + "</signature>".length).replace(/^(\r?\n)+/, "");+};+var stepReasoning = (step) => step.blocks.filter((block) => block.kind === "reasoning").map((block) => visibleReasoning(block.text)).join("\n").trim();// src/shared/group-replies.jsvar RELAY_LIST = /"replies"\s*:\s*\[/;diff --git a/ds-bot/src/client/turn-reasoning.js b/ds-bot/src/client/turn-reasoning.jsindex 17c82dfc..92fe1af3 100644--- a/ds-bot/src/client/turn-reasoning.js+++ b/ds-bot/src/client/turn-reasoning.js@@ -24,4 +24,15 @@ const thinkingLive = step => step.status === 'running' && texts(step).length ===const texts = step => step.blocks.filter(block => block.kind === 'text' && block.text.trim() !== '')-const stepReasoning = step => step.blocks.filter(block => block.kind === 'reasoning').map(block => block.text).join('\n').trim()+// Reasoning can open with a `<signature>` block meant for the model, not the+// reader; DSH's chat hides it since 0.2.1-rc.5 and the Bot chat strips it the+// same way, keeping the raw record in the session.+const visibleReasoning = text => {+ if (text[0] !== '<') return text+ if ('<signature>'.startsWith(text)) return ''+ if (!text.startsWith('<signature>')) return text+ const end = text.indexOf('</signature>')+ return end === -1 ? '' : text.slice(end + '</signature>'.length).replace(/^(\r?\n)+/, '')+}++const stepReasoning = step => step.blocks.filter(block => block.kind === 'reasoning').map(block => visibleReasoning(block.text)).join('\n').trim()diff --git a/ds-bot/test/turn-reasoning.test.js b/ds-bot/test/turn-reasoning.test.jsindex 9f4e0e12..374629eb 100644--- a/ds-bot/test/turn-reasoning.test.js+++ b/ds-bot/test/turn-reasoning.test.js@@ -41,6 +41,18 @@ test('the live step is the one still thinking', () => {assert.equal(thinkingStep(steps.slice(0, 1)), undefined)})+test('a `<signature>` block at the head of reasoning never shows', () => {+ // A signature alone leaves nothing to show, like DSH's hidden reasoning row.+ assert.equal(turnReasoning([], step(1, [think('<signature>abc123</signature>')])), '')+ assert.equal(turnReasoning([], step(1, [think('<signature>abc123</signature>\n\nReal thought')])), 'Real thought')+ assert.equal(turnReasoning([], step(1, [think('<signature>abc123</signature>\r\n\r\nReal thought')])), 'Real thought')+ // A stream that has only reached inside the tag shows nothing yet.+ assert.equal(turnReasoning([], step(1, [think('<sign')])), '')+ assert.equal(turnReasoning([], step(1, [think('<signature>abc123')])), '')+ // Text that only looks like it stays untouched.+ assert.equal(turnReasoning([], step(1, [think('A <signature> mention')])), 'A <signature> mention')+})+test('a step outside the loaded Turn list shows only its own reasoning', () => {const current = step(1, [think(' A ')])assert.equal(turnReasoning([], current), 'A')