docs: add TOON format adoption spec#836
Open
MQ37 wants to merge 1 commit into
Open
Conversation
jirispilka
approved these changes
May 14, 2026
Collaborator
jirispilka
left a comment
There was a problem hiding this comment.
It looks good, I would transform this to an issue.
It will be easier to update it later, including new experiments and number.
After the implementation is done, we can publish it as an md too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Apify MCP tool responses wire JSON text content for most tools. Every Actor run, dataset listing, KV-store key, and dataset item lands in the caller LLM's context and stays there for every subsequent turn — the repeated keys in JSON arrays compound per request.
Solution
Research spec for an adaptive picker at each in-scope tool-call site: encodes both the current JSON and TOON (with a small dot-flatten transform) per response, ships whichever is smaller.
jsonis always a candidate, so the picker is never worse than today.Companion to Code Mode (#794) — TOON shrinks results that flow through the LLM context, Code Mode skips most of them entirely. The spec proposes exposing the picker's encoder as
apify.stringifyCompact()for Code Mode programs.No production code in this PR. Spec-only, pending team review.
Worth your attention
dataset-itemsaverages near zero — savings concentrate on list endpoints.fields=(separate proposal): 100-place Google-Maps result projected to 3 fields → 1.01 MB → 9.5 KB, ~110× smaller into LLM context.structuredContentis unchanged. OnlyTextContent.textshifts.outputSchemavalidation, MCP widgets, and programmatic consumers continue to see the same JSON.jsonalways in candidate set; defensivetry/catcharound the TOON candidate;MAX_DEPTH = 20guard with margin of 11 over deepest real fixture; dotted-key normalisation with collision guard.evals/workflows/regression gate before any production merge.Follow-up