mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-11 23:53:19 -10:00
Problem: Long read_file results could be truncated into a provider-visible preview and then silently treated as complete, allowing later rules to be missed. Root cause: RawContent recovery was advisory. The host had no incomplete-read state, no completion gate, and recorded text observations before the model had consumed every retained page. Fix: Add deterministic dynamic-budget recovery, restricted grep/read strategy receipts, host-level write/final-answer gates, exact contiguous cursors, and bounded streaming read_file/grep decoding without fixed 128 KiB or 32K token product limits. Verification: go test ./...; go test -race ./internal/agent for incomplete-read coverage; go vet ./...; make lint; cd desktop && go test ./...
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package agent
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestFinalReadinessErrorPreservesDiagnosticText(t *testing.T) {
|
|
err := (&FinalReadinessError{Attempts: 3, Reason: "missing verification"}).Error()
|
|
want := "final-answer readiness failed 3 times: missing verification"
|
|
if err != want {
|
|
t.Fatalf("Error() = %q, want %q", err, want)
|
|
}
|
|
}
|
|
|
|
func TestPauseClassNamesEachGuard(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
err error
|
|
want string
|
|
}{
|
|
{&maxStepsPause{steps: 40, key: "max_steps"}, "max_steps"},
|
|
{&FinalReadinessError{Attempts: 3}, "final_readiness"},
|
|
{&RecoveryPauseError{Message: "paused"}, "recovery_paused"},
|
|
{&IncompleteReadError{Reason: "continuation ignored"}, "incomplete_read"},
|
|
{fmt.Errorf("wrapped: %w", &maxStepsPause{steps: 5}), "max_steps"},
|
|
{errors.New("provider 500"), ""},
|
|
{nil, ""},
|
|
} {
|
|
if got := PauseClass(tc.err); got != tc.want {
|
|
t.Errorf("PauseClass(%v) = %q, want %q", tc.err, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestIncompleteReadIsAHostOwnedRecoverablePause(t *testing.T) {
|
|
info, ok := InspectRunPause(&IncompleteReadError{Reason: "continuation ignored"})
|
|
if !ok || info.Kind != "incomplete_read" || !info.HostOwned || info.Reason != "continuation ignored" {
|
|
t.Fatalf("InspectRunPause = %+v, %v", info, ok)
|
|
}
|
|
}
|