Improve 60k limit upon reading - #46
yudistryan wants to merge 5 commits into
Conversation
Added functionality to handle oversized tool results by splitting them into manageable chunks. Introduced the `MAX_OVERFLOW_PARTS` environment variable to control the maximum number of chunks that can be fetched. Updated the MCP meta-tool to allow fetching subsequent parts using `continue_tool_result`. Documentation and tests have been added to cover the new behavior.
|
@yudistryan I think the execute_tool need context (in its description) about this tool so it chains and doesn't need skill to chain. |
|
|
cool.. another alternative in my mind: mimics how claude code handles it: write it as a file under /tmp, then tell the agent to use tool read_file to read it incrementally. @barockok, wydt should solve it by chunking like the PR or write to file? my alternative has another cons: how to cleans the /tmp directory so that the container did not run out of diskspace. |
Return all stored overflow parts in one tools/call so agents can concat without a continue loop; package execute_tools per results[] item with stubs/resultIndex; cap eager oversized items via MAX_OVERFLOW_ITEMS (default 2) and keep continue_tool_result for deferred/re-fetch.
|
guys @barockok @burungbangkai i just updated the PR to add context in execute_tools and now rather than serialize the context, it will do in parallel using execute_tools. Each continuation will be applied per item so it won't mixed up. Let me know if this approach is not really suited |
MAX_OVERFLOW_PARTS silently scaled the real storage budget with the per-block wire size, so changing MAX_RESULT_CHARS would shrink or blow up how much of an oversized payload is retained. Replace it with MAX_OVERFLOW_TOKENS (default 300000) and promote MAX_RESULT_CHARS to an env var (default 60000); part count is now the quotient, so operators retune only one knob.
|
Two architectural concerns worth revisiting: 1. Statefulness across pods The continuation store is in-memory ( 2. Pagination doesn't escape context growth The deeper issue with chunking is that paginating through continuation parts eventually loads the entire payload into the agent's context anyway — just spread across turns, with envelope overhead on top. It doesn't reduce context load; it defers it. Alternative worth considering: overflow URL instead of chunked parts When a result exceeds the char cap, persist the raw JSON to shared storage (GCS/S3 presigned URL, or a signed workbench endpoint backed by a shared PVC), return a small stub: { "_overflow": true, "url": "...", "size_bytes": 4200000, "ttl_seconds": 600 }The agent curls the URL and filters locally ( |
8a03290 to
9075106
Compare
|
Let me answer from second concern first mas @barockok. This capability is basically to let the agent reading all of the documents. Our objective is to ensure no missing context upon reading any documentation. Hence, we wanna allow the agent to read it all. This is QA specific task. To ensure other than QA agent not doing the same, we propose to add some limit as config such as As the first concern, is it possible to be stored somewhere mas @barockok? Since it won't be good to put it into in-memory but unable to store it into PVC. |
|
@yudistryan I |
|
@barockok basically, we just wanna read a whole document without any truncation mas. Let me update it so it'll store it into the PVC |
|
sorry was type @yudistryan |
8749f27 to
2a6cd4f
Compare
Summary
execute_toolsperresults[]item: small siblings stay inline incontent[0]; oversized items become stubs (continuationId,resultIndex,partsIncluded) plus following continuation envelopes.MAX_OVERFLOW_PARTS(default 5) and cap eager oversized items per batch viaMAX_OVERFLOW_ITEMS(default 2); deferred stubs usecontinue_tool_result(omitpart).continue_tool_resultas optional re-fetch (user-bound, 10‑minute TTL, in-memory).Diff highlights
result-overflow.tsMAX_OVERFLOW_ITEMSserver.tsexecute_toolsbatch pathmeta-tools.tsexecute_tools/continue_tool_resultcontracts.env.example/ docsMAX_OVERFLOW_PARTS,MAX_OVERFLOW_ITEMSAgent contract
tools/callreturns multiplecontent[]text blocks (envelopes withchunk).execute_tools: read stubs incontent[0].results[i]. IfpartsIncluded: true, concatenate thatcontinuationId'schunks from following blocks in ascendingpartorder, thenJSON.parse. IfpartsIncluded: false, callcontinue_tool_result(omitpart).continuationIds.continue_tool_resultis only for deferred items, discarded parts, or clients that only readcontent[0].Test plan
npm run test --workspace=@a-workbench/server -- tests/mcp-result-cap.test.tsexecute_toolswith one small + one large Confluence page → header stub + eager parts; second large page withMAX_OVERFLOW_ITEMS=1→ deferred stub +continue_tool_resultcomplete: falsewhen payload exceedsMAX_OVERFLOW_PARTS