Skip to content

fix(agent): add return_exceptions=True to asyncio.gather in context_references - #58808

Closed
x7peeps wants to merge 1 commit into
NousResearch:mainfrom
x7peeps:fix/asyncio-gather-return
Closed

fix(agent): add return_exceptions=True to asyncio.gather in context_references#58808
x7peeps wants to merge 1 commit into
NousResearch:mainfrom
x7peeps:fix/asyncio-gather-return

Conversation

@x7peeps

@x7peeps x7peeps commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Add to the call in so that a single failing reference expansion doesn't cancel all sibling coroutines.

Problem

Without , if one call raises (e.g., network timeout on a remote URL, permission error on a local file), the exception propagates immediately and cancels all other in-flight expansions. The agent loses all successfully expanded references.

Fix

  • Add to the gather call
  • After gathering, iterate results and filter out exceptions, adding them to the warnings list
  • Successful expansions still render normally

Testing

  • Verified syntax:
  • Single-file change (+8/-2 lines)
  • Follows the pattern already used in other gather calls in the codebase (e.g. )

…eferences

Without return_exceptions=True, a single failing _expand_reference call cancels
all sibling coroutines and propagates the exception up, losing all successful
expansions. This is especially problematic when refs include a mix of local files
and remote URLs — a network timeout on one URL would kill the entire expansion.

With return_exceptions=True, failed refs are caught and added to the warnings
list while successful ones still render. This matches the pattern already used
in other gather calls in the codebase (e.g. agent learning_graph_render.py).
@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 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 of the same context reference expansion fix).

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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants