fix(headless): terminal model failures reach stderr

This commit is contained in:
Tianyi Cui
2026-08-09 13:35:00 +08:00
parent 9d5eb37638
commit 63b6e18f71
11 changed files with 76 additions and 22 deletions

View File

@@ -29,6 +29,10 @@ class CliMockAdapter extends LlmAdapter {
}
async * stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
if (process.env.DSH_CLI_MOCK_FAILURE === '1') {
yield { type: 'finish', reason: { kind: 'error', failure: { code: 'SERVER', message: 'CLI mock provider failed' } } }
return
}
const toolResult = options.messages.at(-1)?.content.find(block => block.type === 'tool-result')
if (toolResult === undefined) {
const args = JSON.stringify({ command: 'printf CLI_TOOL_ROUND_TRIP', description: 'Prove the CLI tool round trip.' })