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

rysweet-unsubscribe-and-agent-tests-4744 #4920

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

rysweet
Copy link
Collaborator

@rysweet rysweet commented Jan 7, 2025

Why are these changes needed?

adds unsubscribe api
adds tests for most all of Agent and AgentWorker

Related issue number

closes #4744
closes #4357

Checks

@rysweet rysweet linked an issue Jan 7, 2025 that may be closed by this pull request
@rysweet rysweet requested a review from Copilot January 7, 2025 17:20
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 105 out of 120 changed files in this pull request and generated 3 comments.

Files not reviewed (15)
  • dotnet/AutoGen.sln: Language not supported
  • dotnet/Directory.Packages.props: Language not supported
  • dotnet/samples/dev-team/DevTeam.AgentHost/DevTeam.AgentHost.csproj: Language not supported
  • dotnet/samples/dev-team/DevTeam.AgentHost/Properties/launchSettings.json: Language not supported
  • dotnet/samples/dev-team/DevTeam.AgentHost/appsettings.Development.json: Language not supported
  • dotnet/samples/dev-team/DevTeam.Agents/DevTeam.Agents.csproj: Language not supported
  • dotnet/samples/dev-team/DevTeam.Agents/Properties/launchSettings.json: Language not supported
  • dotnet/samples/dev-team/DevTeam.Agents/appsettings.Development.json: Language not supported
  • dotnet/samples/dev-team/DevTeam.AgentHost/Program.cs: Evaluated as low risk
  • dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs: Evaluated as low risk
  • dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.cs: Evaluated as low risk
  • dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.cs: Evaluated as low risk
  • dotnet/samples/dev-team/DevTeam.Agents/Program.cs: Evaluated as low risk
  • README.md: Evaluated as low risk
  • dotnet/samples/Hello/HelloAIAgents/Program.cs: Evaluated as low risk
Comments suppressed due to low confidence (1)

dotnet/samples/Hello/HelloAgent/Program.cs:59

  • The SayHello method now accepts a CancellationToken, but the Handle method does not pass the cancellationToken to it. Ensure that the cancellationToken is propagated correctly.
public async Task<string> SayHello(string ask, CancellationToken cancellationToken = default)

typeRegistry),
IHandleConsole,
IHandle<NewMessageReceived>,
IHandle<ConversationClosed>,
IHandle<Shutdown>
{
private AgentState? State { get; set; }
public async Task Handle(NewMessageReceived item)
public async Task Handle(NewMessageReceived item, CancellationToken cancellationToken = default)
Copy link
Preview

Copilot AI Jan 7, 2025

Choose a reason for hiding this comment

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

The CancellationToken parameter is not being used within the method to handle cancellation.

Suggested change
public async Task Handle(NewMessageReceived item, CancellationToken cancellationToken = default)
var response = await SayHello(item.Message, cancellationToken).ConfigureAwait(false);

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -57,7 +55,7 @@ await StoreAsync(new AgentState
await PublishMessageAsync(new Shutdown { Message = this.AgentId.Key }).ConfigureAwait(false);

}
public async Task Handle(ConversationClosed item)
public async Task Handle(ConversationClosed item, CancellationToken cancellationToken = default)
Copy link
Preview

Copilot AI Jan 7, 2025

Choose a reason for hiding this comment

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

The CancellationToken parameter is not being used within the method to handle cancellation.

Suggested change
public async Task Handle(ConversationClosed item, CancellationToken cancellationToken = default)
State = await ReadAsync<AgentState>(this.AgentId, cancellationToken).ConfigureAwait(false);

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -74,7 +72,7 @@ await StoreAsync(new AgentState
TextData = JsonSerializer.Serialize(state)
}).ConfigureAwait(false);
}
public async Task Handle(Shutdown item)
public async Task Handle(Shutdown item, CancellationToken cancellationToken = default)
Copy link
Preview

Copilot AI Jan 7, 2025

Choose a reason for hiding this comment

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

The CancellationToken parameter is not being used within the method to handle cancellation.

Suggested change
public async Task Handle(Shutdown item, CancellationToken cancellationToken = default)
await Task.Delay(0, cancellationToken);

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 36 lines in your changes missing coverage. Please review.

Project coverage is 68.34%. Comparing base (50b1721) to head (11558c2).

Files with missing lines Patch % Lines
...togen_ext/runtimes/grpc/protos/agent_worker_pb2.py 4.16% 23 Missing ⚠️
..._ext/runtimes/grpc/protos/agent_worker_pb2_grpc.py 50.00% 12 Missing ⚠️
...ext/runtimes/grpc/_worker_runtime_host_servicer.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4920      +/-   ##
==========================================
- Coverage   68.37%   68.34%   -0.04%     
==========================================
  Files         157      157              
  Lines       10078    10102      +24     
==========================================
+ Hits         6891     6904      +13     
- Misses       3187     3198      +11     
Flag Coverage Δ
unittests 68.34% <33.33%> (-0.04%) ⬇️

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.

Comment on lines +53 to +54
repeated string events = 3;
repeated string topics = 4;
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what these are for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

allows for complete subscription management from registration vs after I think - I've asked Kosta to comment. this was part of his refactor.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, at the point of registration we (at least on the .net side) know all of the events/topics the agent is interested in, no reason to do separate grpc calls to pass that information.

Comment on lines 126 to +129
RegisterAgentTypeRequest registerAgentTypeRequest = 4;
RegisterAgentTypeResponse registerAgentTypeResponse = 5;
AddSubscriptionRequest addSubscriptionRequest = 6;
AddSubscriptionResponse addSubscriptionResponse = 7;
SubscriptionRequest SubscriptionRequest = 6;
SubscriptionResponse SubscriptionResponse = 7;
Copy link
Member

Choose a reason for hiding this comment

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

If registration and subscription is to be done with direct RPC then these message can be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I assumed we wanted to support both for the time being this late in the game. does that make sense @jackgerrits?

Copy link
Contributor

Choose a reason for hiding this comment

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

In my refactor, those are removed.

@rysweet rysweet marked this pull request as draft January 8, 2025 01:41
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.

bring over the tests from pr 4405 Implement remove_subscription in worker runtime
3 participants