⚡️ perf(sarathi): page jobs run on Sonnet with only their tools (#659)

Merged
AT
2d ago
+87-19

sarathi page ran each job's claude -p session with Claude Code's whole tool list (32 tools) on the inherited Opus, because --allowedTools only approves tools. claudeArgs now passes --model sonnet, --tools Read,Artifact or --tools Artifact, and denies ArtifactData (and ArtifactComments where the job answers no comments).

Measured on 2026-11-27:

RunModelToolsFirst requestCost
trivial run, today's flagsOpus3238,492$0.31
trivial run, --tools ArtifactOpus328,236$0.23
trivial run, + ArtifactData denied (read)Opus120,362$0.16
trivial publish, this PR's flagsSonnet221,000$0.08
real --read of one page, released sarathiOpus—38,509—
real --read of the same page, this buildSonnet—20,300—

With no tools at all a session starts at 5,053 tokens, so the CLI's Artifact tool alone is about 15,000 and a page job cannot start much below 20,000.

Ran for real on this build (terminal, desktop entrypoint): publish of a scratch page, --read, --comments, and the guarded --url update after a read. Not run: --reply (no page had a comment thread) and the cloud (remote) entrypoint, where --tools and Sonnet are untested.

The README's "about 11,000 tokens" becomes the measured size of the desktop claude-artifacts server's seven eager tools (22,800 characters, roughly 6,000 tokens a request). The lesson that a deny leaves desktop-injected definitions in place is re-checked in three probe sessions (deny in settings.local.json, in settings.json, and with Artifact denied beside it): each still received all seven.

No version bump: #660 releases sarathi 0.8.15; this needs a later release and a pin bump before sessions run it.

Slice: #659

🤖 Generated with Claude Code


Summary by cubic

Speeds up sarathi page jobs by running each claude -p session on Sonnet with only the tools the job needs, instead of Claude Code's full tool list on the inherited Opus. First-request size drops from about 38,000 tokens to about 20,000, and a trivial run costs about a quarter of what it did (measured 2026-11-27).

  • claudeArgs now passes --model sonnet and --tools Read,Artifact (or Artifact alone for jobs that read no file); --allowedTools previously only approved tools, so the whole list stayed loaded.
  • Every job denies ArtifactData; jobs that do not answer comments also deny ArtifactComments. Artifact is still never denied by name.
  • Each job is a few mechanical calls checked by outcome, so Sonnet's output quality is not a concern.
  • The README's token estimates and the Claude Code lesson about desktop tool definitions are updated with measured values.

--reply and the cloud (remote) entrypoint are untested on this build. This needs a release and a pin bump after #660 before sessions run it.