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

Agent Runtime Gateway Registration Consistency xLang #5755

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lokitoth
Copy link
Member

The behaviour of registration in the .NET Runtime Gateway and the Python Runtime Gateway was inconsistent: .NET allowed arbitrary numbers of clients to register the same agent type, Python did not allow duplicate agent types even in the case of re-registration by the same client.

Per discussion, the decision was to meet in the middle and support re-registration but not multiplexing in the Python, and per further discussion, we decided to allow re-enabling multiplexing mode in .NET.

Closes #5314

@lokitoth lokitoth changed the title Dev/fix agent registration consistency Agent Runtime Gateway Registration Consistency xLang Feb 28, 2025
@rysweet rysweet marked this pull request as draft February 28, 2025 20:01
Copy link
Collaborator

@rysweet rysweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lokitoth - looks like you need to run the formatters....

@lokitoth lokitoth force-pushed the dev/fix_agent_registration_consistency branch from f8a494c to fb61390 Compare March 5, 2025 15:09
@lokitoth lokitoth marked this pull request as ready for review March 5, 2025 15:10
lokitoth added 2 commits March 5, 2025 10:13
The behaviour of registration in the .NET Runtime Gateway and the Python Runtime Gateway was inconsistent: .NET allowed arbitrary numbers of clients to register the same agent type, Python did not allow duplicate agent types even in the case of re-registration by the same client.

Per discussion, the decision was to meet in the middle and support re-registration but not multiplexing in the Python, and per further discussion, we decided to allow re-enabling multiplexing mode in .NET.
@lokitoth lokitoth force-pushed the dev/fix_agent_registration_consistency branch from fb61390 to 9ce8679 Compare March 5, 2025 15:14
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 0% with 50 lines in your changes missing coverage. Please review.

Project coverage is 34.33%. Comparing base (05b14f1) to head (c354731).

Files with missing lines Patch % Lines
...n/RuntimeGateway.Grpc/Services/Grpc/GrpcGateway.cs 0.00% 38 Missing and 6 partials ⚠️
...eway.Grpc/Services/AgentWorkerHostingExtensions.cs 0.00% 2 Missing and 1 partial ⚠️
...Gateway.Grpc/Services/Grpc/GrpcWorkerConnection.cs 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5755       +/-   ##
===========================================
- Coverage   70.16%   34.33%   -35.83%     
===========================================
  Files         262       73      -189     
  Lines       14712     2024    -12688     
  Branches      243      251        +8     
===========================================
- Hits        10322      695     -9627     
+ Misses       4200     1131     -3069     
- Partials      190      198        +8     
Flag Coverage Δ
unittests 34.33% <0.00%> (-35.83%) ⬇️

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.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -6,6 +6,15 @@

namespace Microsoft.AutoGen.RuntimeGateway.Grpc;

public static class ServerCallContextExtensions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding this - probably several other places we could compress/delete code and point to this.

if (!_options.SupportAgentTypeMultiplexing &&
_supportedAgentTypes.TryGetValue(request.Type, out List<GrpcWorkerConnection>? currentWorkers))
{
// We should never have more than one worker unless SupportAgentTypeMultiplexing is true, so the first time we
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// We should never have more than one worker unless SupportAgentTypeMultiplexing is true, so the first time we
// We should never have more than one worker with the same agent type unless SupportAgentTypeMultiplexing is true, so the first time we


await _gatewayRegistry.RegisterAgentTypeAsync(request, clientId, _reference).ConfigureAwait(true);
// If we are not supporting multiplexing, we need to ensure that the agent type is not already registered by
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be other gateways. - the logic here only works fr this one - Shouldn't this be in the RegistryGrain.RegisterAgentType instead, and there you should use RegistryGrain.GetOrAddWorker() to find out if you have a connection already registered for this type?

connection.AddSupportedType(request.Type);
_supportedAgentTypes.GetOrAdd(request.Type, _ => []).Add(connection);

await _gatewayRegistry.RegisterAgentTypeAsync(request, clientId, _reference).ConfigureAwait(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per above - I thik its really in this function that you want to do this...

/// <summary>
/// Contains options for configuring the gRPC gateway.
/// </summary>
public sealed class GrpcGatewayOptions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be in its own file?

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.

Inconsistent Behavior in Agent Registration Between .NET and Python Libraries
3 participants