From bf6b14f81e09600f0bb6385c9b53da98445baa95 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 9 Aug 2026 20:19:44 +0800 Subject: [PATCH] fix: Conform confirm creates AgentOutput and processes streaming response --- bricks/agent.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/bricks/agent.js b/bricks/agent.js index ff704be..0f1b0da 100644 --- a/bricks/agent.js +++ b/bricks/agent.js @@ -70,14 +70,27 @@ bricks.AgentOut = class extends bricks.VBox { w.bind('conformed', function(){ var payload = opts._payload || {}; payload._system_action = opts._action; - // Find parent AgentIO to get URL - var p = this.parent_widget; - while (p && !(p instanceof bricks.AgentIO)){ - p = p.parent_widget; + // Find parent AgentIO + var agentio = this.parent_widget; + while (agentio && !(agentio instanceof bricks.AgentIO)){ + agentio = agentio.parent_widget; } - if (p && p.opts && p.opts.url){ + if (agentio && agentio.opts && agentio.opts.url){ + // Create output widget and process streaming response + var mout = new bricks.AgentOutput({ + reply_url: agentio.opts.reply_url + }); + agentio.msg_box.add_widget(mout); var hr = new bricks.HttpResponseStream(); - hr.post(p.opts.url, {params: payload}); + hr.post(agentio.opts.url, {params: payload}).then(function(resp){ + if (resp){ + return hr.handle_chunk(resp, agentio.chunk_response.bind(agentio, mout)); + } else { + mout.run_stopped(); + } + }).then(function(){ + agentio.chunk_ended(); + }); } }.bind(this)); }