From 70f3e1f5d55af8e1bfa657cc28e3f47deaa8f6c0 Mon Sep 17 00:00:00 2001 From: viettranx Date: Tue, 17 Mar 2026 15:43:24 +0700 Subject: [PATCH] feat(tools): auto-deliver write_file results as channel attachments Flip write_file deliver param default from false to true so result files (reports, articles, generated content) are automatically sent as document attachments to chat channels without requiring explicit LLM opt-in. Add .md MIME type to mimeFromExt for proper markdown file delivery. --- internal/agent/loop_media.go | 2 ++ internal/tools/filesystem_write.go | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/agent/loop_media.go b/internal/agent/loop_media.go index 6433ed3c..ac5152ad 100644 --- a/internal/agent/loop_media.go +++ b/internal/agent/loop_media.go @@ -98,6 +98,8 @@ func mimeFromExt(ext string) string { return "application/msword" case ".xls", ".xlsx": return "application/vnd.ms-excel" + case ".md": + return "text/markdown" default: return "application/octet-stream" } diff --git a/internal/tools/filesystem_write.go b/internal/tools/filesystem_write.go index 973e45f8..c2d77de9 100644 --- a/internal/tools/filesystem_write.go +++ b/internal/tools/filesystem_write.go @@ -77,7 +77,7 @@ func (t *WriteFileTool) Parameters() map[string]any { }, "deliver": map[string]any{ "type": "boolean", - "description": "If true, deliver this file to the user as an attachment (image, document, etc.)", + "description": "Deliver this file to the user as an attachment. Defaults to true. Set to false for intermediate/temporary files (e.g. config, cache, temp scripts).", }, }, "required": []string{"path", "content"}, @@ -87,7 +87,10 @@ func (t *WriteFileTool) Parameters() map[string]any { func (t *WriteFileTool) Execute(ctx context.Context, args map[string]any) *Result { path, _ := args["path"].(string) content, _ := args["content"].(string) - deliver, _ := args["deliver"].(bool) + deliver := true + if v, ok := args["deliver"].(bool); ok { + deliver = v + } if path == "" { return ErrorResult("path is required") }