Skip to content

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

Closed
x7peeps wants to merge 1 commit into
NousResearch:mainfrom
x7peeps:fix/context-refs-add-return-exceptions
Closed

fix(agent): add return_exceptions to asyncio.gather in context ref expansion#61775
x7peeps wants to merge 1 commit into
NousResearch:mainfrom
x7peeps:fix/context-refs-add-return-exceptions

Conversation

@x7peeps

@x7peeps x7peeps commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Add return_exceptions=True to asyncio.gather() in preprocess_context_references_async and guard the result loop against BaseException.

Problem

agent/context_references.py called asyncio.gather() without return_exceptions=True. If one reference expansion (e.g., a URL fetch or file read) fails, the exception propagates immediately and crashes the entire gather, aborting the agent turn — even when other references would have resolved fine.

Fix

  1. Added return_exceptions=True to the gather call.
  2. Updated the result iteration to check isinstance(result, BaseException) and append a warning instead of crashing.

Testing

  • Syntax check passed (py_compile)
  • Behavior verified

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

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: #59954 (the current open sibling with the same return_exceptions=True gather guard) and the wider preprocess_context_references_async gather-guard cluster (#57780 now closed-unmerged, #55207 the merged in-file concurrent-@-expansion). This is the clean single-file version of the shared hunk — verified the fix is not yet on main. Not a duplicate (subset/variant of a larger open PR is related, never dup); a human should pick the canonical entrant.

@x7peeps

x7peeps commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing as duplicate

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