Просмотр исходного кода

fix(webfetch): make format parameter optional with markdown default (#6345)

Co-authored-by: Somair Ansar <[email protected]>
samcornor 3 месяцев назад
Родитель
Сommit
fd973d242e
2 измененных файлов с 6 добавлено и 5 удалено
  1. 2 1
      packages/opencode/src/tool/webfetch.ts
  2. 4 4
      packages/opencode/src/tool/webfetch.txt

+ 2 - 1
packages/opencode/src/tool/webfetch.ts

@@ -15,7 +15,8 @@ export const WebFetchTool = Tool.define("webfetch", {
     url: z.string().describe("The URL to fetch content from"),
     url: z.string().describe("The URL to fetch content from"),
     format: z
     format: z
       .enum(["text", "markdown", "html"])
       .enum(["text", "markdown", "html"])
-      .describe("The format to return the content in (text, markdown, or html)"),
+      .default("markdown")
+      .describe("The format to return the content in (text, markdown, or html). Defaults to markdown."),
     timeout: z.number().describe("Optional timeout in seconds (max 120)").optional(),
     timeout: z.number().describe("Optional timeout in seconds (max 120)").optional(),
   }),
   }),
   async execute(params, ctx) {
   async execute(params, ctx) {

+ 4 - 4
packages/opencode/src/tool/webfetch.txt

@@ -1,13 +1,13 @@
 - Fetches content from a specified URL
 - Fetches content from a specified URL
-- Takes a URL and a prompt as input
-- Fetches the URL content, converts HTML to markdown
-- Returns the model's response about the content
+- Takes a URL and optional format as input
+- Fetches the URL content, converts to requested format (markdown by default)
+- Returns the content in the specified format
 - Use this tool when you need to retrieve and analyze web content
 - Use this tool when you need to retrieve and analyze web content
 
 
 Usage notes:
 Usage notes:
   - IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.
   - IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.
   - The URL must be a fully-formed valid URL
   - The URL must be a fully-formed valid URL
   - HTTP URLs will be automatically upgraded to HTTPS
   - HTTP URLs will be automatically upgraded to HTTPS
-  - The prompt should describe what information you want to extract from the page
+  - Format options: "markdown" (default), "text", or "html"
   - This tool is read-only and does not modify any files
   - This tool is read-only and does not modify any files
   - Results may be summarized if the content is very large
   - Results may be summarized if the content is very large