mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
test(tui-agent): match scripted triggers across the trailing user run
This branch intentionally appends plugin-sourced context (plan-mode notices, the skill catalog) after the prompt, so the request's last message is no longer the user's text. The scripted adapter keyed every scenario off messages.at(-1) only, missed its triggers, and fell through to the ask_user_question default — the frozen 'Waiting for the first token' PTY timeouts. It now scans all text since the last assistant message.
This commit is contained in:
@@ -51,10 +51,19 @@ class ScriptedTuiAdapter extends LlmAdapter {
|
|||||||
throw new Error('the scripted TUI request did not apply the selected model to routing and prompt variables')
|
throw new Error('the scripted TUI request did not apply the selected model to routing and prompt variables')
|
||||||
}
|
}
|
||||||
const lastMessage = options.messages.at(-1)
|
const lastMessage = options.messages.at(-1)
|
||||||
const lastText = (lastMessage?.content ?? [])
|
// The loop appends plugin-sourced context (the plan-mode notice, the
|
||||||
.filter(block => block.type === 'text')
|
// tool-skill catalog) AFTER the admitted prompt, so the scripted trigger
|
||||||
.map(block => block.text)
|
// may sit one or more user messages back: scan the whole trailing run of
|
||||||
.join('\n')
|
// user-role messages since the last assistant message.
|
||||||
|
const trailingUserTexts: string[] = []
|
||||||
|
for (let index = options.messages.length - 1; index >= 0; index--) {
|
||||||
|
const message = options.messages[index]
|
||||||
|
if (message?.role !== 'user') break
|
||||||
|
for (const block of message.content) {
|
||||||
|
if (block.type === 'text') trailingUserTexts.push(block.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const lastText = trailingUserTexts.join('\n')
|
||||||
if (lastText.includes(DEFAULT_MODE_PROBE)) {
|
if (lastText.includes(DEFAULT_MODE_PROBE)) {
|
||||||
if (options.system?.includes('Stay in plan mode for this scripted TUI test.')) {
|
if (options.system?.includes('Stay in plan mode for this scripted TUI test.')) {
|
||||||
throw new Error('the scripted TUI request retained plan guidance after /plan off')
|
throw new Error('the scripted TUI request retained plan guidance after /plan off')
|
||||||
|
|||||||
Reference in New Issue
Block a user