using ClawdDotNet.Core.Tests.Infrastructure;
using Shouldly;

namespace ClawdDotNet.Core.Tests.Engine;

/// <summary>
/// Form des ausgehenden Requests. B11/T8: <c>max_tokens</c> muss gesetzt sein, damit ein
/// Modell nicht in einem Schritt sein volles (teuerstes) Ausgabe-Limit ausschöpft.
/// </summary>
public sealed class RequestShapeTests
{
    [Fact]
    public async Task Der_Request_setzt_max_tokens()
    {
        var fixture = new EngineFixture();
        var agent = fixture.AddAgent("agent-a");
        agent.LoopGuard.MaxResponseTokens = 4_096;
        fixture.Client.RespondsWithText("fertig");

        await fixture.Engine.RunAsync(agent, "los", "test-instance", default);

        fixture.Client.ReceivedRequests.ShouldNotBeEmpty();
        fixture.Client.ReceivedRequests[0].MaxTokens.ShouldBe(4_096);
    }

    [Fact]
    public async Task Bei_Wert_0_bleibt_max_tokens_offen()
    {
        var fixture = new EngineFixture();
        var agent = fixture.AddAgent("agent-a");
        agent.LoopGuard.MaxResponseTokens = 0; // Anbieter-Standard
        fixture.Client.RespondsWithText("fertig");

        await fixture.Engine.RunAsync(agent, "los", "test-instance", default);

        fixture.Client.ReceivedRequests[0].MaxTokens.ShouldBeNull();
    }
}
