Skip to content

feat: enforce per-file size limit in files.write tool handler (#12)#21

Open
mgoldsborough wants to merge 1 commit intomainfrom
fix/issue-12-tool-file-size-limit
Open

feat: enforce per-file size limit in files.write tool handler (#12)#21
mgoldsborough wants to merge 1 commit intomainfrom
fix/issue-12-tool-file-size-limit

Conversation

@mgoldsborough
Copy link
Copy Markdown
Contributor

Summary

  • The API-layer `bodyLimit` middleware caps HTTP uploads, and `src/files/ingest.ts` enforces `maxFileSize` on the user-upload path. The `files__write` tool handler reached by the agentic loop does not traverse either — so the "no file larger than `maxFileSize`" invariant did not hold at the point of write.
  • Plumbed `runtime.getFilesConfig().maxFileSize` into `handleWrite` and reject the call with a descriptive error when the decoded payload exceeds it.
  • Reads from runtime config (not a hard-coded constant) so operators who raise the limit in `nimblebrain.json` see it applied consistently across the HTTP and tool-call paths.

Test plan

  • New `test/unit/tools/platform-files.test.ts` — 3 tests covering accept-within-limit, reject-over-limit (error message includes filename and mentions the limit), and respects runtime config override
  • `bun run lint` / `bun run check` — clean

Closes #12

The API-layer bodyLimit middleware caps HTTP uploads and files/ingest
enforces maxFileSize on the user-upload path, but the files__write
tool handler reached by the agentic loop does not traverse either —
so the "no file larger than maxFileSize" invariant did not hold at
the point of write.

Plumb runtime.getFilesConfig().maxFileSize into handleWrite and
reject the call with a descriptive error when the decoded payload
exceeds it. The check reads from runtime config (not a hard-coded
constant) so operators who raise the limit in nimblebrain.json see
it applied consistently across the HTTP and tool-call paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add file size limit enforcement at tool handler layer

1 participant