You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

differences-python.md 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Differences from Python
  2. ## Agents Self-Interact
  3. When an agent sends a message of a type to which it also listens:
  4. ```csharp
  5. [TopicSubscription("default")]
  6. public class MyAgent(
  7. IAgentWorker worker,
  8. [FromKeyedServices("EventTypes")] EventTypes typeRegistry
  9. ) :
  10. Agent(worker, typeRegistry),
  11. IHandle<Message>
  12. {
  13. async Task SomeInternalFunctionAsync()
  14. {
  15. Message m;
  16. // ...
  17. await this.PublishMessageAsync(m);
  18. }
  19. public async Task Handle(Message message)
  20. {
  21. // will receive messages sent by SomeInternalFunctionAsync()
  22. }
  23. }
  24. ```
  25. Tracked by [#4998](https://github.com/microsoft/autogen/issues/4998)
  26. ## 'Local' Runtime is Multithreaded
  27. 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.
  28. ## No equivalent to 'stop_when_idle()'
  29. Agents need to request termination explicitly, as there is no meaningful 'idle' state.
  30. ## All message types need to be Protocol Buffers
  31. See (linkto: defining-message-types.md) for instructions on defining messages
  32. Tracked by [#4695](https://github.com/microsoft/autogen/issues/4695)