Path: redb-route/tests/redb.Route.Tests.Llm/Governance/StreamingToolPolicyTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Llm/Governance/StreamingToolPolicyTests.cs ---- using redb.Route.Tests.Llm.TestHelpers; using LlmDsl = redb.Route.Llm.Fluent.Llm; namespace redb.Route.Tests.Llm.Governance; /// /// Streaming × tools. Both modes run the agent engine with its tools: stream=calls inside the route /// (StreamCallsTests), stream=body when the body is read (LazyStreamTests). So the combination is allowed when /// the endpoint is created; the one placement rule left is stream=body inside .Transacted(), refused at /// run time because the block would commit before the answer exists. /// [Trait("Category", "Governance")] public sealed class StreamingToolPolicyTests { [Theory] [InlineData(LlmStreamMode.Calls)] [InlineData(LlmStreamMode.Body)] public async Task StreamingWithTools_IsAllowed(LlmStreamMode mode) { await using var host = LiveLlmHost.Build() .AddFactory("demo", new LlmConnectionFactory { Provider = "stub", PrebuiltProvider = new FakeProvider().EnqueueText("done") }); await host.StartAsync(r => r.From("direct:agent") .To(LlmDsl.Factory("demo").Stream(mode).Tools("*").AsUri())); IExchange? exchange = null; var thrown = await Record.ExceptionAsync(async () => exchange = await host.SendAsync("direct:agent", "hello")); if (exchange is not null) await exchange.DisposeAsync(); thrown.Should().BeNull("a tool-using agent streams in either mode"); exchange!.Exception.Should().BeNull(); } [Fact] public async Task StreamingWithoutTools_IsStillAllowed() { await using var host = LiveLlmHost.Build() .AddFactory("demo", new LlmConnectionFactory { Provider = "stub", PrebuiltProvider = new FakeProvider() }); var started = await Record.ExceptionAsync(() => host.StartAsync(r => r.From("direct:agent") .To(LlmDsl.Factory("demo").Stream(LlmStreamMode.Body).AsUri()) .To("mock:done"))); started.Should().BeNull("streaming plain completions is untouched"); } }