From e77204559bd92b43b7320ab128aac768e9be23db Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 27 Oct 2026 22:26:35 +0100 Subject: [PATCH] fix: foreground sub-agent loses its partial output at the tool-call limit (#33269) When a foreground sub-agent stopped at the tool-call limit, the parent model got only the error, so everything the sub-agent had written before the limit was lost, while a background sub-agent in the same state reported it as partial output. A foreground sub-agent now returns the error followed by its partial output, the same way the background report does. The error in both modes is now the plain message, such as "Tool-call limit reached (30 iterations).", instead of raw internal data around it. Fixes #33267 --- backend/open_webui/utils/subagents.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/subagents.py b/backend/open_webui/utils/subagents.py index b63755a89f..3389f4729a 100644 --- a/backend/open_webui/utils/subagents.py +++ b/backend/open_webui/utils/subagents.py @@ -526,6 +526,8 @@ async def delegate( if len(summary) > max_output: summary = f'{summary[:max_output]}\n\n[output truncated]' error = message.get('error') + if isinstance(error, dict): + error = error.get('content') or 'Sub-agent failed.' return { 'status': 'error' if error else 'completed', 'summary': summary or ('Sub-agent produced no output.' if not error else ''), @@ -713,5 +715,8 @@ async def delegate( return f'Error: {exc}' if result.get('status') != 'completed': - return f'Error: {result.get("error") or "sub-agent failed."}' + error_text = f'Error: {result.get("error") or "sub-agent failed."}' + if result.get('summary'): + return f'{error_text}\nPartial output:\n{result["summary"]}' + return error_text return result.get('summary') or 'Sub-agent produced no output.'