Add Droid SDK provider#2689
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
|
Latest Droid follow-up fixes pushed in c72f19b:
Validation: |
|
Addressed the unresolved Droid cleanup review thread in b1dabf8. Added a regression test covering two resumed Droid sessions where one Validation:
Note: the first full-suite run hit a timeout in |
ApprovabilityVerdict: Needs human review This PR introduces a complete new Droid SDK provider integration with extensive new logic across driver, adapter, settings, runtime modes, and UI components. The scope represents a significant new feature, and there are unresolved review comments identifying potential bugs in runtime mode handling and concurrent turn state management. You can customize Macroscope's approvability policy. Learn more. |
|
Split the Droid adapter by responsibility in af7ffb0:
The Droid implementation is now 989 lines total across focused modules instead of one nearly 900-line adapter file. Validation:
|
|
Addressed the two remaining Cursor Bugbot review threads in 8939e57:
Validation:
|
|
Addressed the remaining token-usage review thread in 742ab64:
Validation after this fix:
Earlier in this pass, full |
|
Follow-up fixes for the latest automated review threads:
Validation:
|
|
Follow-up for the latest Cursor Bugbot token usage thread:
Validation after this change:
|
|
Fixed the latest Cursor Bugbot thread:
Validation:
|
|
Addressed the latest Droid review batch in
Validation: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 450fa08. Configure here.
| runtimeMode, | ||
| setComposerDraftRuntimeMode, | ||
| setDraftThreadContext, | ||
| ]); |
There was a problem hiding this comment.
Runtime mode normalization persists downgrade before providers stabilize
Medium Severity
The useEffect normalizes and persists the runtime mode as soon as serverConfig is non-null, without verifying that provider selection has stabilized. If resolveSelectableProvider temporarily resolves to a non-Droid provider (e.g., during reconnection, provider reloading, or if the Droid instance ID doesn't match), a thread's medium-access mode is normalized to auto-accept-edits and irreversibly written via setComposerDraftRuntimeMode and setDraftThreadContext. Once persisted, switching back to Droid won't restore medium-access since rawRuntimeMode already reflects the downgrade.
Reviewed by Cursor Bugbot for commit 450fa08. Configure here.
| }).pipe(Effect.forkDetach); | ||
|
|
||
| return { threadId: input.threadId, turnId, resumeCursor: context.droid.sessionId }; | ||
| }); |
There was a problem hiding this comment.
Concurrent sendTurn calls corrupt shared context state
Low Severity
sendTurn unconditionally resets mutable context fields (activeAssistantItems, activeAbort, activeTurnError, etc.) and launches a detached fiber without checking if a previous turn is still running. If a second sendTurn is issued before the first completes, both detached fibers share and mutate the same context object, leading to corrupted token accounting, lost streaming items, and incorrect turn completion state.
Reviewed by Cursor Bugbot for commit 450fa08. Configure here.


Intention
Add Droid as a first-class T3 Code provider using Factory's TypeScript SDK: https://github.com/Factory-AI/droid-sdk-typescript
This is still WIP while we validate more real Droid permission, file, MCP, auth, and long-running streaming flows.
What this adds
droidto the shared provider, model, settings, runtime source, and driver contracts.createSession/resumeSessionfrom@factory/droid-sdkin a T3 provider adapter.gif,jpeg,png,webp) as base64 SDK image sources resolved through the existing attachment store.initResult.availableModels, including user/custom models, while preserving custom model ids so duplicate underlying models remain selectable.Implementation shape
The Droid adapter has been split by responsibility instead of keeping one large file:
DroidAdapter.ts: session lifecycle and adapter orchestration.provider/droid/DroidRuntimeEvents.ts: SDK message to T3 runtime event projection.provider/droid/DroidSdkMappings.ts: SDK model, access, reasoning, usage, approval, and user-input mappings.provider/droid/DroidAttachmentResolver.ts: attachment MIME validation and image loading.provider/droid/DroidAdapterTypes.ts: shared Droid adapter types.Security / safety notes
droid; prompt content is sent through the SDK rather than shell interpolation.Validation
droid exec --model glm-5.1 --cwd /tmp ...returneddroid-pong.HomeLab - GLM-5.1,HomeLab - Trinity-Large-Thinking,Direct - GPT-5.5-Fast-xHigh, andDirect - GPT-5.5-Low.numTurns; streaming, thinking, access-mode mapping, and custom model discovery were updated.bun fmtpassed.bun lintpassed with existing unrelated web warnings.bun typecheckpassed.cd apps/server && bun run test src/provider/Layers/DroidAdapter.test.ts src/provider/Layers/DroidProvider.test.ts.bun run testpreviously passed; after rebasing, one full parallel run hit three unrelated web timeout failures, and rerunning those exact files in isolation passed.Note
Add Droid SDK provider with full session, turn, and event streaming support
DroidDriverandmakeDroidAdapterto integrate the@factory/droid-sdk(v0.2.0) as a first-class provider, registered inBUILT_IN_DRIVERSand the provider registry.handleDroidMessage.medium-accessruntime mode mapped to autonomy levelMediumfor Droid; the UI exposes this as an extra option in the access mode picker only when the Droid provider is active.--version) and optionally discover available models via a short-lived SDK session, with timeouts and fallback defaults.badgeLabel: 'WIP') and text generation fails by design; switching providers coerces unsupported runtime modes toauto-accept-edits.Macroscope summarized 450fa08.
Note
Medium Risk
Adds a new first-class provider with session lifecycle, permission mediation, and streaming event mapping; correctness issues could affect runtime state, approvals, and token-usage accounting. Droid is disabled by default, reducing blast radius, but it touches core provider/contract surfaces and UI runtime-mode selection.
Overview
Adds Droid as a new provider backed by
@factory/droid-sdk, including a managed server driver that probes thedroidCLI, discovers available models, and exposes a provider snapshot with update/advisory metadata.Implements a Droid adapter that starts/resumes/stops sessions, streams SDK messages into canonical runtime events (content/tool lifecycle, token usage, MCP/auth/status, errors), routes SDK permission and ask-user callbacks through T3 approvals/user-input, and supports image attachments by loading/validating files and sending base64 sources.
Extends shared contracts/settings to include
DroidSettings, new runtime raw sources, provider/model defaults, and introduces a newRuntimeModevaluemedium-access(treated as workspace-write for Codex, and surfaced in the web UI only for Droid with provider-specific labels and normalization when switching providers).Reviewed by Cursor Bugbot for commit 450fa08. Bugbot is set up for automated code reviews on this repo. Configure here.