Skip to content

fix(mothership): fix intelligence regression#4171

Merged
Sg312 merged 1 commit intostagingfrom
fix/mothership-intelligence
Apr 15, 2026
Merged

fix(mothership): fix intelligence regression#4171
Sg312 merged 1 commit intostagingfrom
fix/mothership-intelligence

Conversation

@Sg312
Copy link
Copy Markdown
Collaborator

@Sg312 Sg312 commented Apr 15, 2026

Summary

Fix mothership intelligence regression

Type of Change

  • Bug fix

Testing

Manual

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 15, 2026 2:57am

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 15, 2026

Greptile Summary

This PR fixes a Mothership intelligence regression by correcting sim_test's subagent routing from 'test' to 'run', and enriches both the build tool call path and the subagent orchestrator with workflow name, workspace ID, and workspace context so the Go-side agents have full context on every request. A duplicate sim_workflow MCP tool definition is also removed, and new Debug/Run catalog entries are wired into the UI.

Confidence Score: 5/5

Safe to merge — all remaining findings are P2 style improvements with no correctness impact.

The core regression fix (sim_test agentId + context propagation) is straightforward and well-guarded with try/catch. No data loss, auth bypasses, or broken contracts identified. Only two P2 suggestions remain: a minor redundant DB fetch opportunity and an import consistency nit.

apps/sim/lib/copilot/request/subagent.ts — minor double-fetch on getWorkflowById worth cleaning up.

Important Files Changed

Filename Overview
apps/sim/app/api/mcp/copilot/route.ts handleBuildToolCall now resolves workflow name, workspace ID, and workspace context before invoking runHeadlessCopilotLifecycle; duplicate sim_workflow MCP tool removed; logic and types look correct.
apps/sim/lib/copilot/request/subagent.ts Now propagates chatId, workflowName, workspaceId, workspaceContext, and isHosted to the Go subagent; minor double-fetch opportunity for workflowById when execContext.workspaceId is already available.
apps/sim/lib/copilot/tools/mcp/definitions.ts sim_test agentId corrected from 'test' to 'run'; duplicate sim_workflow definition removed; sim_workflow and sim_info descriptions updated.
apps/sim/lib/copilot/generated/tool-catalog-v1.ts Added Debug and Run catalog entries; updated Read path description; changes match tool-schemas-v1 additions.
apps/sim/app/workspace/[workspaceId]/home/types.ts Adds Debug import, 'debug' subagent label, and Debug.id UI metadata; run still uses local string constant RUN_SUBAGENT_ID rather than Run.id for minor inconsistency.

Sequence Diagram

sequenceDiagram
    participant MCP as MCP Client
    participant Route as /api/mcp/copilot
    participant Build as handleBuildToolCall
    participant Sub as orchestrateSubagentStream
    participant Ctx as generateWorkspaceContext
    participant Go as Go Agent API

    MCP->>Route: sim_workflow(request, workflowId)
    Route->>Build: agentId === 'workflow'
    Build->>Build: authorizeWorkflow → resolvedWorkflowName, resolvedWorkspaceId
    Build->>Ctx: generateWorkspaceContext(workspaceId, userId)
    Ctx-->>Build: workspaceContext string
    Build->>Go: /api/mcp (workflowName, workspaceId, workspaceContext)
    Go-->>Route: streamed result

    MCP->>Route: sim_test(request, workflowId)
    Route->>Sub: agentId = 'run' (was 'test')
    Sub->>Sub: resolve workflowName + workspaceId
    Sub->>Ctx: generateWorkspaceContext(workspaceId, userId)
    Ctx-->>Sub: workspaceContext string
    Sub->>Go: /api/subagent/run (workflowName, workspaceId, workspaceContext, isHosted)
    Go-->>Route: streamed result
Loading

Comments Outside Diff (1)

  1. apps/sim/app/workspace/[workspaceId]/home/types.ts, line 33-34 (link)

    P2 Inconsistent catalog usage for run ID

    Debug is now imported from the tool catalog and used as [Debug.id], but run is still referenced via the local string constant RUN_SUBAGENT_ID = 'run'. Now that Run is exported from tool-catalog-v1, importing it would make the pattern consistent and guard against future ID drift.

    import {
      // existing imports …
      Debug,
      Run,
    } from '@/lib/copilot/generated/tool-catalog-v1'

    Then replace RUN_SUBAGENT_ID usage with Run.id.

Reviews (1): Last reviewed commit: "fix" | Re-trigger Greptile

Comment thread apps/sim/lib/copilot/request/subagent.ts
@Sg312 Sg312 merged commit 29fbad2 into staging Apr 15, 2026
13 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/mothership-intelligence branch April 15, 2026 06:40
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