Skip to content

feat(mothership): mixture of models, search agent, persistent subagents, fork chat, inline questions (mothership v0.8)#5410

Merged
Sg312 merged 61 commits into
stagingfrom
dev
Jul 16, 2026
Merged

feat(mothership): mixture of models, search agent, persistent subagents, fork chat, inline questions (mothership v0.8)#5410
Sg312 merged 61 commits into
stagingfrom
dev

Conversation

@Sg312

@Sg312 Sg312 commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Type of Change

  • New feature

Testing

Manual

Checklist

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

@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Error Error Jul 16, 2026 6:01pm

Request Review

@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces three new read-only copilot tools (run_code, search_knowledge_base, query_user_table) and replaces the research subagent with a search subagent, wiring up all the catalog entries, runtime schemas, server-side handlers, UI display strings, and icon mappings. It also fixes a bug in getToolCallTerminalData where a failed tool call returning an empty-but-defined output ({}) was silently hiding its error from the model.

  • New read-only tools: run_code delegates to executeFunctionExecute after stripping write vectors (outputs, outputTable); search_knowledge_base and query_user_table wrap their mutable counterparts behind operation allowlists, with query_user_table adding an extra outputPath guard.
  • researchsearch: The Research subagent catalog entry and schema are removed; Search replaces it with a task-based parameter; display labels are updated throughout while the old research key is kept in TOOL_TITLES for backward compatibility with existing tool-call history.
  • tool-call-state bugfix: Failed calls that carry a non-null output now have the error merged into the returned terminal data so the model sees the failure reason on resume rather than a bare {}.

Confidence Score: 4/5

Safe to merge with the args nullability issue resolved — all other changes are additive registrations and a well-contained bug fix.

The core logic (read-only guards, tool registration, schema sync, bug fix in terminal data) is sound and well-commented. One concern is the args field typed as optional in both SearchKnowledgeBaseArgs and QueryUserTableArgs while the catalog schemas list args in required — if the model omits it, the handler forwards undefined into the underlying tool, where property accesses on args would throw at runtime.

apps/sim/lib/copilot/tools/server/knowledge/search-knowledge-base.ts and apps/sim/lib/copilot/tools/server/table/query-user-table.ts — both type args as optional at the TypeScript level while the JSON schema marks it required.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/server/knowledge/search-knowledge-base.ts New read-only wrapper for knowledge_base; enforces operation allowlist but types args as optional while schema marks it required — downstream access on undefined args could throw.
apps/sim/lib/copilot/tools/server/table/query-user-table.ts New read-only wrapper for user_table with operation + outputPath guards; contains a redundant second outputPath check at the top-level params scope that cannot be reached given the typed schema.
apps/sim/lib/copilot/tools/handlers/run-code.ts New compute-only variant of function_execute; correctly strips output write vectors before delegating, with defense-in-depth noted in the catalog capabilities.
apps/sim/lib/copilot/request/tool-call-state.ts Bug fix ensuring failed tool calls always surface their error in terminal data even when a non-empty (but empty-object) output is present; logic and edge-case handling look correct.
apps/sim/lib/copilot/generated/tool-catalog-v1.ts Adds QueryUserTable, RunCode, Search, and SearchKnowledgeBase catalog entries; removes Research and replaces with Search subagent; all catalog entries and type unions are consistently updated.
apps/sim/lib/copilot/generated/tool-schemas-v1.ts Runtime schemas kept in sync with catalog additions; research schema removed, new schemas for query_user_table, run_code, search, search_knowledge_base are consistent with catalog definitions.
apps/sim/lib/copilot/tools/server/router.ts Both new server tool instances correctly registered in the server tool registry.
apps/sim/lib/copilot/tool-executor/register-handlers.ts executeRunCode handler properly imported and registered alongside RunCode catalog id.
apps/sim/lib/copilot/request/tools/executor.ts Research replaced by Search in LONG_RUNNING_TOOL_IDS; RunCode added alongside FunctionExecute.
apps/sim/app/workspace/[workspaceId]/home/components/message-content/utils.ts TOOL_ICONS updated to include run_code, search_knowledge_base, query_user_table, scout, and search icons; additions are complete and consistent.
apps/sim/app/workspace/[workspaceId]/home/types.ts SUBAGENT_LABELS extended with scout and search entries to match the new catalog subagent IDs.
apps/docs/components/workflow-preview/format-references.tsx Removes now-unnecessary biome-ignore comments for noArrayIndexKey — the root biome.json has this rule set to off globally, so the suppressions were already no-ops.
apps/sim/lib/copilot/tools/tool-display.ts TOOL_TITLES extended with run_code, query_user_table, search_knowledge_base, scout, and search display strings; consistent with catalog additions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Copilot Model Request] --> B{Tool Route}

    B -->|run_code| C[executeRunCode]
    C --> D{outputs / outputTable in params?}
    D -->|Yes| E[Return error: compute-only]
    D -->|No| F[executeFunctionExecute sandbox execution]

    B -->|search_knowledge_base| G[searchKnowledgeBaseServerTool]
    G --> H{operation in READ_OPERATIONS?}
    H -->|No| I[Return error: read-only]
    H -->|Yes| J[knowledgeBaseServerTool.execute]

    B -->|query_user_table| K[queryUserTableServerTool]
    K --> L{operation in READ_OPERATIONS?}
    L -->|No| M[Return error: read-only]
    L -->|Yes| N{outputPath present?}
    N -->|Yes| O[Return error: read-only]
    N -->|No| P[userTableServerTool.execute]

    B -->|search subagent| Q[Search Subagent replaces Research]

    F & J & P & Q --> R[Tool Result]
    R --> S[getToolCallTerminalData]
    S --> T{failed AND output defined?}
    T -->|Yes| U[Merge error into output for model context]
    T -->|No| V[Return output or error as-is]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Copilot Model Request] --> B{Tool Route}

    B -->|run_code| C[executeRunCode]
    C --> D{outputs / outputTable in params?}
    D -->|Yes| E[Return error: compute-only]
    D -->|No| F[executeFunctionExecute sandbox execution]

    B -->|search_knowledge_base| G[searchKnowledgeBaseServerTool]
    G --> H{operation in READ_OPERATIONS?}
    H -->|No| I[Return error: read-only]
    H -->|Yes| J[knowledgeBaseServerTool.execute]

    B -->|query_user_table| K[queryUserTableServerTool]
    K --> L{operation in READ_OPERATIONS?}
    L -->|No| M[Return error: read-only]
    L -->|Yes| N{outputPath present?}
    N -->|Yes| O[Return error: read-only]
    N -->|No| P[userTableServerTool.execute]

    B -->|search subagent| Q[Search Subagent replaces Research]

    F & J & P & Q --> R[Tool Result]
    R --> S[getToolCallTerminalData]
    S --> T{failed AND output defined?}
    T -->|Yes| U[Merge error into output for model context]
    T -->|No| V[Return output or error as-is]
Loading

Reviews (1): Last reviewed commit: "fix(copilot): failed tool calls must sur..." | Re-trigger Greptile

Comment thread apps/sim/lib/copilot/tools/server/table/query-user-table.ts
@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
OAuth reconnect and pending-draft upsert logic touch credential binding and authorization; fork performs quota-gated storage copies and reference rewrites that can leave partial failures if blobs fail.

Overview
Large feature batch across auth, copilot chat, and code execution.

OAuth2 authorize now supports optional credentialId for reconnect: admin checks, provider/workspace/type validation, Trello/Shopify blocked, and pending drafts that carry credentialId (plain connect explicitly nulls it on upsert). Connect drafts use shared defaultCredentialDisplayName with collision numbering against existing workspace OAuth credentials; reconnect drafts reuse the credential’s display name.

Mothership chat fork copies uploads born at or before the fork point: storage quota gate, physical blob copies with new ids/keys, transcript and resource reference rewrites, ghost resource cleanup, failed-copy row deletion + failedFileCopies in the response, and copilot-service fork cut aligned to the last kept user message.

<question> special tags add interactive single/multi-select cards (with recap pairing that hides the duplicate user bubble), plus parsing/streaming support. Thinking blocks are omitted from chat rendering; Branch in new chat fork is enabled for persisted assistant messages only.

Function execute returns 422 when sandbox mounts/exports are requested without E2B; overwrite exports get byte-compare unchanged warnings, size/sha256 receipts, and a leading newline on E2B result markers. Streamed workflow remove events evict workflows from the active React Query cache.

Smaller changes: credential reconnect link labels, sim_key placeholder handling, parseJsonArrayValue for KB sub-blocks, mothership execute drops user-skill tool wiring, minimal dev registry adds Slack/Gmail, docs drops biome array-index-key ignores.

Reviewed by Cursor Bugbot for commit 07af501. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread apps/sim/app/api/mothership/chats/[chatId]/fork/route.ts Outdated
Sg312 and others added 26 commits July 16, 2026 10:49
Preserve the product invariant that Mothership chat files are not charged as workspace file storage after the billing storage merge.
…ed so the between-steps thinking indicator isn't suppressed
@github-actions

Copy link
Copy Markdown

⚠️ Cross-repo companion check

One or more companion PRs aren't merged into staging yet. Merging this without them will leave copilot and sim out of sync — merge them in lockstep.

  • simstudioai/mothership#343 — couldn't read (401); check CROSS_REPO_TOKEN scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants