chore(sync): 上游同步 - 快照导入 upstream/main@e70fe1b9(v1.6.5)并重放本项目差异

This commit is contained in:
tongtong committed 2026-10-12 11:52:01 +08:00
1 parent c9979a4a2b
commit 43c3dd3568
167 files changed
+5792 -7802

No files matched your search

@@ -380,10 +380,72 @@ func TestCloudAgentVisionBlocksSameResourceInSameCanvasRevision(t *testing.T) {
state.ImageInspectionReads = map[string]int{inspection.CacheKey: 1}
refreshCall := cloudAgentStoryboardCall(t, "canvas_inspect_image", "inspect-refresh", map[string]any{"nodeId": "cat", "refresh": true})
_, err = s.prepareCloudAgentImageInspection("user", "agent-canvas", &state, refreshCall)
var loopErr *cloudAgentReadLoopError
if !errors.As(err, &loopErr) {
t.Fatalf("refresh should not re-read the same resource in the same revision: %v", err)
second, err := s.prepareCloudAgentImageInspection("user", "agent-canvas", &state, refreshCall)
if err != nil {
t.Fatalf("repeated visual read should converge to a receipt, got: %v", err)
}
receipt := second.(cloudAgentImageInspection)
if receipt.ImageURL != "" || receipt.Receipt["repeat"] != true || receipt.CacheKey != inspection.CacheKey {
t.Fatalf("repeated visual read did not return a stable text receipt: %+v", receipt)
}
}
func TestCloudAgentVisionRepeatReadSoftNudgesRuntime(t *testing.T) {
s, _, _ := cloudAgentVisionFixture(t)
req := agentTestRequest()
req.VisionEnabled = true
root, err := s.CreateCloudAgentRun("user", req, "")
if err != nil {
t.Fatal(err)
}
run, err := s.repo.CloudAgent("user", root.ID)
if err != nil {
t.Fatal(err)
}
state, err := cloudAgentDecode(run)
if err != nil {
t.Fatal(err)
}
state.Request.VisionEnabled = true
firstCall := cloudAgentStoryboardCall(t, "canvas_inspect_image", "inspect-first", map[string]any{"nodeId": "cat"})
first, err := s.prepareCloudAgentImageInspection("user", "agent-canvas", &state, firstCall)
if err != nil {
t.Fatal(err)
}
cacheKey := first.(cloudAgentImageInspection).CacheKey
state.ImageInspectionReads = map[string]int{cacheKey: 1}
state.Calls = []cloudAgentCall{cloudAgentStoryboardCall(t, "canvas_inspect_image", "inspect-repeat", map[string]any{"nodeId": "cat", "refresh": true})}
state.CallIndex = 0
if err := s.repo.MutateCloudAgent("user", run.ID, run.Revision, func(current *model.CloudAgentExecution, _ *repository.Repository) error {
return cloudAgentSave(current, &state)
}); err != nil {
t.Fatal(err)
}
run, err = s.repo.CloudAgent("user", root.ID)
if err != nil {
t.Fatal(err)
}
state, err = cloudAgentDecode(run)
if err != nil {
t.Fatal(err)
}
if err := s.advanceCloudAgentTool(run, &state); err != nil {
t.Fatal(err)
}
output, err := s.CloudAgentRun("user", root.ID)
if err != nil {
t.Fatal(err)
}
if output.Status != "running" {
t.Fatalf("repeat visual read terminated the run: %+v", output)
}
hasGuard, hasFailure := false, false
for _, event := range output.Events {
hasGuard = hasGuard || event.Type == "read_loop_guard"
hasFailure = hasFailure || event.Type == "run_failed"
}
if !hasGuard || hasFailure {
t.Fatalf("repeat visual read did not preserve a soft guard: %+v", output.Events)
}
}
@@ -407,7 +469,7 @@ func TestCloudAgentVisionHasPerRunInspectionBudget(t *testing.T) {
}
}
func TestCloudAgentVisionBudgetStopsRunBeforeAnotherModelStep(t *testing.T) {
func TestCloudAgentVisionBudgetSoftNudgesBeforeAnotherModelStep(t *testing.T) {
s, _, _ := cloudAgentVisionFixture(t)
req := agentTestRequest()
req.VisionEnabled = true
@@ -447,8 +509,16 @@ func TestCloudAgentVisionBudgetStopsRunBeforeAnotherModelStep(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if output.Status != "failed" || !strings.Contains(output.FailureMessage, "识图调用已达到安全上限") {
t.Fatalf("inspection budget did not terminate the run: %+v", output)
if output.Status != "running" {
t.Fatalf("inspection budget terminated the run: %+v", output)
}
hasGuard, hasFailure := false, false
for _, event := range output.Events {
hasGuard = hasGuard || event.Type == "read_loop_guard"
hasFailure = hasFailure || event.Type == "run_failed"
}
if !hasGuard || hasFailure {
t.Fatalf("inspection budget did not soft-nudge the next model request: %+v", output.Events)
}
}