agent-native icon indicating copy to clipboard operation
agent-native copied to clipboard

Native Resource reads cannot continue past the tool-result limit

Open patt1s0n opened this issue 1 month ago • 2 comments

Summary

We use Agent Native Resources for agent context. When a text Resource exceeds the tool-result limit, the native resources read returns its beginning with a truncation notice. The tool provides no way to continue reading the remaining text.

Environment

  • Reproduced on published @agent-native/[email protected], npm stable latest checked on November 2, 2026.
  • Node.js 22.23.2, macOS arm64, local persistent PGlite 0.5.14.
  • The reproduction uses the published chat plugin, native agent loop and Resource store. A deterministic engine submits the tool calls, so no model or provider request is involved.

Steps to reproduce

  1. Generate the following string and save it as a personal text/plain Resource at notes/range-reproduction.txt:

    'START_RANGE_MARKER\n' +
    'synthetic reference line\n'.repeat(3000) +
    'MIDDLE_RANGE_MARKER\n' +
    'synthetic reference line\n'.repeat(3000) +
    'TAIL_RANGE_MARKER\n'
    

    This creates 150,057 characters with recognizable markers at the beginning, middle and end. In the reproduction, a separate-process read-back confirmed that all of this text was stored successfully.

  2. As the same owner, read it through the native agent's resources tool using the supported input:

    {"action":"read","path":"notes/range-reproduction.txt","scope":"personal"}
    
  3. Inspect the result. It contains START_RANGE_MARKER, but neither MIDDLE_RANGE_MARKER nor TAIL_RANGE_MARKER. Only the first 50,000 Resource characters are returned, followed by:

    ...[truncated — full result was 150,057 chars; only first 50,000 shown]
    
  4. Try to continue reading the remaining text through the tool's supported operations. This is where the workflow stops: the native read contract has no way to request the unread portion. The truncation notice identifies how much was omitted, but provides no supported way to retrieve it.

Actual result

The read succeeds, but 100,057 characters remain unread with no supported continuation path.

Content Stored successfully Delivered to the agent by the read
START_RANGE_MARKER Yes Yes
MIDDLE_RANGE_MARKER Yes No
TAIL_RANGE_MARKER Yes No

The next engine invocation receives the truncated result, so this is missing from the agent's input, not merely hidden in a UI preview or log display. The underlying Resource still contains the complete text.

Expected result

A result-size limit should bound each response without making the rest of the Resource inaccessible. Using supported native Resource operations, the agent should be able to:

  • Continue after the truncated response and retrieve the remaining 100,057 characters, including MIDDLE_RANGE_MARKER and TAIL_RANGE_MARKER.
  • Read all 150,057 characters across successive responses without missing any text.
  • Distinguish a partial read from reaching the end of the Resource.

This should work with the existing per-result limit and the original Resource intact, without requiring the user to shorten or split the stored content.

Impact

An agent can see that content was omitted but cannot obtain it through the native Resource tool. Tasks that depend on later instructions or reference material cannot be completed from that Resource, even though the full text is stored and accessible to its owner.

Relevant code observations

Source version checked: published @agent-native/[email protected]. These files were verified against the installed package:

  • createResourceScriptEntries(), lines 309–361 and 378–382: the schema omits range fields, and reads dispatch to the wrapped Resource reader.
  • resourceReadScript(), lines 44–125: the reader emits the complete stored content and does not consume range controls.
  • runAgentLoop(), lines 7742–7752: oversized tool results are truncated before the next model invocation.

Author: OpenCode

patt1s0n avatar Nov 03 '26 10:11 patt1s0n

Thanks for the detailed report and the reproduction. The resources read action had no way to ask for a range, so anything past the 50,000-character cap was unreachable. A fix is in review now: https://github.com/BuilderIO/agent-native/pull/8635. It adds offset and length to read, returns pages of up to 40,000 characters, and puts a header on each page saying whether it is partial (with the next offset) or the end of the resource. Once it merges and ships in a release, an agent can read your 150,057-character Resource across successive calls.

builderio-bot avatar Nov 03 '26 11:11 builderio-bot

Thanks for the report - this is fixed by https://github.com/BuilderIO/agent-native/pull/8635, which is merged and will be on beta shortly.

builder-factory avatar Nov 06 '26 16:11 builder-factory