-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Problem
The github_list_releases tool can return excessively large responses that cause the model to exceed context limits, resulting in "Input is too long for requested model" errors in brand new chats.
Root Cause Analysis
When fetching releases with include_body_and_assets: true, the tool returns massive amounts of data. Testing with coder/coder:
- 5 releases with bodies and assets = ~38KB of JSON
- Each release has ~24 assets (download URLs, sizes, counts, etc.)
- Release bodies can be ~1KB each (full changelogs)
- Requesting 100 releases with full data could exceed 500KB+
The tool implementation at packages/github/src/tools.ts (line ~928) passes data through without any size limits:
list_releases: toolWithOctokit(({ octokit }) =>
tool({
inputSchema: z.object({
owner: z.string(),
repo: z.string(),
page: z.number(),
per_page: z.number(), // No max limit!
include_body_and_assets: z.boolean(),
}),
execute: async (args, opts) => {
// ...
return {
releases: response.data.map((release) => ({
// Full body returned, no truncation
body: args.include_body_and_assets
? (release.body ?? undefined)
: undefined,
// ALL assets returned
assets: args.include_body_and_assets
? release.assets.map((asset) => ({ ... }))
: undefined,
})),
};
},
})
),Proposed Solution
Modify the tool in packages/github/src/tools.ts:
- Cap
per_pageto a reasonable max (e.g., 10 releases) - Truncate release bodies to ~500-1000 chars with a
[truncated]indicator - Limit assets per release to 5-10 most relevant ones
- Add response size indicator so the model knows data was limited
list_releases: toolWithOctokit(({ octokit }) =>
tool({
inputSchema: z.object({
owner: z.string(),
repo: z.string(),
page: z.number(),
per_page: z.number().max(10), // Hard cap
include_body_and_assets: z.boolean(),
}),
execute: async (args, opts) => {
const MAX_BODY_LENGTH = 500;
const MAX_ASSETS = 5;
const response = await (await octokit()).request(...);
return {
releases: response.data.map((release) => ({
// ...
body: args.include_body_and_assets && release.body
? release.body.length > MAX_BODY_LENGTH
? release.body.slice(0, MAX_BODY_LENGTH) + '... [truncated]'
: release.body
: undefined,
assets: args.include_body_and_assets
? release.assets.slice(0, MAX_ASSETS).map((asset) => ({ ... }))
: undefined,
total_assets: release.assets.length, // Let model know if more exist
})),
_truncated: true, // Signal that limits were applied
};
},
})
),Related Context
This affects the Blink agent (coder/agents) which uses github.tools directly. The fix should be in the SDK (coder/blink) since that's where the tool is defined.
Metadata
Metadata
Assignees
Labels
No labels