Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

host: answer the agent's own questions as unavailable so a turn never waits for a missing answerer

Niko1221cfd45e0c4d15
diff --git a/apps/host/server/agent/agent-bridge.mjs b/apps/host/server/agent/agent-bridge.mjs
index 5239f92d7..0117612bb 100644
--- a/apps/host/server/agent/agent-bridge.mjs
+++ b/apps/host/server/agent/agent-bridge.mjs
@@ -157,6 +157,10 @@ export function createAgentBridge({ dataDir, componentsDir = null, localInstance
const r = value.request ?? {};
if (!r.callId) return;
pending.set(`${value.agentId}:${r.callId}`, { eventId: value.eventId, sessionId: value.agentId, callId: r.callId, tool: r.toolName, reason: r.reason ?? null, at: Date.now(), clientId: runtime.clientId });
+ } else if (value.type === 'waterfall' && value.event === 'user-questions/request') {
+ // The app has no surface for the agent's own questions yet. Declaring that nobody can answer makes
+ // the tool return an error the model reads and carries on from, instead of a turn that waits forever.
+ void runtime.gw.answerEvent({ clientId: runtime.clientId, eventId: value.eventId, outcome: 'next' }).catch(() => {});
} else if (value.type === 'cancel') {
for (const [k, v] of pending) if (v.eventId === value.eventId) pending.delete(k);
}
diff --git a/apps/host/tests/agent-bridge.test.mjs b/apps/host/tests/agent-bridge.test.mjs
index 494d35cab..46c900801 100644
--- a/apps/host/tests/agent-bridge.test.mjs
+++ b/apps/host/tests/agent-bridge.test.mjs
@@ -283,3 +283,15 @@ test('a leftover agent from a host that died is stopped at the next start, and a
await new Promise(x => setTimeout(x, 300));
assert.equal(bystander.exitCode, null, 'an unrelated process is left alone');
});
+
+test('a question the agent asks the person does not hang the turn: it is declared unanswerable and the model carries on', { skip }, async t => {
+ const r = await rig(t);
+ const { frames, promise } = r.run('chat-ask', 'SCRIPT:ask');
+ const result = await Promise.race([promise, new Promise(x => setTimeout(() => x('hung'), 30_000))]);
+ assert.notEqual(result, 'hung', 'the turn must not wait forever for an answerer that does not exist');
+ assert.equal(frames.at(-1).type, 'done');
+ const card = frames.filter(f => f.type === 'agent-tool').at(-1).tool;
+ assert.equal(card.name, 'ask_user_question');
+ assert.equal(card.state, 'error', 'the tool reports that no one could answer');
+ assert.match(text(frames), /Tool finished/, 'the model got the result back and finished');
+});
diff --git a/apps/host/tests/helpers/scripted-worker.mjs b/apps/host/tests/helpers/scripted-worker.mjs
index cd0c03f55..62f12d5f4 100644
--- a/apps/host/tests/helpers/scripted-worker.mjs
+++ b/apps/host/tests/helpers/scripted-worker.mjs
@@ -15,6 +15,7 @@
* wider access, so the approval gate is exercised
* SCRIPT:plain <file> <text> the same call without the escalation (no approval needed)
* SCRIPT:echo <text> replies with <text>
+ * SCRIPT:ask one ask_user_question call (the agent asking the person something)
* SCRIPT:envdump <file> one shell call that writes the shell's environment to <file>
*
* A request whose last message is a tool result is answered with a text that quotes the result.
@@ -81,6 +82,11 @@ export async function startScriptedWorker({ port = 0, chunkDelayMs = 40, model =
return say(Array.from({ length: n }, (_, i) => `w${i} `));
}
if (name === 'echo') return say([args]);
+ if (name === 'ask') {
+ send({ role: 'assistant', content: '' });
+ send({ tool_calls: [{ index: 0, id: `call_${requests.length}`, type: 'function', function: { name: 'ask_user_question', arguments: JSON.stringify({ questions: [{ id: 'q1', question: 'Which colour?', options: [{ label: 'Red' }, { label: 'Blue' }] }] }) } }] });
+ return finish('tool_calls', 20);
+ }
if (name === 'tool' || name === 'plain' || name === 'envdump') {
const [file, ...rest] = args.split(/\s+/);
const shell = (body.tools ?? []).find(t => ['bash', 'pwsh'].includes(t.function?.name))?.function?.name ?? 'bash';