Expose backend identity and capacity errors

This commit is contained in:
2026-08-29 14:26:04 +00:00
parent 06b37c2bae
commit 157209f097
11 changed files with 194 additions and 6 deletions

View File

@@ -1033,13 +1033,16 @@ backends:
queue_capacity: 0
`, lib.promptDir, lib.profileDir))
code, _, stderr := runCLICommand(t, renderCommand, []string{
code, stdout, stderr := runCLICommand(t, renderCommand, []string{
"--config", configPath,
"--prompt", "custom",
})
if code != ExitOK {
t.Fatalf("expected ExitOK, got %d stderr=%q", code, stderr)
}
if !strings.Contains(stdout, "selected_backend_id: local-gpu") {
t.Fatalf("expected configured backend in prepared output, got:\n%s", stdout)
}
}
func TestRenderCommandMapsReasoningEffortAndSessionID(t *testing.T) {
@@ -1624,6 +1627,9 @@ func TestWriteOutputAndSummaryUseSeparateWriters(t *testing.T) {
if strings.Contains(stderr.String(), "cached_tokens=") || strings.Contains(stderr.String(), "cache_write_tokens=") {
t.Fatalf("expected zero cache usage to be omitted from summary, got %q", stderr.String())
}
if strings.Contains(stderr.String(), "backend=") {
t.Fatalf("expected endpoint-only backend to be omitted from summary, got %q", stderr.String())
}
}
func TestPrintSummaryIncludesCacheUsageWhenPresent(t *testing.T) {
@@ -1653,6 +1659,32 @@ func TestPrintSummaryIncludesCacheUsageWhenPresent(t *testing.T) {
if !strings.Contains(summary, "cached_tokens=0 cache_write_tokens=3") {
t.Fatalf("expected cache usage in summary, got %q", summary)
}
if strings.Contains(summary, "backend=") {
t.Fatalf("expected endpoint-only backend to be omitted from summary, got %q", summary)
}
}
func TestPrintSummaryIncludesBackendWhenPresent(t *testing.T) {
var stderr bytes.Buffer
printSummary(&stderr, &promptkit.RunResult{
PromptID: "p",
PromptVersion: "1",
SelectedProfileID: "exec",
SelectedBackendID: "local",
ModelName: "m",
Validation: promptkit.ValidationResult{Status: promptkit.ValidationPassed, Mode: promptkit.ValidationBasic},
RenderedPromptHash: "h",
})
if !strings.Contains(stderr.String(), "backend=local") {
t.Fatalf("expected backend in summary, got %q", stderr.String())
}
}
func TestRunErrorMessageDoesNotExposeCapacityDetails(t *testing.T) {
got := runErrorMessage(&promptkit.CapacityError{BackendID: "private-backend"})
if got != "run error: model backend capacity is exhausted" {
t.Fatalf("unexpected capacity diagnostic: %q", got)
}
}
type cliTestLibrary struct {