Archive summary refinements and profile switching
PR and Push Build/Test / build-and-test (push) Successful in 6m37s

This commit is contained in:
2026-05-27 23:11:21 +02:00
parent c12febe029
commit 7777b349a5
37 changed files with 3190 additions and 121 deletions
@@ -151,6 +151,36 @@ public sealed class LiteLlmResponsesChatClientTests
Assert.Equal(1, handler.RequestCount);
}
[Fact]
public async Task ClientSendsUserInitiatorOnceThenAgentInitiator()
{
var handler = new RecordingHttpMessageHandler(_ => new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent("""
{
"output": [
{
"type": "message",
"content": [
{
"type": "output_text",
"text": "Done."
}
]
}
]
}
""")
});
using var client = CreateClient(handler, reconnectionAttempts: 0);
await client.GetResponseAsync([new ChatMessage(ChatRole.User, "write summary")]);
await client.GetResponseAsync([new ChatMessage(ChatRole.Tool, "tool result")]);
await client.GetResponseAsync([new ChatMessage(ChatRole.Assistant, "continue")]);
Assert.Equal(["user", "agent", "agent"], handler.RequestHeaders["X-Initiator"]);
}
[Fact]
public async Task ClientUsesResponsesCompactionEndpointWhenContextThresholdIsReached()
{
@@ -209,6 +239,7 @@ public sealed class LiteLlmResponsesChatClientTests
Assert.Equal("Done.", response.Text);
Assert.Equal(["/v1/responses/compact", "/v1/responses"], handler.RequestPaths);
Assert.Contains("\"content\":\"compacted\"", handler.RequestBodies[1]);
Assert.Equal(["agent", "user"], handler.RequestHeaders["X-Initiator"]);
}
[Fact]
@@ -321,6 +352,8 @@ public sealed class LiteLlmResponsesChatClientTests
public List<string> RequestBodies { get; } = [];
public Dictionary<string, List<string>> RequestHeaders { get; } = new(StringComparer.OrdinalIgnoreCase);
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
@@ -329,6 +362,17 @@ public sealed class LiteLlmResponsesChatClientTests
RequestBodies.Add(request.Content is null
? string.Empty
: await request.Content.ReadAsStringAsync(cancellationToken));
foreach (var header in request.Headers)
{
if (!RequestHeaders.TryGetValue(header.Key, out var values))
{
values = [];
RequestHeaders[header.Key] = values;
}
values.AddRange(header.Value);
}
return handler(request);
}
}