@@ -502,101 +502,6 @@ func TestMicroCompactMixedPinnedAndNonPinned(t *testing.T) {
502502 }
503503}
504504
505- func TestMicroCompactPinsCopyAndMoveUsingPersistedMetadataPaths (t * testing.T ) {
506- t .Parallel ()
507-
508- pinChecker := NewDefaultPinChecker ()
509-
510- copyMessages := []providertypes.Message {
511- {Role : providertypes .RoleUser , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("older user" )}},
512- {
513- Role : providertypes .RoleAssistant ,
514- ToolCalls : []providertypes.ToolCall {
515- {ID : "copy-call" , Name : tools .ToolNameFilesystemCopyFile , Arguments : `{"source_path":"main.go","destination_path":"go.mod"}` },
516- },
517- },
518- {Role : providertypes .RoleTool , ToolCallID : "copy-call" , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("ok" )}, ToolMetadata : map [string ]string {
519- "tool_name" : tools .ToolNameFilesystemCopyFile ,
520- "source_path" : "/project/main.go" ,
521- "destination_path" : "/project/go.mod" ,
522- }},
523- {
524- Role : providertypes .RoleAssistant ,
525- ToolCalls : []providertypes.ToolCall {
526- {ID : "recent-call" , Name : tools .ToolNameBash , Arguments : "{}" },
527- },
528- },
529- {Role : providertypes .RoleTool , ToolCallID : "recent-call" , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("recent bash result" )}},
530- {Role : providertypes .RoleUser , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("latest explicit instruction" )}},
531- }
532-
533- copyGot := microCompactMessagesWithPolicies (copyMessages , stubMicroCompactPolicySource {}, 1 , nil , pinChecker )
534- if renderDisplayParts (copyGot [2 ].Parts ) != "ok" {
535- t .Fatalf ("expected copy_file result touching go.mod to stay pinned, got %q" , renderDisplayParts (copyGot [2 ].Parts ))
536- }
537-
538- moveMessages := []providertypes.Message {
539- {Role : providertypes .RoleUser , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("older user" )}},
540- {
541- Role : providertypes .RoleAssistant ,
542- ToolCalls : []providertypes.ToolCall {
543- {ID : "move-call" , Name : tools .ToolNameFilesystemMoveFile , Arguments : `{"source_path":"package.json","destination_path":"package.backup.json"}` },
544- },
545- },
546- {Role : providertypes .RoleTool , ToolCallID : "move-call" , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("ok" )}, ToolMetadata : map [string ]string {
547- "tool_name" : tools .ToolNameFilesystemMoveFile ,
548- "source_path" : "/project/package.json" ,
549- "destination_path" : "/project/package.backup.json" ,
550- }},
551- {
552- Role : providertypes .RoleAssistant ,
553- ToolCalls : []providertypes.ToolCall {
554- {ID : "recent-call" , Name : tools .ToolNameBash , Arguments : "{}" },
555- },
556- },
557- {Role : providertypes .RoleTool , ToolCallID : "recent-call" , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("recent bash result" )}},
558- {Role : providertypes .RoleUser , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("latest explicit instruction" )}},
559- }
560-
561- moveGot := microCompactMessagesWithPolicies (moveMessages , stubMicroCompactPolicySource {}, 1 , nil , pinChecker )
562- if renderDisplayParts (moveGot [2 ].Parts ) != "ok" {
563- t .Fatalf ("expected move_file result touching package.json to stay pinned, got %q" , renderDisplayParts (moveGot [2 ].Parts ))
564- }
565- }
566-
567- func TestMicroCompactStillCompactsCopyAndMoveWhenNoKeyFileIsTouched (t * testing.T ) {
568- t .Parallel ()
569-
570- pinChecker := NewDefaultPinChecker ()
571- messages := []providertypes.Message {
572- {Role : providertypes .RoleUser , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("older user" )}},
573- {
574- Role : providertypes .RoleAssistant ,
575- ToolCalls : []providertypes.ToolCall {
576- {ID : "move-call" , Name : tools .ToolNameFilesystemMoveFile , Arguments : `{"source_path":"main.go","destination_path":"main2.go"}` },
577- },
578- },
579- {Role : providertypes .RoleTool , ToolCallID : "move-call" , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("ok" )}, ToolMetadata : map [string ]string {
580- "tool_name" : tools .ToolNameFilesystemMoveFile ,
581- "source_path" : "/project/main.go" ,
582- "destination_path" : "/project/main2.go" ,
583- }},
584- {
585- Role : providertypes .RoleAssistant ,
586- ToolCalls : []providertypes.ToolCall {
587- {ID : "recent-call" , Name : tools .ToolNameBash , Arguments : "{}" },
588- },
589- },
590- {Role : providertypes .RoleTool , ToolCallID : "recent-call" , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("recent bash result" )}},
591- {Role : providertypes .RoleUser , Parts : []providertypes.ContentPart {providertypes .NewTextPart ("latest explicit instruction" )}},
592- }
593-
594- got := microCompactMessagesWithPolicies (messages , stubMicroCompactPolicySource {}, 1 , nil , pinChecker )
595- if ! strings .Contains (renderDisplayParts (got [2 ].Parts ), "[summary] filesystem_move_file" ) {
596- t .Fatalf ("expected non-key move_file result to still compact into summary, got %q" , renderDisplayParts (got [2 ].Parts ))
597- }
598- }
599-
600505// stubMicroCompactPinChecker 实现 MicroCompactPinChecker,用于测试。
601506type stubMicroCompactPinChecker map [string ]map [string ]bool
602507
0 commit comments