feat(SDKBridge): add in-process agent backend via OpenAgentSDK#1
Merged
feat(SDKBridge): add in-process agent backend via OpenAgentSDK#1
Conversation
Replace external opencode serve process with SDKBridge actor that uses Agent.stream() API. Adds BackendBridge enum wrapper, backend type setting, and AdvancedSettingsView picker for switching between OpenCode and SDK modes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Pass sessionStore + sessionId to AgentOptions so the SDK automatically persists and restores conversation history across prompts in the same session. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Pass MCP servers from SkillRegistry and environment variables from ConfigManager to the SDK's AgentOptions so the SDK backend can use the same external tools (motive-memory, custom MCP servers, etc.) as the OpenCode backend. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Pass skillDirectories to AgentOptions so SDK discovers SKILL.md skills - Fix critical bug where core tools (Bash, Read, Write, etc.) were not loaded when no MCP servers were configured (SDK's assembleFullToolPool returns empty on no-MCP path) - Add debug log level support - Remove invalid motive-memory MCP entry (it's an OpenCode plugin, not MCP) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Add missing modelProviderID parameter to OpenCodeBridge.Configuration in OpenCodeBridgeTests - Add missing provider/modelName/apiKey parameters to OpenCodeConfigGenerator.Inputs in ConfigManagerConfigTests - Fix permissionRulesDoNotContainQuestionDeny test: question is now a valid ToolPermission case, so assert it's not denied instead of nil Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Secondary finish events (isSecondaryFinish=true, e.g., session.idle after error) should not produce conversation messages. Added early return in toMessage() to match test expectations. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add ability to configure custom MCP stdio servers in Settings > Advanced > MCP Servers (visible when SDK backend is selected). Servers are persisted as JSON in UserDefaults and merged into the SDKBridge's MCP config alongside skill-based entries. - CustomMcpServerConfig: Codable model with name, command, args, env, and enabled toggle - ConfigManager: @AppStorage + computed property for persistence - AppState+Bridge: merge custom servers in buildSDKMcpServers() - AdvancedSettingsView: collapsible section with add/edit/delete sheet for server configuration Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Call configureBridge() before every submitIntent/resumeSession call. This fixes "SDK bridge not configured" errors that occur when the async configuration in start() hasn't completed yet, or when settings changes trigger a restart that races with prompt submission. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ey support - Inject extended PATH (nvm, homebrew, etc.) into MCP server env vars so MCP servers can find node/python executables in macOS GUI app context - Add detailed debug logging for MCP server config in configureBridge and createAgent - Allow empty API key for providers that support optional auth (LM Studio, Ollama) - Guard submitIntent/resumeSession against proceeding after configureBridge sets error - Always include core+specialist tools regardless of MCP server presence - Handle bridge type mismatch by rebuilding bridge in configureBridge Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SDKBridgeas a new in-process agent backend using the OpenAgentSDK Swift package, replacing the externalopencode serve+ HTTP/SSE approach with directAgent.stream()callsBackendBridgeprotocol abstraction so the app can switch between legacy OpenCode HTTP bridge and the new SDK bridgeSessionStoreOpenCodeEvent.toMessage()to skip secondary finish eventsChanged Files
SDKBridge.swift— Core in-process agent backend (361 lines)BackendBridge.swift— Protocol + shared bridge typesAppState+Bridge.swift— Bridge orchestration and configuration wiringAdvancedSettingsView.swift— MCP server configuration UIConfigManager+SkillsConfig.swift— Skill directory config supportOpenCodeEvent.swift— Fix for duplicate finish eventsTest Plan
MotiveTestssuite🤖 Generated with Claude Code