[WIP] Reduce SKILL.md token consumption#46
Draft
atemate wants to merge 2 commits into
Draft
Conversation
The full SKILL.md body is injected into every agent conversation's system prompt. At 12KB it was the single largest contributor to per-conversation token cost, and the linked reference docs added another 17KB when eagerly read. Changes: - Tighten trigger description to reduce false activations - Collapse verbose sections to essential commands and rules - Inline key gotchas instead of linking to reference docs - List reference docs as plain-text paths (on-demand, not eager) - Cut platform-specific notes, philosophy, troubleshooting - Preserve all critical rules and safety warnings
344b5ca to
1c706b9
Compare
The sub-agent test revealed that "All cell variables are in scope" is misleading — variables are only available from cells that have been run in the current session, not just defined.
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.
This pull request was authored by a coding agent.
Summary
SKILL.md is injected into every agent conversation's system prompt. At 12KB it's the single largest contributor to per-conversation token cost. The 4 linked reference docs add another 17KB when the agent eagerly
Reads them (which it does often, given the broad trigger description).This PR reduces the skill body from 12KB → 4KB (67%) while preserving all critical rules, safety warnings, and on-demand access to detailed guides.
What changed
--help)What's preserved
All critical rules and behavioral guidance:
ctx.edit_cell()async withis required — without it, operations silently do nothingctx.packages.add()instead ofpip/uv add-cwith semicolons)create_cell/edit_cellare structural — userun_cellto execute_prefix), duplicate import errors--session IDfor multi-notebook serversreference/for widgets, gotchas, invocation, improvementsWhat's removed
--help; agents don't use MCP via this skillfinding-marimo.mdinline contentreference/reference/rich-representations.mdContext
Related discussion in marimo-team/marimo#8177 (MCP agent friction points) — token overhead from the bash-based skill architecture is a compounding cost. This PR addresses the most controllable part: the static prompt size.
The reference docs (
reference/*.md) are not deleted — they remain available for on-demandReadaccess. The change is that the agent is no longer nudged to read all of them on every session.Sub-agent test results
Tested locally with a Claude sub-agent that was given ONLY the patched SKILL.md (no prior context). The agent was tasked with: discover servers → execute code → create a cell via code_mode → verify.
Results:
async with cm.get_context(),ctx.create_cell(),ctx.run_cell()Edit/Writethe.pyfileTest plan
Install the patched skill
Functional checks
bash scripts/discover-servers.sh— finds running serversbash scripts/execute-code.sh --port 2718 -c "1+1"— returns resultcode_modeAPI (create_cell,run_cell,edit_cell) — worksreference/*.md) still readable when explicitly needed