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
This commit is contained in:
Classic298 2026-10-27 22:26:35 +01:00 • committed by GitHub
parent 1c572c49bc
commit e77204559b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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.'