Skip to content

Commit 323959a

Browse files
authored
Merge pull request #3 from neuroglia-io/fix-task-record-extensions
Fixed the `TaskRecordExtensions` to include `Artifacts` when converting a `TaskRecord` into a `Task`
2 parents e9aa56b + 72102b3 commit 323959a

File tree

13 files changed

+40
-16
lines changed

13 files changed

+40
-16
lines changed

src/a2a-net.Client.Asbtractions/a2a-net.Client.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>A2A.Client</RootNamespace>
8-
<VersionPrefix>0.4.0</VersionPrefix>
8+
<VersionPrefix>0.4.1</VersionPrefix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/a2a-net.Client.Http/a2a-net.Client.Http.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>A2A.Client</RootNamespace>
8-
<VersionPrefix>0.4.0</VersionPrefix>
8+
<VersionPrefix>0.4.1</VersionPrefix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/a2a-net.Client.WebSocket/a2a-net.Client.WebSocket.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>A2A.Client.WebSocket</RootNamespace>
8-
<VersionPrefix>0.4.0</VersionPrefix>
8+
<VersionPrefix>0.4.1</VersionPrefix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/a2a-net.Client/a2a-net.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>A2A.Client</RootNamespace>
8-
<VersionPrefix>0.4.0</VersionPrefix>
8+
<VersionPrefix>0.4.1</VersionPrefix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/a2a-net.Core/a2a-net.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>A2A.Client</RootNamespace>
8-
<VersionPrefix>0.4.0</VersionPrefix>
8+
<VersionPrefix>0.4.1</VersionPrefix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/a2a-net.Server.AspNetCore/a2a-net.Server.AspNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<OutputType>Library</OutputType>
88
<RootNamespace>A2A.Server.AspNetCore</RootNamespace>
9-
<VersionPrefix>0.4.0</VersionPrefix>
9+
<VersionPrefix>0.4.1</VersionPrefix>
1010
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1111
<FileVersion>$(VersionPrefix)</FileVersion>
1212
<NeutralLanguage>en</NeutralLanguage>

src/a2a-net.Server.Infrastructure.Abstractions/a2a-net.Server.Infrastructure.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>A2A.Server.Infrastructure</RootNamespace>
8-
<VersionPrefix>0.4.0</VersionPrefix>
8+
<VersionPrefix>0.4.1</VersionPrefix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/a2a-net.Server.Infrastructure.DistributedCache/a2a-net.Server.Infrastructure.DistributedCache.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>A2A.Server.Infrastructure.DistributedCache</RootNamespace>
8-
<VersionPrefix>0.4.0</VersionPrefix>
8+
<VersionPrefix>0.4.1</VersionPrefix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/a2a-net.Server/Extensions/TaskRecordExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ public static class TaskRecordExtensions
2323
/// Converts the <see cref="TaskRecord"/> into a new <see cref="Models.Task"/>
2424
/// </summary>
2525
/// <param name="taskRecord">The <see cref="TaskRecord"/> to convert</param>
26+
/// <param name="stateTransitionHistory">A boolean indicating whether or not the agent exposes status change history for tasks</param>
27+
/// <param name="historyLength">The maximum length number of state transitions, if any, to be retrieved</param>
2628
/// <returns>A new <see cref="Models.Task"/></returns>
27-
public static Models.Task AsTask(this TaskRecord taskRecord) => new()
29+
public static Models.Task AsTask(this TaskRecord taskRecord, bool stateTransitionHistory = false, uint? historyLength = null) => new()
2830
{
2931
Id = taskRecord.Id,
3032
SessionId = taskRecord.SessionId,
3133
Status = taskRecord.Status,
32-
History = taskRecord.History,
34+
Artifacts = taskRecord.Artifacts,
35+
History = stateTransitionHistory ? historyLength.HasValue && taskRecord.History != null ? [..taskRecord.History.TakeLast((int)historyLength.Value)] : taskRecord.History : null,
3336
Metadata = taskRecord.Metadata,
3437
};
3538

src/a2a-net.Server/Infrastructure/Services/A2AProtocolServer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class A2AProtocolServer(string name, AgentCapabilities capabilities, ILog
7878
return new()
7979
{
8080
Id = request.Id,
81-
Result = task.AsTask()
81+
Result = task.AsTask(Capabilities.StateTransitionHistory, request.Params.HistoryLength)
8282
};
8383
}
8484

@@ -134,7 +134,7 @@ public virtual async IAsyncEnumerable<RpcResponse<TaskEvent>> ResubscribeToTaskA
134134
public virtual async Task<RpcResponse<Models.Task>> GetTaskAsync(GetTaskRequest request, CancellationToken cancellationToken = default)
135135
{
136136
ArgumentNullException.ThrowIfNull(request);
137-
var task = (await Tasks.GetAsync(request.Params.Id, cancellationToken).ConfigureAwait(false))?.AsTask();
137+
var task = (await Tasks.GetAsync(request.Params.Id, cancellationToken).ConfigureAwait(false))?.AsTask(Capabilities.StateTransitionHistory);
138138
if (task == null) return new()
139139
{
140140
Id = request.Id,
@@ -173,7 +173,7 @@ public virtual async IAsyncEnumerable<RpcResponse<TaskEvent>> ResubscribeToTaskA
173173
return new()
174174
{
175175
Id = request.Id,
176-
Result = task.AsTask()
176+
Result = task.AsTask(Capabilities.StateTransitionHistory)
177177
};
178178
}
179179

0 commit comments

Comments
 (0)