Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(provider): load Claude SDK only when needed #8104

Closedonmax(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/8104/headopened View on GitHub

What Changed

Changed the Claude adapter and capability probe to import SDK runtime values only when they start Claude work. Type imports remain static, and the existing injected query path is unchanged.

Added a regression test that makes the Claude SDK throw if importing the adapter evaluates it. Focused adapter and capability-probe tests pass with 78 tests, the server typecheck passes, and the production server bundle contains only deferred Claude SDK imports.

Why

T3 currently evaluates @anthropic-ai/claude-agent-sdk during server startup even when the active provider is Codex, Cursor, Grok, or OpenCode. Provider-specific runtime code should load at the point where T3 starts a Claude query or SDK capability probe. This keeps unrelated provider startup isolated while preserving the existing Claude behavior.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Created with the Codex harness using gpt-5.6-sol.


Note

Medium Risk Touches Claude session startup and capability probing, including abort-during-import cleanup. Behavior is otherwise unchanged, but SDK failures now appear later than module load.

Overview Stops evaluating @anthropic-ai/claude-agent-sdk when Claude adapter/provider modules load. Type imports stay static; query is dynamic-imported only when starting a session or probing capabilities.

Session start now uses Effect.tryPromise with abort handling so an interrupted lazy import does not call query. Injected createQuery is unchanged.

Adds a module-load regression test and an interrupt test covering the abort path. SDK load failures now surface at first Claude use instead of import time.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 20ebbc412af467614aea27a77549a6447f9feace. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Defer loading @anthropic-ai/claude-agent-sdk until session start in ClaudeAdapter

  • Changes ClaudeAdapter and ClaudeProvider to import only types from the Claude SDK at module load, and dynamically import() the query value inside Effect.tryPromise when a session starts or capabilities are probed.
  • Starting a Claude session now checks the abort signal before and after the dynamic import, and closes the runtime exactly once if interrupted during loading.
  • Adds tests asserting the adapter module imports without touching the SDK, and that interrupting startSession mid-import prevents query from being called.
  • Risk: createQuery is no longer passed the statically imported query as a default; callers that relied on the old default in ClaudeAdapter.ts must supply it via options or rely on the new dynamic import path.
Macroscope summarized 20ebbc4.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 56e718d0-128d-4665-b59f-6761405d3cb3

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 20ebbc4

      Macroscope's review found this PR approvable — The change is narrowly scoped to deferring Claude SDK loading until Claude functionality is actually used, with focused tests for import isolation and cancellation. It does not alter APIs, schemas, workflows, or deployment behavior.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Thanks for the PR. We're not taking changes to the orchestration and provider layers right now: that part of the server is being rewritten for V2, and merging into the current code would either conflict with or be thrown away by that work.

      Closing for now. If this is still an issue once V2 lands, please reopen (or open a fresh PR against the new code) and we'll take a proper look.

    5. juliusmarminge closed this

Sign in to join this conversation.