Skip to content

feat(fix): experimental --agent sdk executor on the Claude Agent SDK - #89

Merged
lucasbraum merged 11 commits into
mainfrom
spike/agent-sdk
Oct 12, 2026
Merged

lucasbraum merged 11 commits into
mainfrom
spike/agent-sdk

Conversation

@lucasbraum

@lucasbraum lucasbraum commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Experiment behind a hidden flag: uptide fix <pkg> --agent sdk runs assisted fixes as Claude Agent SDK sessions instead of the single-shot patch agent. The default path does not change. Non-Anthropic providers are refused and keep the patch agent. Design, terms and the dependency finding are in docs/decisions/0016-agent-sdk-executor.md; what a session sends to Anthropic is in docs/privacy.md.

What's in it

  • packages/core/src/fix/sdk-agent.ts. One Agent SDK session per pack rule over its file group, with cwd set to the temporary clone.
    • Files. The task's files are its site files, the helpers the run placed, and the repository declarations the compiler links to a site's error.
    • Tools. Read, Grep, Glob, Edit and Write, plus three in-process tools: check_types, run_lint and run_tests. These run Uptide's own type-check, lint and tests through command(), which strips secrets from the environment.
    • No shell. The agent cannot install, use git or reach the network on its own.
    • Isolation. permissionMode: 'dontAsk', settingSources: [], persistSession: false, and a minimal environment.
    • Guard. A PreToolUse guard refuses reads outside the clone, .git, symlink escapes, edits outside the task's files, and every other tool.
  • Context, not orders. The prompt carries the sites, the rule's knowledge, the pack's changelog sections and links, the pack's decisions, the placed helpers, and the detected conventions. Each session ends with a structured summary: {changed, newFiles, decisions, assumptions, couldNotDo}.
  • Gate.
    • After each session, the edit rules. The task is rejected if it edits outside its files, creates a file it didn't declare, or adds @ts-ignore, @ts-expect-error, as any or as unknown as. Otherwise its edits become one commit.
    • Per batch, types and lint. A multi-site rule is its own batch; the single-site rules share one. The type-check is incremental (typeChecker(): one TypeScript builder program per workspace across checks, re-checking only what a change can affect). Diagnostics are matched through main's gitLineMoves. Lint runs on the changed files after formatting.
    • Once, after every batch, the related tests. These are the tests related to everything the agent changed: the owning workspaces and their direct dependents, side by side, with a bare vitest run/jest script run in related mode. They are compared with the start only when one fails. If one fails, the batches are replayed from the start and the one that broke it is dropped.
    • A rejected batch of several tasks is retried one task at a time.
  • Final verdict unchanged: settle, the full selected suite, the pre-upgrade baseline through gitLineMoves, the tree hash and the export.
  • Per-task record in report.json under llm.tasks[]: turns, tokens, cost, wall time, tool calls, gate verdict, rejection, and summary.
  • This round, also:
    • The Stripe subscription-period context and decisions now say that webhook payloads follow the endpoint's API version. Handlers must read both shapes, with no as number that would store an Invalid Date.
    • A test that --agent sdk refuses OpenAI and Gemini.
    • The jest argument-order fix and its fallback came from main (fix(fix): assisted Stripe fixes on real repositories #87) in the merge; this branch's duplicate was dropped.

Results (round 2)

All runs used claude-sonnet-5-5 on public repos, 3 runs per agent, with no --pr, --max-cost at $1, on the same build (0f7a9e7, after merging #87). Each value is the median, with the range in parentheses. Wall time is the whole uptide fix run. "Rejections" counts reverted attempts for the patch agent and rejected tasks for the SDK agent.

Repo / command Agent Wall LLM cost Types Tests Sites fixed / manual Rejections Verified
boxyhq/saas-starter-kit @ abc9b68, fix stripe patch 167s (161–194) $0.038 (0.028–0.038) 4 → 0 passed (4 tests¹) 4 / 1 0 3/3
sdk 217s (209–227) $0.30 (0.30–0.30) 4 → 0 passed (4 tests¹) 5 / 0 0 3/3
plain Claude Code (reference, one run) ~60s $0.38 tsc 0 4 passing n/a n/a n/a
alanagoyal/alanagoyal @ 22aa5f1, the printed Next command² patch 266s (257–290³) $0.11 (0.10–0.11) 13 → 2 passed 10 / 2 3 0/3
sdk 162s (161–170) $0.098 (0.090–0.114) 13 → 0 passed 12 / 0 0 3/3
howardyang2009/PATH @ bb17141, fix zod --target 4.6.5 patch 652s (563–678) $0.13 (0.11–0.15) 27 → 7 (6–7) 5 of 6 workspaces fail 3 (3–4) / 10 10 (7–12) 0/3
sdk 657s (633–666) $0.44 (0.44–0.47) 27 → 2 3 of 6 workspaces fail 9 (8–10) / 4 0 0/3

¹ No test in boxyhq imports the migrated files, so the related run finds none and the repository's suite runs instead (main's fallback from #87).
² fix react @radix-ui/react-tabs @radix-ui/react-tooltip react-resizable-panels --target 19.3.0 --allow-peer @emoji-mart/react.
³ The Mac slept during one patch run (wall clock 13,579s). Its own report measured 270s, so it counts as about 290s.

boxyhq checks, all 3 runs per agent:

patch sdk plain Claude Code
apiVersion pinned yes (rule) yes (rule) no
sync-stripe.js reported, manual migrated missed
Webhook reads both payload shapes 0/3 (the helper reads items only, so an old-version endpoint still gives an Invalid Date) 3/3 (items first, then typed subscription-level fields) yes
A missing period fails loudly created handler throws "no items" when there are no items, but not for an old-shape payload 3/3: "has no billing period" no (Invalid Date)

Cost per fixed site, pooled over the 3 runs:

Repo patch sdk
boxyhq $0.009 (12 sites) $0.061 (15)
alanagoyal $0.011 (30) $0.008 (36)
PATH (zod) $0.039 (10) $0.050 (27)

Speed, against the PATH target of under 8 minutes

Not met: the median is 10m57s. Round 1 took 28 minutes; the first change in this round brought it to 18m50s and the gates to 10m32s, with the same fixes.

Where the 10m32s goes (--verbose):

Phase Time
Uptide before the agent: check, baseline types and tests, install ~2.5 min
Agent sessions 3.6 min
The SDK gate: types and lint per batch, related tests once 2.4 min
Final verification (settle: full suite 1m38s, types 23s) ~2 min

The patch agent takes the same time on this build (652s). The rest is Uptide's own verification, which neither agent can shorten. On this repo the root test script is pnpm -r run test, so the baseline and final suites run every workspace twice: once from the root and once per workspace. Removing that duplication would save about 1.5–2 minutes for both agents. It changes the default path's test selection, though, so it is not in this PR.

The round's speed changes:

  • the incremental type-check: on PATH, 7.1s fresh, 2.3s after a one-file edit, 41ms unchanged;
  • related-only test planning for the SDK gates. Before it, a bare vitest run script and the root's pnpm -r ran the whole monorepo on every check;
  • tests once per assist instead of once per task;
  • the agent's own run_tests limited to the owning workspaces;
  • related workspaces run in parallel.

Failure modes seen this round

  • Patch agent, alanagoyal: a regression from fix(fix): assisted Stripe fixes on real repositories #87's grouping, which is on main. The two notes-app.tsx sites now go out as one task, but their fixes are in two different presenter files. The agent answers "No patch submitted" 3/3 times, although it describes the right fix. Before fix(fix): assisted Stripe fixes on real repositories #87 it fixed 12/12. I'm flagging it as a separate fix.
  • Patch agent, PATH. The same snippet-scope failures as round 1.
  • SDK agent. No rejections. Some sites are left manual with the agent's own reasons (zod ZodRawShape and ZodErrorMap: "no edit needed" or "needs a product decision").
  • Benchmark caveats. The Mac slept during two patch runs. One was re-run (zod); the other is counted by its own report timing (alanagoyal).

Distribution (finding, not acted on)

The terms allow a normal dependencies entry: npm installs Anthropic's unmodified bytes, and Uptide redistributes nothing. The install size rules it out. The SDK is 5.5 MB, but its platform binary is 240.7 MB on macOS arm64 and 257.1 MB on Linux x64, plus about 24 MB of peers. That is about 270 MB on every npx uptide, against Uptide's 11 MB, including for users who never pass the flag. Keep the optional peer.

Three questions to confirm with Anthropic before a default ships:

  1. Does the publisher of a free CLI, whose users bring their own API key, need its own Commercial Terms agreement?
  2. Is an npm dependency "preinstalling" Claude Code?
  3. Is leaving the binary's built-in login untouched, while Uptide documents only API keys, consistent with both login rules?

The links are in the decision record.

Recommendation

Go for Anthropic, as the default when the SDK is installed; otherwise the patch agent, with a one-line hint.

  • On all three repos the SDK agent fixes at least as many sites, with 0 rejections. It is the only agent that verifies alanagoyal (3/3 against 0/3), and the only one that handles old-shape Stripe webhook payloads (3/3 against 0/3).
  • It costs more per run on small repos: $0.30 against $0.04 on boxyhq. That is still under the $1 default cap, and it is cheaper per fixed site on alanagoyal.
  • Before flipping it: the three Anthropic confirmations above, and a note in uptide fix output that suggests installing the SDK when it's absent.

🤖 Generated with Claude Code

lucasbraum and others added 11 commits October 11, 2026 22:51
Hidden flag. Assisted fixes run as one Agent SDK session per pack rule
over its files in the temporary clone: read/edit tools, Uptide's own
type-check, lint and tests as in-process tools, no shell. One gate at the
end of each task (file scope, compiler escape hatches, types matched
across line shifts, lint and tests no worse than baseline); a rejected
task is reset and its sites stay manual. Anthropic only; the patch agent
stays the default. The SDK is an optional peer, never bundled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
…int gate

The guard denied StructuredOutput, so no summary came back; lint judged
unformatted edits where settle formats first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
A React 19 RefObject<T | null> error is fixed in the prop type the
compiler links it to, in another file; the task's scope had only the
site files, so the agent stopped and said so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
…ites by their own error

An upgrade can fail tests until every site is migrated: comparing each
task with the pre-upgrade baseline rejected every zod task. A site fixed
in another file (a prop type) now counts as fixed. The cost of a session
stopped by its budget is kept: the SDK emits the result, then throws.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
…l back when the related run cannot start

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
…repository

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
…o in the period context and decisions

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
… data and distribution

- typeChecker(): one TypeScript builder program per workspace across checks,
  re-checking only workspaces whose repository files changed (PATH monorepo:
  7.1s fresh, 2.3s after a one-file edit, 41ms unchanged). diagnostics() is a
  one-shot of it.
- Each task's edit rules run right after its session; single-site rules share
  one gate, retried one task at a time when it fails.
- Tests per batch are those related to its files; the start-of-batch run
  happens only to explain a failure. settle still runs the full selected suite.
- The session also sets DISABLE_FEEDBACK_COMMAND and
  CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL. docs/privacy.md says
  what it sends; the decision record has the dependency-vs-optional-peer
  finding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
A workspace whose test script is just the runner, with no config file,
ran its whole suite on every check, and the root's pnpm -r test ran every
workspace's again. With related: the owning workspaces and their direct
dependents, the root only for its own files, and a bare runner script in
related-tests mode. Verification's selection is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
#87 fixed the jest argument order and the related-tests fallback on main,
and matches diagnostics across line moves (gitLineMoves). Main's versions
are kept; this branch's duplicate jest fix and its changeset are dropped.
The SDK gate now uses gitLineMoves too, so a task that passes its gate is
judged the same way by the final verdict; newDiagnosticsAcrossShifts is
gone. The incremental typeChecker and the related-tests mode for the SDK
gates are kept on top of main's verify.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
@lucasbraum
lucasbraum marked this pull request as ready for review October 12, 2026 18:24
@lucasbraum
lucasbraum merged commit 405f429 into main Oct 12, 2026
8 checks passed
@lucasbraum
lucasbraum deleted the spike/agent-sdk branch October 12, 2026 18:24
@uptide-release uptide-release Bot mentioned this pull request Oct 12, 2026
lucasbraum added a commit that referenced this pull request Oct 13, 2026
## What and why

Implements
[UPT-23](https://linear.app/uptide/issue/UPT-23/make-the-agent-sdk-executor-the-default-for-anthropic).

Authenticated Anthropic CLI fixes now use the Agent SDK by default when
it is installed; without it they fall back to the patch executor with a
one-line hint in the fix output. `--agent patch` opts out; OpenAI,
Gemini and callers supplying a fixer retain the patch executor.
`--no-llm` still disables assistance.

One session handles the package's remaining manual sites with shared
rule knowledge. It reuses the post-install TypeScript program, scopes
and caches session tests, and runs the full selected suite once at final
verification. Confirmed compiler findings already resolved by mechanical
edits are skipped by both executors. Undeclared scratch additions are
removed before revalidating the remaining edits; path checks reject
symlink escapes.

Stripe's shared period helper and both executors' guidance accept legacy
subscription-level and modern item-level webhook fields. Endpoint API
versions determine the payload shape.

The SDK stays an optional peer, external to both bundles: as a
dependency it would add about 270 MB to every `npx uptide`, `--no-llm`
and other providers included. The Uptide Action installs it. ADR 0016
records the size decision, our reading of the published terms, and three
questions for Anthropic that remain open. Privacy docs and CLI
disclosure describe repository reads, check output and the SDK
traffic/settings/persistence switches.

## Benchmark

Three trials × three public repositories × two executors: all 18
sequential runs completed
with Sonnet 5.5, medium effort and a $1 per-package budget. SDK trials
omit `--agent`, testing
the new default; controls explicitly select patch. Times, costs and
counts are medians
(ranges); cost per agent fix is total spend / total agent-fixed sites
across the three runs.
Final lockfiles match across all trials for each repository.

| Repository / upgrade | Executor | Time, median (range) | USD, median
(range) | USD / agent fix | Fixed: mechanical + agent; manual | Types
before → after | Verified |
| --- | --- | --- | --- | --- | --- | --- | --- |
| boxyhq / Stripe | patch | 2m58s (2m41s–3m18s) | $0.031 ($0.031–$0.072)
| $0.011 | 2 + 4; 1 | 4 → 0 | 3/3 |
| boxyhq / Stripe | sdk | 2m29s (2m27s–2m58s) | $0.188 ($0.186–$0.191) |
$0.044 | 2 + 4 (4–5); 1 (0–1) | 4 → 0 | 3/3 |
| alanagoyal / React | patch | 4m56s (4m06s–5m00s) | $0.103
($0.100–$0.105) | $0.010 | 1 + 10; 2 | 13 → 2 | 0/3 |
| alanagoyal / React | sdk | 1m47s (1m45s–1m48s) | $0.077
($0.076–$0.079) | $0.006 | 1 + 12; 0 | 13 → 0 | 3/3 |
| PATH / zod | patch | 7m36s (7m09s–7m37s) | $0.122 ($0.119–$0.144) |
$0.035 | 17 + 4 (3–4); 2 (2–3) | 27 → 6 (6–7) | 0/3 |
| PATH / zod | sdk | 6m59s (6m43s–8m30s) | $0.221 ($0.217–$0.239) |
$0.038 | 17 + 6; 0 | 27 → 2 | 0/3 |

[Method, exact revisions, individual trials and excluded development
runs](https://github.com/uptide-dev/uptide/blob/c8da53e6b67e1c5f8b354fe4b2f8357a758df127/docs/agent-sdk-evaluation.md).

- PATH meets the speed target on median, with all 23 planned fixes
retained in every SDK run; one run still takes 8m30s. A new engine
diagnostic and failing designer tests keep all PATH results unverified.
- React verifies 3/3 with SDK versus 0/3 with patch, which leaves two
ref-type errors in every trial.
- Stripe verifies 3/3 with both executors. Shared knowledge improves
patch too; patch is substantially cheaper here. The previous
one-third-cost-per-fixed-site claim does not hold in this rerun.
- Seven PATH sites are now correctly counted as mechanically resolved
for both executors. Compare total fixes and remaining diagnostics, not
agent-only totals, with PR #89.
- Synthetic checks of all six generated Stripe migrations confirmed that
both handlers accept legacy and item-based payloads. Two SDK and all
three patch trials retain the standalone sync script's API pin as a
manual decision.

The measured executor sources are in `cf5682b`; the later merge of
`main` adds 0.8.0 metadata
and `uptide.yml` support without changing the measured executor, pack or
verifier. Fixture
roots have no `uptide.yml`. Explicit configured executors are covered by
additional tests.
SDK uses full baseline/final suites and scoped session checks; patch
retains its existing
test selection/retry behavior. The test scopes are not identical.

## How it was verified

- [Implementation
CI](https://github.com/uptide-dev/uptide/actions/runs/38334848211)
passed lint, build, typecheck, full tests and clean-container
npm/pnpm/Yarn smoke tests on Node 20 and 22.
- Node 20: 1,724 tests passed, 34 skipped. Node 22: 1,726 passed, 32
skipped, plus 18 passing package-manager/bot-loop network tests.
- [Every migration pack
passed](https://github.com/uptide-dev/uptide/actions/runs/38334848243).
- Clean npm installation of the packed CLI automatically installed and
resolved the SDK.
- A real recursive pnpm check confirmed `--no-bail` runs later
workspaces while preserving failure status.
- Final documentation links and `git diff --check` passed locally. The
last commit changes documentation and a build-config comment only.

## Limits and tradeoffs

One session is accepted or reverted atomically. Users who want the SDK
executor install the
optional peer (roughly 270 MB unpacked, with native/peer packages) next
to Uptide.
ADR 0016's license finding is our reading of the published conditions,
not confirmation
from Anthropic; its three questions for Anthropic are open. Live Stripe
events and service-dependent application integration tests were
not run for this benchmark. PATH is not ready to publish, and the
under-eight-minute result
is a median rather than a per-run guarantee.

## Checklist

- [x] Tests for the change
- [x] `pnpm lint`, `pnpm typecheck` and `pnpm test` pass in
implementation CI
- [x] README, privacy, config and executor docs updated
- [x] New changeset for the default after the 0.8.0 release
- [x] Dependency decision requested by UPT-23 and recorded in ADR 0016
- [x] No private source or local paths added to fixtures, tests or docs
- [x] CONTRIBUTING.md invariants retained

---------

Signed-off-by: Lucas Braum <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant