Skip to content

improvement(mothership): agent model dropdown validations, markers for recommended models#4213

Open
icecrasher321 wants to merge 7 commits intostagingfrom
improvement/agent-dropdown-model
Open

improvement(mothership): agent model dropdown validations, markers for recommended models#4213
icecrasher321 wants to merge 7 commits intostagingfrom
improvement/agent-dropdown-model

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

  • Mark recommended + speedOptimized models
  • Add deterministic validation error for invalid model ids (correctly handles dynamic models like ollama, etc)

Type of Change

  • Other: Context Improvement

Testing

Tested manually

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 17, 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 17, 2026 6:06pm

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 17, 2026

PR Summary

Medium Risk
Changes server-side workflow validation for model inputs and may newly reject previously accepted unprefixed or mistyped model ids, impacting edits/automation that relied on lax validation. Scope is constrained to subblocks wired to getModelOptions, with tests covering common edge cases.

Overview
Tightens workflow input validation for model fields that use the provider catalog (getModelOptions): values are trimmed, unknown static model ids are rejected with a deterministic, more actionable error, and user-configured models must use a provider prefix (e.g. ollama/...).

Extends model metadata and VFS block-schema serialization to include recommended/speedOptimized/deprecated markers for static models, plus a note + allowed prefixes for dynamic providers; adds helper utilities in providers/models (DYNAMIC_MODEL_PROVIDERS, isKnownModelId, suggestions) and broadens tests to cover the new validation behavior (agent/router vs non-catalog model fields).

Reviewed by Cursor Bugbot for commit df3b2ff. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 17, 2026

Greptile Summary

This PR adds recommended, speedOptimized, and deprecated tier flags to ModelDefinition, marks selected models accordingly, and introduces a deterministic model-ID validation step in the copilot's validateValueForSubBlockType. The validation rejects hallucinated static-provider IDs (e.g. claude-sonnet-4.6) while allowing dynamic-provider prefixes (ollama/, fireworks/, etc.) and unrecognized bare IDs (local Ollama tags). The VFS serializer is extended to propagate tier flags — including inheritance for reseller providers — and a dynamicProviders note is added to block schemas to help the AI handle non-catalog IDs correctly.

Confidence Score: 4/5

Safe to merge; the two findings are P2 design observations that don't affect correctness of the primary validation path.

The core validation logic is correct and well-tested. The startsWith(base+"-") permissiveness is an intentional tradeoff for date-suffixed variants and doesn't break the primary hallucination-detection use case. The duplicate dynamic-provider list is a maintenance risk but not a current defect. Scoring 4 rather than 5 because the suffix-matching gap could admit hallucinated IDs that look like -, which marginally weakens the stated goal of catching bad model IDs.

apps/sim/providers/models.ts (isKnownModelId suffix check) and apps/sim/lib/copilot/vfs/serializers.ts (DYNAMIC_PROVIDERS_NOTE sync)

Important Files Changed

Filename Overview
apps/sim/providers/models.ts Adds recommended/speedOptimized/deprecated flags to ModelDefinition and selected models; introduces isKnownModelId, getRecommendedModels, and suggestModelIdsForUnknownModel — the startsWith(base+"-") fallback is intentionally permissive but accepts any suffix after a known ID.
apps/sim/lib/copilot/tools/server/workflow/edit-workflow/validation.ts Wires model-ID validation into validateValueForSubBlockType using a function-reference equality check against getModelOptions; logic is sound but returns the trimmed value for the catalog path regardless of whether the original was trimmed.
apps/sim/lib/copilot/vfs/serializers.ts Enriches VFS block schema with tier flags (recommended/speedOptimized/deprecated) and inherits them for reseller providers via RESELLER_BASE_PREFIX; DYNAMIC_PROVIDERS_NOTE prefixes list is manually maintained separately from the canonical DYNAMIC_MODEL_PROVIDERS in models.ts.
apps/sim/lib/copilot/tools/server/workflow/edit-workflow/validation.test.ts Good test coverage added for the new model validation path, including catalog matches, hallucinated IDs, empty values, dynamic prefixes, date-suffixed variants, and whitespace trimming; follows project vi.hoisted + vi.mock pattern correctly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[validateValueForSubBlockType\nfield='model', type='combobox'] --> B{subBlockConfig.options\n=== getModelOptions?}
    B -- No --> C[Return value as-is\nnon-catalog path]
    B -- Yes --> D{trimmed === ''}
    D -- Yes --> E[Return empty string\nvalid: true]
    D -- No --> F[isKnownModelId\ntrimmed]
    F --> G{Exact catalog match\nor startsWith base+'-'?}
    G -- Yes --> H[valid: true\nreturn trimmed]
    G -- No --> I{Dynamic provider\nprefix? ollama/ vllm/ etc.}
    I -- Yes --> H
    I -- No --> J{Matches static\nprovider modelPattern?}
    J -- Yes --> K[valid: false\nUnknown model id error\n+ suggestions]
    J -- No --> L[valid: true\nunrecognized bare id\ne.g. local Ollama tag]
Loading

Reviews (1): Last reviewed commit: "mark a few more models:" | Re-trigger Greptile

Comment thread apps/sim/providers/models.ts Outdated
Comment thread apps/sim/lib/copilot/vfs/serializers.ts
Comment thread apps/sim/providers/models.ts Outdated
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/providers/models.ts
Comment thread apps/sim/lib/copilot/vfs/serializers.ts
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/providers/models.ts
Comment thread apps/sim/lib/copilot/vfs/serializers.ts Outdated
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/lib/copilot/tools/server/workflow/edit-workflow/validation.ts Outdated
Comment thread apps/sim/providers/models.ts
@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit df3b2ff. Configure here.

? value
: typeof value === 'number'
? String(value)
: String(value)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant ternary branches produce identical results

Low Severity

The ternary for computing stringValue has two branches (typeof value === 'number' and the default) that both evaluate to String(value). This makes it look like numbers are handled differently when they aren't, which could mislead future developers into thinking there's a meaningful distinction. The entire expression after the first string check collapses to just String(value).

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit df3b2ff. Configure here.

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