Skip to content

Commit 5e37ad3

Browse files
authored
fix: add support for auto-returning download URLs for specific endpoints helping agent not sending whole file to LLM (#142)
1 parent 0f5b0c6 commit 5e37ad3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/endpoints.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@
207207
"pathPattern": "/drives/{drive-id}/items/{driveItem-id}/content",
208208
"method": "get",
209209
"toolName": "download-onedrive-file-content",
210-
"scopes": ["Files.Read"]
210+
"scopes": ["Files.Read"],
211+
"returnDownloadUrl": true
211212
},
212213
{
213214
"pathPattern": "/drives/{drive-id}/items/{driveItem-id}",
@@ -278,7 +279,8 @@
278279
"pathPattern": "/me/onenote/pages/{onenotePage-id}/content",
279280
"method": "get",
280281
"toolName": "get-onenote-page-content",
281-
"scopes": ["Notes.Read"]
282+
"scopes": ["Notes.Read"],
283+
"returnDownloadUrl": true
282284
},
283285
{
284286
"pathPattern": "/me/onenote/pages",

src/graph-tools.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface EndpointConfig {
1616
toolName: string;
1717
scopes?: string[];
1818
workScopes?: string[];
19+
returnDownloadUrl?: boolean;
1920
}
2021

2122
const endpointsData = JSON.parse(
@@ -261,7 +262,12 @@ export function registerGraphTools(
261262
tool.errors?.some((error) => error.description === 'Retrieved media content') ||
262263
path.endsWith('/content');
263264

264-
if (isProbablyMediaContent) {
265+
if (endpointConfig?.returnDownloadUrl && path.endsWith('/content')) {
266+
path = path.replace(/\/content$/, '');
267+
logger.info(
268+
`Auto-returning download URL for ${tool.alias} (returnDownloadUrl=true in endpoints.json)`
269+
);
270+
} else if (isProbablyMediaContent) {
265271
options.rawResponse = true;
266272
}
267273

0 commit comments

Comments
 (0)