Skip to content

fix: avoid TS2590 in Agent model options - #414

Merged
robelest merged 4 commits into
convex:mainfrom
eliotgevers:fix/agent-model-options-ts2590
Oct 20, 2026
Merged

robelest merged 4 commits into
convex:mainfrom
eliotgevers:fix/agent-model-options-ts2590

Conversation

@eliotgevers

@eliotgevers eliotgevers commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Valid Agent and startGeneration configurations fail with TS2590 when used with the current AI SDK model catalog. Define a named AgentOptions interface extending Config, require its existing model type, and remove the redundant model declaration from standalone generation options. This avoids overlapping model unions and duplicate generated option declarations without changing runtime behavior.

I also considered removing Agent's extra model restrictions and relying entirely on AI SDK's compatibility handling. This change preserves the existing tested model policy; broadening it can be considered separately.

Fixes #413.

Validation:

  • Package build, lint, and typecheck, including examples.
  • Existing suite: 39 test files / 481 tests passed.
  • Standalone published-package reproduction fails before and passes after on TypeScript 6.0.3 and 7.0.2, also with 10,000 registered model IDs.
  • Type-erased JavaScript is unchanged.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T00:27:46.919123Z 03921f5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: convex/coderabbit/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ec281cc6-b5ef-4d1d-ad08-4e3136d83608
📥 Commits

Reviewing files that changed from the base of the PR and between 45eb057 and 5b4bf25.

📒 Files selected for processing: 4
  • src/vercel/client/start.ts
  • src/vercel/client/types.test.ts
  • src/vercel/client/types.ts
  • src/vercel/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The changes add the exported AgentLanguageModel and WithoutModel types. The Agent constructor now accepts the exported AgentOptions interface. Agent.start and startGeneration omit generic model fields before adding the agent model type. startGeneration no longer accepts the languageModel option. Type-level tests verify discriminated argument narrowing. The changelog records the TS2590 fix.

Suggested reviewers: robelest

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 5b4bf

The reviewed changes are mergeable with no identified current-head risk.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Linked Issues check Warning Issue #413 requires valid Agent and startGeneration configurations to typecheck without TS2590. AgentOptions extends Config and requires Config["languageModel"]. The startGeneration return… Remove model?: AgentLanguageModel from the input intersection in startGeneration. Preserve the required model in the returned WithoutModel<T> & { model: AgentLanguageModel } type and the existing model policy. Add a compile-time regre…
Passed Passed checks: 3 passed
Check name Status Explanation
Description check Passed The description directly explains the TS2590 fix, the affected Agent and startGeneration configurations, the preserved model policy, and the validation results.
Title check Passed The title is concise and clearly identifies the primary change: avoiding TS2590 in Agent model options.
Out of Scope Changes check Passed The changes define AgentOptions, consolidate the agent model type, update Agent and startGeneration declarations, and add supporting type tests and changelog text. These changes support the TS25…
Full details: Out of Scope Changes check

Explanation

The changes define AgentOptions, consolidate the agent model type, update Agent and startGeneration declarations, and add supporting type tests and changelog text. These changes support the TS2590 and model-compatibility objective in issue #413. No unrelated runtime feature or unrelated API change is established.

Full details: Linked Issues check

Explanation

Issue #413 requires valid Agent and startGeneration configurations to typecheck without TS2590. AgentOptions extends Config and requires Config["languageModel"]. The startGeneration return type uses WithoutModel&lt;T&gt; and requires AgentLanguageModel. However, the input type still declares model?: AgentLanguageModel in T &amp; { ... }. A caller-provided model remains intersected with this declaration, so the redundant model overlap is not removed. The current type test covers discriminated return types but does not cover the reported Agent and standalone startGeneration configurations.

Resolution

Remove model?: AgentLanguageModel from the input intersection in startGeneration. Preserve the required model in the returned WithoutModel&lt;T&gt; &amp; { model: AgentLanguageModel } type and the existing model policy. Add a compile-time regression test for the issue #413 Agent and standalone startGeneration configurations with the current AI SDK model type.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/vercel/client/start.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/vercel/client/types.test.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

src/vercel/client/types.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

  • 1 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 4 files

Re-trigger cubic

@robelest

Copy link
Copy Markdown
Collaborator

Pushed a commit on top: our own source still intersected our model type with the AI SDK's (streamText.ts), so our build hits TS2590 with ai@7.0.143. It now uses one model type throughout.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread src/vercel/client/start.ts Outdated
@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/agent@414

commit: 5b4bf25

@robelest
robelest merged commit a6c78f7 into convex:main Oct 20, 2026
4 checks passed
@eliotgevers
eliotgevers deleted the fix/agent-model-options-ts2590 branch October 20, 2026 09:28
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.

TS2590 when constructing Agent with current AI SDK model types

2 participants