fix(tools): keep send_file refs forget-only

Mark send_file media registrations as forget-only so cleanup drops the ref without deleting the original workspace file.

Refs #1886
This commit is contained in:
Hoshina 2026-03-22 17:50:22 +08:00
parent 1ba6211cb6
commit bbe127f7b0
2 changed files with 12 additions and 3 deletions

View file

@ -136,6 +136,7 @@ func (t *SendFileTool) Execute(ctx context.Context, args map[string]any) *ToolRe
Filename: filename,
ContentType: mediaType,
Source: "tool:send_file",
CleanupPolicy: media.CleanupPolicyForgetOnly,
}, scope)
if err != nil {
return ErrorResult(fmt.Sprintf("failed to register media: %v", err))

View file

@ -104,6 +104,14 @@ func TestSendFileTool_Success(t *testing.T) {
if result.Media[0][:8] != "media://" {
t.Errorf("expected media:// ref, got %q", result.Media[0])
}
_, meta, err := store.ResolveWithMeta(result.Media[0])
if err != nil {
t.Fatalf("ResolveWithMeta failed: %v", err)
}
if meta.CleanupPolicy != media.CleanupPolicyForgetOnly {
t.Errorf("CleanupPolicy = %q, want %q", meta.CleanupPolicy, media.CleanupPolicyForgetOnly)
}
}
func TestSendFileTool_CustomFilename(t *testing.T) {