From 67cf86fb26ac34d6bc6d46bb26107100df00aae2 Mon Sep 17 00:00:00 2001 From: fujie Date: Sat, 28 Feb 2026 15:21:28 +0800 Subject: [PATCH] fix(pipes): yield artifacts string directly to stream flow avoiding emitter replacement --- .../github-copilot-sdk/github_copilot_sdk.py | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py b/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py index 4917751..7736de8 100644 --- a/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py +++ b/plugins/pipes/github-copilot-sdk/github_copilot_sdk.py @@ -1259,15 +1259,7 @@ class Pipe: } ) elif embed_type == "artifacts": - # OpenWebUI's srcdoc sandbox breaks external CDN module logic for very large files. - # Therefore, fallback to providing a direct iframe to the local backend URL for artifacts. - artifacts_content = ( - f'\n\n" - ) + artifacts_content = f"\n```html\n{embed_content}\n```\n" pending_embeds.append( { "filename": safe_filename, @@ -1276,7 +1268,7 @@ class Pipe: } ) logger.info( - f"[Copilot] Queued artifacts embed for '{safe_filename}', content len={len(artifacts_content)}, pending_embeds len={len(pending_embeds)}" + f"[Copilot] Queued artifacts embed for '{safe_filename}' (content={len(artifacts_content)}, queue={len(pending_embeds)})" ) if __event_emitter__: await __event_emitter__( @@ -5785,15 +5777,10 @@ class Pipe: } ) elif embed.get("type") == "artifacts": - # Artifacts mode appends as raw message - await __event_emitter__( - { - "type": "message", - "data": { - "content": embed["content"] - }, - } - ) + # Directly yield the markdown block to the response stream. + # This securely appends the code block to the final message, + # tricking OpenWebUI into rendering it as an artifact seamlessly. + yield embed["content"] # 3. LOCK internal status emission for background tasks # (Stray Task A from tool.execution_complete will now be discarded)