-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rysweet-4744-bring-over-the-tests-from-pr-4405
- Loading branch information
Showing
56 changed files
with
1,715 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
docs/dotnet/user-guide/core-user-guide/defining-message-types.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Defining Message Types | ||
|
||
Messages are currently required to be Protocol Buffers. To define them, it is necessary to include the Protocol Buffers compiler, through the `Grpc.Tools` package. In your `.csproj` file, add/edit: | ||
|
||
```xml | ||
<PackageReference Include="Grpc.Tools" PrivateAssets="All" /> | ||
``` | ||
|
||
Then create an include a `.proto` file in the project: | ||
|
||
```xml | ||
<ItemGroup> | ||
<Protobuf Include="messages.proto" GrpcServices="Client;Server" Link="messages.proto" /> | ||
</ItemGroup> | ||
``` | ||
|
||
Then define your messages as specified in the [Protocol Buffers Language Guide](https://protobuf.dev/programming-guides/proto3/) | ||
|
||
```proto | ||
syntax = "proto3"; | ||
package HelloAgents; | ||
option csharp_namespace = "AgentsProtocol"; | ||
message TextMessage { | ||
string Source = 1; | ||
string Content = 2; | ||
} | ||
``` |
46 changes: 46 additions & 0 deletions
46
docs/dotnet/user-guide/core-user-guide/differences-python.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Differences from Python | ||
|
||
## Agents Self-Interact | ||
|
||
When an agent sends a message of a type to which it also listens: | ||
|
||
```csharp | ||
[TopicSubscription("default")] | ||
public class MyAgent( | ||
IAgentWorker worker, | ||
[FromKeyedServices("EventTypes")] EventTypes typeRegistry | ||
) : | ||
Agent(worker, typeRegistry), | ||
IHandle<Message> | ||
{ | ||
async Task SomeInternalFunctionAsync() | ||
{ | ||
Message m; | ||
|
||
// ... | ||
await this.PublishMessageAsync(m); | ||
} | ||
|
||
public async Task Handle(Message message) | ||
{ | ||
// will receive messages sent by SomeInternalFunctionAsync() | ||
} | ||
} | ||
``` | ||
|
||
Tracked by [#4998](https://github.com/microsoft/autogen/issues/4998) | ||
|
||
## 'Local' Runtime is Multithreaded | ||
|
||
Unlike the `single_threaded_runtime`, the InProcess (`local: true`) runtime for .NET is multi-threaded, so messages will process in arbitrary order across agents. This means that an agent may process messages sent after the termination request has been made unless checking for termination using the `IHostApplicationLifecycle` service. | ||
|
||
## No equivalent to 'stop_when_idle()' | ||
|
||
Agents need to request termination explicitly, as there is no meaningful 'idle' state. | ||
|
||
## All message types need to be Protocol Buffers | ||
|
||
See (linkto: defining-message-types.md) for instructions on defining messages | ||
|
||
Tracked by [#4695](https://github.com/microsoft/autogen/issues/4695) |
Oops, something went wrong.