Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add deferral to RegisterAgentType and (Add/Remove)Subscription #5494

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

lokitoth
Copy link
Member

Unlike with the InProcessRuntime, there is a two-phase initialization, first when AgentsApp is built (when initial agents are registered) and when it StartAsync()s and connects to the Gateway. Unfortunately, it is possible to attempt to send direct RPC calls to the Gateway before the message channel is opened; in this case, the Gateway has no connected client corresponding to the RPC's clientId, and falls over.

The fix is to defer registering agents and subscriptions with the gateway until after the connection is established after .StartAsync() is called.

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.46%. Comparing base (540c4fb) to head (126b07c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5494      +/-   ##
==========================================
+ Coverage   75.10%   76.46%   +1.36%     
==========================================
  Files         167      205      +38     
  Lines        9911    11011    +1100     
  Branches        0      146     +146     
==========================================
+ Hits         7444     8420     +976     
- Misses       2467     2496      +29     
- Partials        0       95      +95     
Flag Coverage Δ
unittests 76.46% <100.00%> (+1.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Unlike with the InProcessRuntime, there is a two-phase initialization, first when AgentsApp is built (when initial agents are registered) and when it StartAsync()s and connects to the Gateway. Unfortunately, it is possible to attempt to send direct RPC calls to the Gateway before the message channel is opened; in this case, the Gateway has no connected client corresponding to the RPC's clientId, and falls over.

The fix is to defer registering agents and subscriptions with the gateway until after the connection is established after .StartAsync() is called.
@lokitoth lokitoth force-pushed the dev/fix_grpcagentruntime_startup branch from 1eb1b87 to 126b07c Compare February 11, 2025 20:03
@lokitoth lokitoth merged commit 392aa14 into main Feb 11, 2025
68 checks passed
@lokitoth lokitoth deleted the dev/fix_grpcagentruntime_startup branch February 11, 2025 21:03
lokitoth added a commit that referenced this pull request Feb 13, 2025
…registration (#5521)

This finishes the fix for the race condition between opening a
GrpcWorkerConnection and registering agent types on that worker. Now,
instead of failing to register, we return from the call (with the
expectation that we will finish registration as we set up the
connection)

Part 1: #5494 
Part 2: #5514

---------

Co-authored-by: Ryan Sweet <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants