Why: Authentic quotes do not establish an unstated approval, and the evaluation wrapper must honor tighter production output limits. Evidence: Approval-overstatement and 780-token-cap regressions failed first; complete Backend suite and fixture cap checks now pass. Impact: Render material records from trusted labels and validated quotations, reserve interpretation for explicit finding kinds, bump recipe identity and cap the fixture without overriding smaller limits. Refs: Approved R05; independent model assessment; original failed samples preserved
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
//go:build live
|
|
|
|
package server
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
agentllm "agent-native/runtime/llm"
|
|
)
|
|
|
|
func TestEvaluationPreservesProductionOutputCap(t *testing.T) {
|
|
for _, tc := range []struct{ supplied, want int }{{780, 780}, {5000, 4000}, {0, 4000}} {
|
|
t.Run(fmt.Sprint(tc.supplied), func(t *testing.T) {
|
|
got := make(chan int, 1)
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
var body struct {
|
|
MaxTokens int `json:"max_tokens"`
|
|
}
|
|
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
|
t.Error(err)
|
|
}
|
|
got <- body.MaxTokens
|
|
w.Header().Set("Content-Type", "text/event-stream")
|
|
fmt.Fprint(w, "data: {\"choices\":[{\"delta\":{\"content\":\"done\"},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":1,\"completion_tokens\":1,\"total_tokens\":2}}\n\ndata: [DONE]\n\n")
|
|
}))
|
|
defer srv.Close()
|
|
stream := evalProviderStream(map[string]any{"baseUrl": srv.URL, "apiKey": "fixture", "model": "fixture"}, t.TempDir())
|
|
for range stream(context.Background(), "fixture", []agentllm.Message{{Role: agentllm.RoleUser, Content: "check cap"}}, nil, agentllm.StreamOptions{MaxTokens: tc.supplied}) {
|
|
}
|
|
if actual := <-got; actual != tc.want {
|
|
t.Fatalf("evaluation overwrote production cap: got %d want %d", actual, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|