Skip to content

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

Keep a redacted tool result whole

Fei24118af773494fac
diff --git a/ds-bot/src/host/secrets.js b/ds-bot/src/host/secrets.js
index 05f46ebe..058deccb 100644
--- a/ds-bot/src/host/secrets.js
+++ b/ds-bot/src/host/secrets.js
@@ -483,22 +483,14 @@ export function install(rt) {
},
}))
- // Tool results lose the values before the registry renders and saves them: a fresh
- // result object is re-rendered from its value, so the model content, the saved
- // `tool/result`, and the tool card's presentation all come from the redacted value.
+ // Tool results lose the values before the registry renders and saves them. Every
+ // field is redacted — a wrapper further out in the pipeline still sees a whole
+ // result (its `content`, `meta`, and `additionalContexts` too), and the registry
+ // re-renders a changed success result from its redacted value.
ctx.on('tools/execute', async (exec, next) => {
const result = await next()
if (secrets.size === 0 || result === null || typeof result !== 'object') return result
- if (result.isError) {
- const content = redactDeep(result.content, redact)
- const meta = redactDeep(result.meta, redact)
- const error = redactDeep(result.error, redact)
- if (content === result.content && meta === result.meta && error === result.error) return result
- return { ...result, content, error, ...(meta !== undefined ? { meta } : {}) }
- }
- const value = redactDeep(result.value, redact)
- if (value === result.value) return result
- return { isError: false, value, ...(result.additionalContexts !== undefined ? { additionalContexts: result.additionalContexts } : {}) }
+ return redactDeep(result, redact)
})
// Anything that still carries a value (the user pasted it, an earlier part kept it)
diff --git a/ds-bot/test/secrets.test.js b/ds-bot/test/secrets.test.js
index 9b839280..373bafe8 100644
--- a/ds-bot/test/secrets.test.js
+++ b/ds-bot/test/secrets.test.js
@@ -304,7 +304,28 @@ test('tool results and model requests lose the values', async (t) => {
// The team tools' listener (working_directory) registers first.
const execute = bench.listeners['tools/execute'].at(-1)
const ok = await execute({}, async () => ({ isError: false, value: { kind: 'foreground', stdout: { text: `${value}\n`, truncated: false } }, content: [{ type: 'text', text: value }], meta: { stdout: value } }))
- assert.deepEqual(ok, { isError: false, value: { kind: 'foreground', stdout: { text: '[secret:DEMO_TOKEN]\n', truncated: false } } })
+ assert.equal(ok.isError, false)
+ assert.deepEqual(ok.value, { kind: 'foreground', stdout: { text: '[secret:DEMO_TOKEN]\n', truncated: false } })
+ // The rest of a changed result stays whole and loses the values too: a wrapper
+ // further out still reads its content and meta, and they are already redacted.
+ assert.deepEqual(ok.content, [{ type: 'text', text: '[secret:DEMO_TOKEN]' }])
+ assert.equal(ok.meta.stdout, '[secret:DEMO_TOKEN]')
+ const logged = await (async () => {
+ const result = await execute({}, async () => ({
+ isError: false,
+ value: { text: value },
+ content: [{ type: 'text', text: `out ${value}` }],
+ meta: { stdout: value },
+ additionalContexts: [{ role: 'user', content: [{ type: 'text', text: value }] }],
+ }))
+ // A logging wrapper reads `content` right after its next() — before the
+ // registry re-renders a success result from its value.
+ assert.equal(result.content.length, 1)
+ return result
+ })()
+ assert.equal(logged.content[0].text, 'out [secret:DEMO_TOKEN]')
+ assert.equal(logged.meta.stdout, '[secret:DEMO_TOKEN]')
+ assert.equal(logged.additionalContexts[0].content[0].text, '[secret:DEMO_TOKEN]')
const failed = await execute({}, async () => ({ isError: true, error: { message: `bad ${value}` }, content: [{ type: 'text', text: `bad ${value}` }] }))
assert.equal(failed.content[0].text, 'bad [secret:DEMO_TOKEN]')
assert.equal(failed.error.message, 'bad [secret:DEMO_TOKEN]')