Skip to content

fix(agent): add return_exceptions=True to asyncio.gather in context ref expansion - #59043

Closed
x7peeps wants to merge 2 commits into
NousResearch:mainfrom
x7peeps:fix/context-refs-gather-return-exceptions
Closed

fix(agent): add return_exceptions=True to asyncio.gather in context ref expansion#59043
x7peeps wants to merge 2 commits into
NousResearch:mainfrom
x7peeps:fix/context-refs-gather-return-exceptions

Conversation

@x7peeps

@x7peeps x7peeps commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds return_exceptions=True to asyncio.gather() in preprocess_context_references_async() to prevent a single failing reference from crashing all concurrent expansions.

Problem

When processing multiple context references (e.g. @url:, @file:) concurrently via asyncio.gather(), if any one reference raises an unexpected exception (e.g. cancellation, network error, or any uncaught exception from the reference chain), the entire gather fails and all other valid references are lost. This means a single bad URL reference in a user message can silently drop all other context refs.

Fix

  • Add return_exceptions=True to the asyncio.gather() call at line 161
  • Iterate results and handle Exception items by appending them as warnings (consistent with how the function already handles warnings)
  • Continue processing remaining results normally
  • Minimal diff: 7 insertions, 2 deletions

Testing

  • Syntax check passed (py_compile)
  • Behavior verified

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint platform/whatsapp WhatsApp Business adapter P3 Low — cosmetic, nice to have labels Jul 5, 2026
@x7peeps

x7peeps commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #59954 (newer version covering context reference expansion + additional fixes in moa_loop and voice_mode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have platform/whatsapp WhatsApp Business adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants