fix(core): reject a zero limit on read calls (#63808)

This commit is contained in:
Aiden Cline
2026-11-13 11:50:08 -06:00
committed by GitHub
Unverified
parent f0f41c0164
commit 68fd7dd6b3
2 changed files with 19 additions and 0 deletions
+2
View File
@@ -53,6 +53,8 @@ export const Plugin = {
output: Output,
execute: (input, context) => {
return Effect.gen(function* () {
if (input.limit === 0)
return yield* new ToolFailure({ message: "Limit must be a positive integer" })
if (Skill.isUri(input.path)) {
const parsed = parseSkillUri(input.path)
if (!parsed) return yield* new ToolFailure({ message: `File not found: ${input.path}` })
+17
View File
@@ -223,6 +223,23 @@ describe("ReadTool", () => {
}),
)
it.effect("rejects a zero limit before reading", () =>
Effect.gen(function* () {
const registry = yield* Tool.Service
const result = yield* executeTool(registry, {
sessionID,
...toolIdentity,
call: { type: "tool-call", id: "call-zero-limit", name: "read", input: { path: "README.md", limit: 0 } },
})
expect(result).toMatchObject({
status: "error",
error: { message: "Limit must be a positive integer" },
})
expect(assertions).toEqual([])
expect(readCalls).toEqual([])
}),
)
it.effect("asks for external_directory approval before reading an external absolute path", () =>
Effect.gen(function* () {
const registry = yield* Tool.Service