A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Estimate context size from messages when the meter fails
lulu feizhu25900b66a382
diff --git a/ds-bot/src/host/parts.js b/ds-bot/src/host/parts.jsindex 658d9941..49739345 100644--- a/ds-bot/src/host/parts.js+++ b/ds-bot/src/host/parts.js@@ -142,7 +142,8 @@ export function install(rt) {const STEWARD_TIMEOUT_MS = 120_000const STEWARD_LINES = 40- // A broken provider adapter must not crash every turn; one warning is enough.+ // A broken provider adapter must not crash every turn; estimate from the+ // derived messages instead, with one warning.let measureWarned = falseconst tokensOf = (session) => {try {@@ -150,8 +151,12 @@ export function install(rt) {} catch (error) {if (!measureWarned) {measureWarned = true- rt.warn('ds-bot: token measure failed; context sizes are estimated without it: %s', error)+ rt.warn('ds-bot: token measure failed; context sizes are estimated: %s', error)}+ }+ try {+ return estimateTokens(session.deriveMessages().map(message => textOf(message.content)).join('\n'))+ } catch {return undefined}}