Repository navigation
Disable the summarize analyzer for the SDK persona - #703
Conversation
Summarize prices what a filesystem scan of AGENT INSTRUCTION FILES found. Its population is the catalog in `core/summarize/agent_files.toml`: `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, the rules / skills / commands / agents markdown beside them, and the `~/.claude`, `~/.codex`, `~/.gemini` equivalents. It has never read application source, and the only widening it offers (the user-invoked `tj summarize list --recursive`) admits more markdown, never the `.py`/`.ts` a prompt template lives in. So for an SDK/API-dominant window the scan has no input, and the analyzer can only produce a card with no fix behind it. That is the same bar the `sdk` key already applies to `deadweight` and `subagent`, so it joins them in `PERSONA_DISABLED_ANALYZERS` rather than getting a second gating scheme: a true skip before dispatch, mirrored automatically into the Review inbox's own selection surface through `cost_analyzers_for_persona`. Nothing changes for Claude Code or Codex users. An interactive coding agent classifies as the `claude-code` persona, never `sdk`, and `tj summarize` stays a command anyone can type; the gate drops the analyzer from optimize reports, not the lifecycle. Two `tj optimize` strings were asserting the wrong reason for an SDK reader and are now persona-aware: the "Not run:" line hardcoded the claude-code "no fix inside an interactive coding-agent session" wording, and the skipped- filesystem-scan note hardcoded three analyzer names, blaming a scope skip for absences the persona gate had already caused. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
| Filename | Overview |
|---|---|
| tokenjam/core/optimize/runner.py | Adds the SDK summarize gate, but uses a telemetry-derived persona to suppress an analyzer whose inputs are independent filesystem state. |
| tokenjam/cli/cmd_optimize.py | Adds shared persona-aware rendering for filesystem-scan and explicitly requested gated-analyzer notices. |
| tests/unit/test_persona_analyzer_gate.py | Expands gate and downstream-card coverage, but tests only an SDK fixture assumed not to have independently available summarize inputs. |
| tests/unit/test_optimize_summarize.py | Reclassifies summarize analyzer fixtures as Claude Code so existing analyzer behavior remains exercised. |
| README.md | Documents summarize as unavailable for SDK users, inheriting the gate's overly broad filesystem-input assumption. |
| docs/agent-capability-matrix.md | Updates persona capability claims consistently with the new gate. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Telemetry sessions] --> B[dominant_persona]
B -->|sdk| C[Remove summarize before dispatch]
D[Project and global instruction files] -. independent input .-> E[Summarize filesystem scan]
C -->|scan never runs| F[Finding absent from report and Review]
E --> G[Potential summarize finding]
Prompt To Fix All With AI
### Issue 1
tokenjam/core/optimize/runner.py:183
**SDK gate suppresses filesystem findings**
If an SDK-dominant telemetry window is analyzed where cataloged project or global instruction files exist, the unconditional persona gate removes `summarize` before its independent filesystem scan runs, causing actionable instruction-file savings to disappear from the optimize report and Review inbox.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "Disable the summarize analyzer for the S..." | Re-trigger Greptile
| # never `sdk`. `tj summarize` itself stays available to everyone — the | ||
| # gate drops the analyzer from optimize reports, not the command. | ||
| "summarize", | ||
| }), |
There was a problem hiding this comment.
SDK gate suppresses filesystem findings
If an SDK-dominant telemetry window is analyzed where cataloged project or global instruction files exist, the unconditional persona gate removes summarize before its independent filesystem scan runs, causing actionable instruction-file savings to disappear from the optimize report and Review inbox.
Knowledge Base Used: Session Analysis and Export
Prompt To Fix With AI
This is a comment left during a code review.
Path: tokenjam/core/optimize/runner.py
Line: 183
Comment:
**SDK gate suppresses filesystem findings**
If an SDK-dominant telemetry window is analyzed where cataloged project or global instruction files exist, the unconditional persona gate removes `summarize` before its independent filesystem scan runs, causing actionable instruction-file savings to disappear from the optimize report and Review inbox.
**Knowledge Base Used:** [Session Analysis and Export](https://app.greptile.com/metabldr/-/custom-context/knowledge-base/metabuilder-labs/tokenjam/-/docs/session-analysis-export.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
summarizeruns for every persona today, including SDK/API windows where it has nothing to look at. This gates it off for thesdkpersona and corrects the surfaces that claimed otherwise.Summary
summarizejoinsdeadweightandsubagentunder thesdkkey ofPERSONA_DISABLED_ANALYZERS(tokenjam/core/optimize/runner.py) — a true skip before dispatch, not a run-and-report-disabled finding.cost_analyzers_for_personaandcost_proposals_from_report's_pickboth read the same map, so nosummarizecard can reach an SDK user's inbox either.tj optimizestrings that asserted the wrong reason for an SDK reader are now persona-aware.docs/agent-capability-matrix.mdupdated so the published persona tables match the gate.Why an SDK window has no lever here
summarizeprices what a filesystem scan of agent instruction files found. Its population is the catalog intokenjam/core/summarize/agent_files.toml:CLAUDE.md/CLAUDE.local.md,AGENTS.md/codex.md,GEMINI.md.claude/rules/**/*.md,.claude/skills/*/SKILL.md,.claude/commands/*.md,.claude/agents/*.md~/.claude,~/.codex,~/.geminiequivalentsIt has never read application source. The only widening it offers is the user-invoked
tj summarize list --recursive, and that walk admits.md/.markdown(_DEFAULT_EXTSincore/summarize/candidates.py), never the.py/.tswhere an SDK workload's prompt templates actually live.So for an SDK/API-dominant window the scan has no input by construction. Running it can only produce a card with no fix behind it, which is exactly the bar
PERSONA_DISABLED_ANALYZERS'ssdkkey already applies todeadweight(no on-disk Claude Code transcript) andsubagent(sub_agent_idnever populated). Same mechanism, third entry — no parallel gating scheme.What now happens for those users
summarizeis absent from an SDK window's report entirely, rather than rendering a permanently-thin card. A gated analyzer vanishes; it does not render a placeholder.tj optimize summarizeby name, they get the one-line "not run, and why" answer, because silence after a typed command reads as a bug.write_budget.measured_agent_file_tokensreads this finding as the write budget's denominator. With the finding absent it takes its documentedNonepath — leave the lane cap intact rather than invent a footprint — which errs toward more headroom, the conservative direction for a suppression gate.Nothing changes for Claude Code or Codex users. An interactive coding agent classifies as the
claude-codepersona (framing.dominant_personaviaalerts.is_interactive_coding_agent), neversdk, so Codex and Gemini CLI users keep the analyzer. Andtj summarizestays a command anyone can type: the gate drops the analyzer from optimize reports, not the prepare/check/apply lifecycle.Two CLI strings that were asserting the wrong reason
Both in
tokenjam/cli/cmd_optimize.py, both pre-existing and both made more visible by a thirdsdkgate entry:"deadweight, relearn and summarize did not run: <scope reason>". For an SDK window that blamed the scope for absences the persona gate had already caused._filesystem_scan_note()now filters the names against the gate and prints nothing when the skip cost this reader nothing.Tests / Verification
tests/unit/test_persona_analyzer_gate.py:SDK_NO_LEVERpin (derived from the production map, then asserted against an explicit set) now namessummarize, so a silent drop from the gate fails immediately.test_summarize_is_gated_for_sdk_and_untouched_for_claude_code— names the analyzer explicitly rather than relying on set-wise coverage, and asserts both halves: not invoked and absent fromreport.findingsfor an SDK window, still invoked for a claude-code window. The second half is what stops the first from passing vacuously ifsummarizeever stopped being dispatched at all.test_summarize_card_is_dropped_from_the_review_inbox_for_sdk— handscost_proposals_from_reporta report that carries the finding (a real shape: a cached payload or a wider selection can hold one) and asserts the card exists forclaude-codebefore asserting its absence forsdk, so the fixture's own validity is pinned.test_gate_saves_real_query_work_on_a_claude_code_windowcompared claude-code's statement count against sdk's, which was a proxy for "the claude-code gate is the only heavy one". Adding a third sdk entry inverted it: it failed while both gates worked perfectly. Replaced bytest_gate_saves_real_query_work_for_both_gated_personas, which measures each persona against itself with the gate emptied. A control that can invert without the property under test changing was measuring the wrong thing.tests/unit/test_optimize_summarize.py: this suite seededtests.factories' defaultagent_id="test-agent", which classifies assdk— so every test built the one window shape in which this analyzer cannot run. Sessions now seed a coding-agent id, with a comment saying why the vehicle has to be a claude-code window. No assertion was weakened.What's also in this PR
The README analyzer table listed
subagentas ✅ for SDK, which contradictsPERSONA_DISABLED_ANALYZERS["sdk"]and predates this change. Corrected to—alongsidesummarize, because the same table is the subject of this PR anddocs/agent-capability-matrix.md's SDK cell — which I had to rewrite anyway, since its "twelve of thirteen" count no longer held — would otherwise have contradicted it. Both are one-cell truth corrections; easy to drop if you would rather they landed separately.What's NOT in this PR
ui/index.htmlalready handles an absentsummarizefinding correctly: the nav child is gated onsf.candidates.length, and the Optimize action row onsf.files > 0. Nothing renders a zero or an empty-state claim.tj summarizeitself. The command, its catalog, and the prepare/check/apply lifecycle are untouched and remain available to every persona.summarize.py's module docstring still says the analyzer is "deliberately not aCOST_ANALYZERSmember", which stopped being true when it got a real peer card. Stale comment, unrelated to persona gating, left alone rather than folded into this diff.🤖 Generated with Claude Code