Skip to content

fix(core): Support streamed reasoning from custom AI endpoints (no-changelog) - #37875

Draft
Ryner01 wants to merge 1 commit into
masterfrom
ins-1301-community-issue-mistral-error-type-validation-failed
Draft

fix(core): Support streamed reasoning from custom AI endpoints (no-changelog)#37875
Ryner01 wants to merge 1 commit into
masterfrom
ins-1301-community-issue-mistral-error-type-validation-failed

Conversation

@Ryner01

@Ryner01 Ryner01 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Route custom OpenAI-compatible endpoints through the compatible provider. This lets Instance AI process streams that contain reasoning and text parts.

How to test

  1. Configure Instance AI with a custom OpenAI-compatible endpoint.
  2. Send a message to a model that streams reasoning and text content.
  3. Confirm that Instance AI returns the response without a validation error.

Related Linear tickets, Github issues, and Community forum posts

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

🤖 PR Summary generated by AI

Review in cubic

@n8n-assistant

n8n-assistant Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

PR review overview

Based on ownership of the 5 changed files in this PR:

Ownership Files owned Share Source code Test files Misc
@n8n-io/ai-assistant 2 40% +15 / -3 +54 / -4 +0 / -0
@n8n-io/ai 1 20% +0 / -0 +74 / -0 +0 / -0
@n8n-io/catalysts 2 40% +1 / -1 +0 / -0 +45 / -4
Total 5 100% +16 / -4 +128 / -4 +45 / -4

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 5 files

Confidence score: 4/5

  • In packages/@n8n/agents/src/runtime/__tests__/model-factory.test.ts, the Backend regression test bypasses createModel, so it can pass without verifying that custom endpoints reach the compatible provider; update it to exercise createModel and assert the resulting routing.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/@n8n/agents/src/runtime/__tests__/model-factory.test.ts">

<violation number="1" location="packages/@n8n/agents/src/runtime/__tests__/model-factory.test.ts:890">
P2: Custom agent: **Backend**

This regression test bypasses `createModel`, so it does not verify that custom endpoints reach the compatible provider. The test still passes if the n8n registry routes the endpoint through the old provider; exercise `createModel({ id: 'custom/<model>', baseURL, apiKey })` and stream through the returned model.</violation>
</file>

Shadow auto-approve: would not auto-approve because issues were found.

Fix all with cubic | Re-trigger cubic

expectedDeltas: [{ type: 'text-delta', id: 'txt-0', delta: 'The answer is 391.' }],
},
])('$name', async ({ content, expectedDeltas }) => {
const { createOpenAICompatible } = await vi.importActual<

@cubic-dev-ai cubic-dev-ai Bot Sep 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Custom agent: Backend

This regression test bypasses createModel, so it does not verify that custom endpoints reach the compatible provider. The test still passes if the n8n registry routes the endpoint through the old provider; exercise createModel({ id: 'custom/<model>', baseURL, apiKey }) and stream through the returned model.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/@n8n/agents/src/runtime/__tests__/model-factory.test.ts, line 890:

<comment>This regression test bypasses `createModel`, so it does not verify that custom endpoints reach the compatible provider. The test still passes if the n8n registry routes the endpoint through the old provider; exercise `createModel({ id: 'custom/<model>', baseURL, apiKey })` and stream through the returned model.</comment>

<file context>
@@ -864,6 +864,80 @@ describe('createModel', () => {
+			expectedDeltas: [{ type: 'text-delta', id: 'txt-0', delta: 'The answer is 391.' }],
+		},
+	])('$name', async ({ content, expectedDeltas }) => {
+		const { createOpenAICompatible } = await vi.importActual<
+			typeof import('@ai-sdk/openai-compatible')
+		>('@ai-sdk/openai-compatible');
</file context>
Fix with cubic

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...odules/instance-ai/instance-ai-settings.service.ts 85.71% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Instance AI Discovery Eval ✅

Branch: ins-1301-community-issue-mistral-error-type-validation-failed · Commit: 87c512c7a034f93e332b1ac8f9deb99cda3a9cfb

Eval output
$ tsx evaluations/discovery/cli.ts --trials 3 --fail-on-zero-pass
Running 17 discovery scenario(s) × 3 trial(s) (model: anthropic/claude-sonnet-4-6, concurrency: 3).

▸ config-evals-skill-loading ... (node:4860) [DEP0205] DeprecationWarning: `module.register()` is deprecated. Use `module.registerHooks()` instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
✓ 3/3 passed (100%)
▸ data-table-natural-list-skill-loading ... ✓ 3/3 passed (100%)
▸ data-table-skill-loading ... ✓ 3/3 passed (100%)
▸ data-table-workflow-skill-loading ... ✓ 3/3 passed (100%)
▸ google-oauth-credential-setup ... ✓ 3/3 passed (100%)
▸ http-node-config-no-browser ... ✓ 3/3 passed (100%)
▸ mcp-broken-connection-reconnect ... ✓ 3/3 passed (100%)
▸ mcp-connect-unconnected-service ... ✓ 3/3 passed (100%)
▸ mcp-declined-tool-call-no-reconnect ... ✓ 3/3 passed (100%)
▸ mcp-no-registry-match ... ✓ 3/3 passed (100%)
▸ mcp-not-offered-for-workflow-build ... ✓ 3/3 passed (100%)
▸ mcp-uses-connected-server-tools ... ✓ 3/3 passed (100%)
▸ oauth-with-computer-use-disabled ... ✓ 3/3 passed (100%)
▸ screenshot-dashboard ... ✓ 3/3 passed (100%)
▸ slack-oauth-credential-setup ... ✓ 3/3 passed (100%)
▸ workflow-builder-no-agent-builder-leak ... ✓ 3/3 passed (100%)
▸ workflow-builder-no-credential-ask ... ✓ 3/3 passed (100%)

=== Summary ===
Scenarios: 17/17 above threshold (67%)
Trials: 51/51 passed (100%)
Total time: 1545.1s

@n8n-assistant n8n-assistant Bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mistral error "Type validation failed"

1 participant