diff --git a/apps/detail-agent-pi/src/agent.mjs b/apps/detail-agent-pi/src/agent.mjs index 88df9c98..1d8de126 100644 --- a/apps/detail-agent-pi/src/agent.mjs +++ b/apps/detail-agent-pi/src/agent.mjs @@ -381,9 +381,11 @@ export class DetailPiAgent { const cost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }; const retry = {enabled:true,maxRetries:3}; const workers = new Map(); + // Worker sessions are in memory, so the event log is the only place a failed tool's reason survives. const recordToolEvent = (event,activity,scope) => store.appendEvent({ type:event.type,toolName:event.toolName,toolCallId:event.toolCallId,isError:event.isError??false,...scope, ...(activity?{status:activity.status,phase:activity.phase,category:activity.category,durationMs:activity.durationMs}:null), + ...(event.isError?{error:event.result?.content?.find(item=>item.type==='text')?.text?.slice(0,300)}:null), }); runtime.registerProvider('jiansun-native-98k', { api, apiKey: 'native-broker-only', baseUrl: api === 'anthropic-messages' ? 'https://api.vip98k.com' : 'https://api.vip98k.com/v1', diff --git a/apps/detail-agent-pi/test/screen-review.test.mjs b/apps/detail-agent-pi/test/screen-review.test.mjs index fd0fe476..4a688bf9 100644 --- a/apps/detail-agent-pi/test/screen-review.test.mjs +++ b/apps/detail-agent-pi/test/screen-review.test.mjs @@ -171,6 +171,9 @@ test('waiting screen review returns its last rejection when Pi reaches the turn assert.equal(starts.length,WORKER_TURN_LIMIT); assert.equal(ends.length,WORKER_TURN_LIMIT); assert.ok(ends.every(event=>event.isError&&event.toolName==='review_output_screen')); + assert.ok(ends.every(event=>event.error.includes('overlayFixes[0].nativeLayerId')&&event.error.length<=300), + JSON.stringify(ends[0])); + assert.ok(starts.every(event=>event.error===undefined)); assert.deepEqual(ends.map(event=>event.toolCallId).sort(),starts.map(event=>event.toolCallId).sort()); });