mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
456e7d1b65
- Moved InProcessRuntime type into abstractions package and deleted InProcess package. - Moved several members of IAgentRuntime to be extension methods instead, e.g. multiple GetActorAsync overloads. - Added synchronous RegisterMessageHandler overloads and used them to avoid unnecessary async usage at call sites. - Removed unnecessary surface area from InProcessRuntime, e.g. StopAsync, RunUntilIdleAsync, etc. - Fixed spin loop in InProcessRuntime that would consume an entire core for the duration of the orchestration's operation. - Removed a bunch of allocation from InProcessRuntime. - Made a runtime optional for orchestrations, defaulting to using a temporary InProcessRuntime if none is provided. - Removed custom delegate types from orchestrations. - Consolidated namespaces. - Used records to simplify message classes. - Tweaked naming on AgentActor to make purpose of protected methods more clear. - Removed invocation in AgentActor.InvokeAsync of empty update / isFinal parameter. - Changed OrchestrationHandoffs to avoid needing to pass in agents duplicatively. - Made various extension methods, such as those on OrchestrationHandoffsExtensions, into instance methods.
34 lines
973 B
C#
34 lines
973 B
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
|
|
namespace Microsoft.Extensions.AI.Agents.Runtime.InProcess.Tests;
|
|
|
|
public class TestSubscription(string topicType, ActorType agentType, string? id = null) : ISubscriptionDefinition
|
|
{
|
|
public string Id { get; } = id ?? Guid.NewGuid().ToString();
|
|
|
|
public string TopicType { get; } = topicType;
|
|
|
|
public ActorId MapToActor(TopicId topic)
|
|
{
|
|
if (!this.Matches(topic))
|
|
{
|
|
throw new InvalidOperationException("TopicId does not match the subscription.");
|
|
}
|
|
|
|
return new ActorId(agentType, topic.Source);
|
|
}
|
|
|
|
public bool Equals(ISubscriptionDefinition? other) => this.Id == other?.Id;
|
|
|
|
public override bool Equals(object? obj) => obj is TestSubscription other && other.Equals(this);
|
|
|
|
public override int GetHashCode() => this.Id.GetHashCode();
|
|
|
|
public bool Matches(TopicId topic)
|
|
{
|
|
return topic.Type == this.TopicType;
|
|
}
|
|
}
|