Stufe 4c (#764): Kommentare in C#, WebUI-Skripten, CSS und HTML auf Englisch
Rund 2.600 Kommentarblöcke in 310 C#-Dateien übersetzt, Begründungen vollständig erhalten: blockweise gleiche Anzahl wie vorher, kein Block unter 60 % seiner Länge, der Code außerhalb der Kommentare per Tokenizer byte-identisch geprüft. Zitate deutscher Oberflächentexte und Testdaten bleiben deutsch. WebUI: Kommentare in JS/CSS/HTML übersetzt, JSDoc-@param an die in 4b umbenannten Parameter angeglichen. Dabei behoben: - 4b hatte "tag" (HTML-Tag) als deutsches "Tag" gelesen und zu "dayValue" gemacht (makeElement, svg, Tagesübersicht) - zurück auf tag/day. - Aufgaben "InProgress" bekamen die Plakettenart "laufend", für die es nie eine CSS-Klasse gab - jetzt "success" wie laufende Instanzen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
da4ceac7d5
commit
837a634a22
@@ -5,15 +5,15 @@ using Shouldly;
|
||||
namespace ClawdDotNet.Core.Tests.Engine;
|
||||
|
||||
/// <summary>
|
||||
/// #203 — die Compaction lief nach dem API-Aufruf.
|
||||
/// #203 — compaction ran after the API call.
|
||||
///
|
||||
/// <para>Sie stützte sich auf die <c>promptTokens</c> der gerade beantworteten Anfrage:
|
||||
/// Als der Wert vorlag, war der überfüllte Prompt längst abgerechnet, und gekürzt wurde
|
||||
/// erst für den nächsten Schritt. Genau ein Schritt zu spät — und zwar der teuerste.</para>
|
||||
/// <para>It relied on the <c>promptTokens</c> of the request just answered:
|
||||
/// by the time the value was available, the overfull prompt had long been billed, and truncation
|
||||
/// only happened for the next step. Exactly one step too late — and the most expensive one.</para>
|
||||
///
|
||||
/// <para>Die Zusage lautet jetzt: <b>Keine Anfrage geht über die Kontextgrenze hinaus.</b>
|
||||
/// Geprüft wird vor dem Senden, mit der Schätzung; die gemessenen Werte ziehen die
|
||||
/// Schätzung hinterher nach.</para>
|
||||
/// <para>The promise now reads: <b>no request goes beyond the context limit.</b>
|
||||
/// The check happens before sending, with the estimate; the measured values adjust the
|
||||
/// estimate afterwards.</para>
|
||||
/// </summary>
|
||||
public sealed class ProactiveCompactionTests
|
||||
{
|
||||
@@ -26,17 +26,17 @@ public sealed class ProactiveCompactionTests
|
||||
var fixture = new EngineFixture();
|
||||
var agent = fixture.AddAgent("agent-a");
|
||||
|
||||
// Schwelle: 1000 geschätzte Tokens.
|
||||
// Threshold: 1000 estimated tokens.
|
||||
agent.LoopGuard.MaxContextTokens = 2_000;
|
||||
agent.LoopGuard.CompactionThreshold = 0.5;
|
||||
agent.LoopGuard.SummaryModel = SummaryModel;
|
||||
|
||||
fixture.Client.AlwaysRespondsWithText("Verstanden.");
|
||||
|
||||
// Jede Nachricht bringt rund 150 geschaetzte Tokens mit; nach wenigen Runden
|
||||
// waere der Kontext ohne Eingriff ueber der Grenze. Klein genug, dass auch die
|
||||
// sechs geschuetzten Tail-Nachrichten zusammen noch unter die Grenze passen -
|
||||
// sonst koennte selbst eine Kompaktierung sie nicht mehr unterschreiten.
|
||||
// Every message brings about 150 estimated tokens; after a few rounds
|
||||
// the context would be above the limit without intervention. Small enough that even the
|
||||
// six protected tail messages together still fit below the limit -
|
||||
// otherwise not even a compaction could get under it any more.
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
await fixture.Engine.ChatAsync(
|
||||
@@ -49,9 +49,9 @@ public sealed class ProactiveCompactionTests
|
||||
|
||||
anfragenAnDenAgenten.Count.ShouldBe(20);
|
||||
|
||||
// Der eigentliche Punkt: nicht "irgendwann wurde gekürzt", sondern "es ging nie
|
||||
// etwas Überfülltes hinaus". Vorher hing die Prüfung an den promptTokens der
|
||||
// Antwort — beim Fake immer 100 —, kam also nie über die Schwelle und kürzte nie.
|
||||
// The actual point: not "at some point it was truncated", but "nothing overfull ever
|
||||
// went out". Previously the check hung on the promptTokens of the
|
||||
// answer — always 100 with the fake —, so it never got over the threshold and never truncated.
|
||||
foreach (var anfrage in anfragenAnDenAgenten)
|
||||
{
|
||||
ContextCompactor.EstimateTokens(anfrage.Messages)
|
||||
@@ -77,12 +77,12 @@ public sealed class ProactiveCompactionTests
|
||||
agent, $"Frage {i}: " + new string('y', 600), "test-instance", default);
|
||||
}
|
||||
|
||||
// Es wurde überhaupt kompaktiert — sonst sagt der Test darüber nichts aus.
|
||||
// Compaction happened at all — otherwise the test says nothing about it.
|
||||
fixture.Client.ReceivedRequests.ShouldContain(r => r.Model == SummaryModel);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
// Kalibrierung
|
||||
// Calibration
|
||||
// ═══════════════════════════════════════════════════════════
|
||||
|
||||
private static ContextCompactor NeuerKompaktierer()
|
||||
@@ -105,7 +105,7 @@ public sealed class ProactiveCompactionTests
|
||||
|
||||
var compactor = NeuerKompaktierer();
|
||||
|
||||
// Die API berechnet durchweg doppelt so viel wie geschätzt.
|
||||
// The API consistently charges twice as much as estimated.
|
||||
for (var i = 0; i < 20; i++)
|
||||
compactor.Calibrate("m", 1_000, 2_000);
|
||||
|
||||
@@ -119,9 +119,9 @@ public sealed class ProactiveCompactionTests
|
||||
var roh = ContextCompactor.EstimateTokens(messages);
|
||||
|
||||
var compactor = NeuerKompaktierer();
|
||||
compactor.Calibrate("m", 1_000, 4_000); // einmal weit daneben
|
||||
compactor.Calibrate("m", 1_000, 4_000); // far off once
|
||||
|
||||
// Ein Messwert verschiebt den Faktor nur um sein Gewicht, nicht auf seinen Wert.
|
||||
// A measurement only shifts the factor by its weight, not to its value.
|
||||
compactor.EstimateFor("m", messages).ShouldBeLessThan(roh * 2);
|
||||
}
|
||||
|
||||
@@ -135,15 +135,15 @@ public sealed class ProactiveCompactionTests
|
||||
for (var i = 0; i < 50; i++)
|
||||
compactor.Calibrate("m", 1, 1_000_000);
|
||||
|
||||
// Höchstens das Vierfache — was darüber läge, ist kein Kalibrierungsfall mehr.
|
||||
// At most four times — anything above that is no longer a calibration case.
|
||||
compactor.EstimateFor("m", messages).ShouldBeLessThanOrEqualTo(roh * 4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Jedes_Modell_wird_fuer_sich_kalibriert()
|
||||
{
|
||||
// Verschiedene Tokenizer zerlegen denselben Text verschieden — ein gemeinsamer
|
||||
// Faktor wäre der Mittelwert von etwas, das nichts miteinander zu tun hat.
|
||||
// Different tokenizers split the same text differently — a common
|
||||
// factor would be the average of things that have nothing to do with each other.
|
||||
var messages = Conversation.Start().Repeat(4).Build();
|
||||
var roh = ContextCompactor.EstimateTokens(messages);
|
||||
|
||||
@@ -162,8 +162,8 @@ public sealed class ProactiveCompactionTests
|
||||
var roh = ContextCompactor.EstimateTokens(messages);
|
||||
|
||||
var compactor = NeuerKompaktierer();
|
||||
compactor.Calibrate("m", 0, 5_000); // ohne Schätzung kein Verhältnis
|
||||
compactor.Calibrate("m", 1_000, 0); // ohne Messwert auch nicht
|
||||
compactor.Calibrate("m", 0, 5_000); // without an estimate no ratio
|
||||
compactor.Calibrate("m", 1_000, 0); // without a measurement neither
|
||||
|
||||
compactor.EstimateFor("m", messages).ShouldBe(roh);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user