-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Merge upstream PR #6478 - parallel subtasks and model fixes #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The variant field was accidentally removed during a cherry-pick that fixed plugin commands. This restores variant support in PromptInput, CommandInput, and the corresponding message/command handlers.
Move CORS origin validation to cors.ts for better testability and add support for *.shuv.ai domain alongside *.opencode.ai.
…nvironments - Persist active server selection across sessions (server.v4 storage) - Add WelcomeScreen for hosted environments when server connection fails - Add connection state machine (connecting/ready/needs_config/error) - Add hosted environment detection utilities
- Add REVIEW_PANE constants for centralized width configuration - Enforce max review pane width ratio (33% of viewport) - Handle window resize to maintain width constraints - Add empty state UI when no files to review
- Move Theme/Font pickers before Review and Terminal toggles - Add clarifying comments for button groups
…ce, command.execute.before hook Merges changes from sst#6478: - Add parallel subtask execution via Promise.all() - Fix model inheritance for subtasks with parent context restoration - Add command.execute.before plugin hook for pre-execution logic - Improve model resolution with proper fallback chain: command frontmatter > agent model > session model > default model - Extend SubtaskPart schema with model, parentAgent, parentModel fields - Update task tool to use ctx.extra.model for model override Closes #225
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
16 files reviewed, 1 comment
| messageID: input.processor.message.id, | ||
| callID: options.toolCallId, | ||
| extra: { model: input.model }, | ||
| extra: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: check that tools still work correctly - extra changed from { model: input.model } to empty object {}
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/opencode/src/session/prompt.ts
Line: 622:622
Comment:
**style:** check that tools still work correctly - `extra` changed from `{ model: input.model }` to empty object `{}`
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is volontary, no value should be forced into extra at this stage, fallbacks resolve properly.
feeding model: input.model will override agent's configured model on any main session use of the task tool (eg, main session uses sonnet, calls an 'explore' agent configured with haiku -> we want haiku for that task tool. With model: input.model we would get the main session (sonnet) as the explore subagent's model.
Summary
command.execute.beforeplugin hook for pre-execution logicChanges
SubtaskPart Schema Extension (
message-v2.ts)model,parentAgent,parentModelfields to track parent contextParallel Subtask Execution (
prompt.ts)Promise.all()command.execute.beforehook trigger before command executionextraparameter inresolveToolsto use empty objectModel Resolution Fix (
task.ts,prompt.ts)lastModel()now returns undefined if no session model foundProvider.defaultModel()New Plugin Hook (
plugin/index.ts)command.execute.beforehook for intercepting command executionSDK Types (
types.gen.ts)Parttype andSubtaskPartInputwith new fieldsTesting
Related
Greptile Summary
This PR merges upstream sst/opencode#6478 which adds parallel subtask execution, model inheritance fixes, and a new plugin hook. It also includes fork-specific improvements for the hosted environment (welcome screen, server persistence, CORS for
*.shuv.ai).Key Changes
Core Subtask Improvements:
Promise.all()instead of sequentiallymodel,parentAgent,parentModelfields toSubtaskPartschema to properly restore session context after subtask completioncommand.execute.beforehook allows plugins to intercept command executionFork-Specific Features:
server.v4)*.shuv.aidomain to allowed originsPotential Concerns
extraparameter change (prompt.ts:622): Changed from{ model: input.model }to empty object{}. The model is now only passed to subtasks viaextra: { model: task.model }. Verify regular tool calls don't rely onctx.extra.modelParallel subtask race conditions: Multiple subtasks creating messages/parts concurrently could potentially create ordering issues if they share state
PR scope: Mixing upstream merge with unrelated UI/CORS changes makes it harder to isolate regressions. Consider splitting into separate PRs in the future
Confidence Score: 4/5
extraparameter change inresolveToolsthat removes model context and needs verification, (2) parallel execution introducing potential race conditions in message creation, and (3) mix of upstream merge with unrelated UI/CORS changes making it harder to isolate issuespackages/opencode/src/session/prompt.tsfor theextra: {}change and parallel subtask execution logicImportant Files Changed
Sequence Diagram
sequenceDiagram participant User participant Session participant Plugin participant Prompt participant TaskTool participant Subtask1 participant Subtask2 User->>Session: Send message with command Session->>Prompt: Process command Prompt->>Plugin: Trigger command.execute.before hook Plugin-->>Prompt: Hook complete Note over Prompt: Filter subtasks from other tasks Prompt->>Prompt: subtasks = tasks.filter(type === "subtask") Prompt->>Prompt: Store parent context (agent, model) Note over Prompt,Subtask2: Execute all subtasks in parallel via Promise.all() par Parallel Execution Prompt->>TaskTool: executeSubtask(task1) TaskTool->>Subtask1: Execute with task1.model Subtask1-->>TaskTool: Result TaskTool-->>Prompt: Complete and Prompt->>TaskTool: executeSubtask(task2) TaskTool->>Subtask2: Execute with task2.model Subtask2-->>TaskTool: Result TaskTool-->>Prompt: Complete end Note over Prompt: All subtasks complete Prompt->>Prompt: Restore parent context Prompt->>Session: Create synthetic user message Note over Session: agent = parentAgent ?? lastUser.agent<br/>model = parentModel ?? lastUser.model Session-->>User: Continue with restored context