Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Show a resumed or retried request as an event, not a new message

Fei24113d6e66881b98
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 0076544c..b3a82952 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -1523,7 +1523,8 @@ function toolArgs(root) {
var RELAY_ROLES = /* @__PURE__ */ new Set(["request", "reply", "stopped"]);
var isRelayContext = (data) => {
const source = data?.source;
- if (source === null || typeof source !== "object" || source.kind !== "bot" || source.handoff === true || source.deferred === true) return false;
+ if (source === null || typeof source !== "object" || source.kind !== "bot" || source.handoff === true) return false;
+ if (source.deferred === true || source.resumed === true || source.retried === true) return false;
return RELAY_ROLES.has(source.role) && typeof source.senderSessionId === "string";
};
var stepShows = (step) => (step?.blocks ?? []).some((block) => {
@@ -4058,7 +4059,7 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
const source = data.source !== null && typeof data.source === "object" ? data.source : {};
const selfId = roster.byId[sessionId]?.id ?? sessionId;
const deferred = source.kind === "bot" && source.deferred === true;
- const relayed = source.kind === "bot" && source.handoff !== true && !deferred && (source.role === "request" || source.role === "reply" || source.role === "stopped") && typeof source.senderSessionId === "string";
+ const relayed = isRelayContext(data);
const turn = node.location?.turn?.turn ?? data.turn;
(0, import_react6.useLayoutEffect)(() => {
if (relayed) actions.noteTurnPeer(sessionId, turn, source.senderSessionId);
@@ -4085,8 +4086,6 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
if (source.handoff === true) return roster.roomsById[sessionId] ? null : (0, import_react6.createElement)(EarlierParts, { sessionId, roster, actions });
if (source.role === "kickoff" || source.role === "room") return null;
if (source.role === "secret" || deferred) return null;
- if (source.role === "resume") return (0, import_react6.createElement)("div", { className: "bt-event" }, t("Picked up its work after a restart"));
- if (source.role === "retry") return (0, import_react6.createElement)("div", { className: "bt-event" }, t("Asked to make the tool call it wrote as text"));
if (source.role === "post") {
if (source.failed !== void 0 || source.resumed === true) return null;
const room2 = roster.roomsById[sessionId];
@@ -4096,6 +4095,8 @@ function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnClock, us
if (source.role === "report") {
return (0, import_react6.createElement)(GroupEvent, { prefix: t("Replies from"), room: roster.roomsById[source.roomId], name: t("a group chat"), roster, actions });
}
+ if (source.role === "resume" || source.resumed === true) return (0, import_react6.createElement)("div", { className: "bt-event" }, t("Picked up its work after a restart"));
+ if (source.role === "retry" || source.retried === true) return (0, import_react6.createElement)("div", { className: "bt-event" }, t("Asked to make the tool call it wrote as text"));
const run = relayed ? commRunOf(
order.split(",").filter(Boolean).map(Number),
Object.fromEntries(peers.split(",").filter(Boolean).map((pair) => [Number(pair.slice(0, pair.indexOf(":"))), pair.slice(pair.indexOf(":") + 1)])),
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index 5764be1a..b638a349 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -2,7 +2,7 @@ import { createElement as h, Fragment, useEffect, useLayoutEffect, useRef, useSt
import { createPortal } from 'react-dom'
import { MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives'
import { inkText } from './inks.js'
-import { linkMentions, mentionTarget, dayLabel, contentText, stripHeader, isHiddenTurn, relaysBefore, relayPart, commRunOf, toolName, toolArgs, reminderPrompts } from './text.js'
+import { linkMentions, mentionTarget, dayLabel, contentText, stripHeader, isHiddenTurn, isRelayContext, relaysBefore, relayPart, commRunOf, toolName, toolArgs, reminderPrompts } from './text.js'
import { SmileIcon, ReplyIcon, DotsIcon, CheckIcon, DownloadIcon, CopyIcon, MemoryIcon } from './icons.js'
import { colorOf, toolState, BotMark, RoomAvatar } from './mark.js'
import { AnsweredCell, SettledQuestion, PendingQuestion } from './questions.js'
@@ -288,7 +288,7 @@ export function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnCl
// A deferred request was already shown where the Bot read it mid-turn; the turn
// that answers it adds no second line.
const deferred = source.kind === 'bot' && source.deferred === true
- const relayed = source.kind === 'bot' && source.handoff !== true && !deferred && (source.role === 'request' || source.role === 'reply' || source.role === 'stopped') && typeof source.senderSessionId === 'string'
+ const relayed = isRelayContext(data)
const turn = node.location?.turn?.turn ?? data.turn
// Noted before paint so a folded line never flashes in before its run's first line.
useLayoutEffect(() => {
@@ -324,8 +324,6 @@ export function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnCl
if (source.role === 'kickoff' || source.role === 'room') return null
// The secret card itself shows what the user did; the note to the Bot stays out.
if (source.role === 'secret' || deferred) return null
- if (source.role === 'resume') return h('div', { className: 'bt-event' }, t('Picked up its work after a restart'))
- if (source.role === 'retry') return h('div', { className: 'bt-event' }, t('Asked to make the tool call it wrote as text'))
if (source.role === 'post') {
// A member's late failure, or its work picked up after a restart, shows as an
// event of the round it opens.
@@ -337,6 +335,9 @@ export function TriggerCell({ node, sessionId, useRoster, useSessions, useTurnCl
if (source.role === 'report') {
return h(GroupEvent, { prefix: t('Replies from'), room: roster.roomsById[source.roomId], name: t('a group chat'), roster, actions })
}
+ // A request carried on keeps its role, but its message line was shown already.
+ if (source.role === 'resume' || source.resumed === true) return h('div', { className: 'bt-event' }, t('Picked up its work after a restart'))
+ if (source.role === 'retry' || source.retried === true) return h('div', { className: 'bt-event' }, t('Asked to make the tool call it wrote as text'))
const run = relayed ? commRunOf(
order.split(',').filter(Boolean).map(Number),
Object.fromEntries(peers.split(',').filter(Boolean).map(pair => [Number(pair.slice(0, pair.indexOf(':'))), pair.slice(pair.indexOf(':') + 1)])),
diff --git a/ds-bot/src/client/text.js b/ds-bot/src/client/text.js
index c52f6a12..9fedd6f5 100644
--- a/ds-bot/src/client/text.js
+++ b/ds-bot/src/client/text.js
@@ -122,12 +122,14 @@ export function toolArgs(root) {
// A relay context is a Bot-to-Bot request, reply or stop notice injected into the
// model's history. ds-bot's own package sources (kickoff, room, secret, handoff
-// parts) are not events in the chat, nor is a deferred request handed back after
-// its line was already shown.
+// parts) are not events in the chat, nor is a request handed back after its line was
+// already shown: deferred, resumed after a restart, or retried after a tool call
+// written as text.
const RELAY_ROLES = new Set(['request', 'reply', 'stopped'])
export const isRelayContext = (data) => {
const source = data?.source
- if (source === null || typeof source !== 'object' || source.kind !== 'bot' || source.handoff === true || source.deferred === true) return false
+ if (source === null || typeof source !== 'object' || source.kind !== 'bot' || source.handoff === true) return false
+ if (source.deferred === true || source.resumed === true || source.retried === true) return false
return RELAY_ROLES.has(source.role) && typeof source.senderSessionId === 'string'
}
diff --git a/ds-bot/test/tool-node.test.js b/ds-bot/test/tool-node.test.js
index 1ab8e3b1..64836e5b 100644
--- a/ds-bot/test/tool-node.test.js
+++ b/ds-bot/test/tool-node.test.js
@@ -104,7 +104,9 @@ test('non-relay context and ds-bot package sources are ignored', () => {
{ time: 24, source: { kind: 'agent-instructions' } },
{ time: 26, source: null },
relay(27, 'request', { deferred: true }),
+ relay(27, 'request', { resumed: true }),
+ relay(27, 'stopped', { retried: true }),
relay(28, 'request'),
]
- assert.deepEqual(relaysBefore(contexts, steps, steps[1]), [contexts[8]])
+ assert.deepEqual(relaysBefore(contexts, steps, steps[1]), [contexts[10]])
})