Skip to content

[interceptors] Data spillover for large tool results #67

Closed

Description

@Shreyavemana

Summary

A tool that returns a very large payload consumes the model's context. Add an interceptor that stores large results out of band and returns a preview plus a resource URI.

Reference

  • ts:core/interceptors/data-spillover.interceptor.ts: DataSpilloverInterceptor. URI prefix defaults to resource://data-spillover/. A payload over the store's maxBytes raises PayloadTooLargeError.
  • ts:core/interceptors/spillover/: spillover-store.interface.ts, memory-spillover.store.ts (TTL + LRU), fs-spillover.store.ts, preview-generator.ts, types.ts.

Scope

  • A SpilloverStore protocol (put, get, delete, TTL), with MemorySpilloverStore and FileSpilloverStore.
  • DataSpilloverInterceptor(threshold_bytes=..., store=..., resource_uri_prefix="resource://data-spillover/"), usable with @use_interceptors(...).
  • A preview generator for lists, dicts and strings: head items, counts, truncated text.
  • Spilled payloads are served as MCP resources, scoped to the caller.
  • File store: paths cannot escape the store root, total size is capped, and expired files are cleaned up.

Acceptance criteria

  • Results under the threshold are returned unchanged.
  • Results over the threshold return a preview, a URI and the original size; reading the URI returns the full payload.
  • An expired payload returns not-found.
  • A different principal cannot read the URI.
  • A path-traversal attempt on the file store fails.

Activity

  1. manish-wekan commented on Nov 2, 2026

    @manish-wekan
    Collaborator

    Implemented by #92 (merged into develop as b4d229b).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions