') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); feat(runtime): add Qwen3.8-Max native WebSearch by MoonOld · Pull Request #3685 · apache/maka · GitHub
Skip to content

feat(runtime): add Qwen3.8-Max native WebSearch - #3685

Draft
MoonOld wants to merge 4 commits into
apache:mainfrom
MoonOld:feat/alibaba-native-websearch
Draft

feat(runtime): add Qwen3.8-Max native WebSearch#3685
MoonOld wants to merge 4 commits into
apache:mainfrom
MoonOld:feat/alibaba-native-websearch

Conversation

@MoonOld

@MoonOldMoonOld commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the first Alibaba Harness-tool slice from #3163: provider-native WebSearch for qwen3.8-max on the Alibaba Token Plan China and international access paths.

  • keeps capability routing fail-closed and exact-model scoped; Qwen 3.7 remains disabled because Maka still routes it through Chat;
  • lowers the canonical Maka WebSearch descriptor to the documented Responses tools: [{ type: "web_search" }] request shape;
  • decodes streamed web_search_call items into provider-executed call/result events, preserving search, open_page, and find_in_page actions, generated queries, source URLs, and usage.x_tools;
  • reuses the existing Runtime projection for durable events, UI/export, privacy-mode removal, and tool ceilings;
  • keeps the current replay boundary explicit: the durable search episode and grounded answer survive, while the provider-owned call/result pair is omitted from the next request rather than creating a dangling function output.

Refs #3163

This PR intentionally does not close#3163. web_extractor, code interpreter, image-search tools, and broader Qwen 3.7 Responses routing remain follow-up slices.

Upstream dependency and patch retirement

The generic @ai-sdk/open-responses@2.0.34 adapter drops provider-defined tools and does not decode bare web_search_call items. This Draft carries a narrow dependency patch for current verification only.

The missing public seam is tracked upstream:

AI SDK 2.0.35 introduced explicit extension codecs, but they accept only normative namespaced wire types. #19939 adds an explicit fail-closed bare extension codec for documented implementation types such as web_search and web_search_call; its CI is green and it is awaiting upstream review.

Retirement rule: once that API is merged and released, replace this patch with a package-local Experimental_OpenResponsesBareExtension, prove request/stream/replay behavior against the unpatched package, and delete patches/@ai-sdk+open-responses+*.patch plus its LICENSE/patch README entries.

Verification

Exact head 3ae89609a, rebased directly onto main at bd951aa88:

  • fresh npm ci applies @ai-sdk/open-responses@2.0.34 cleanly and reports 0 vulnerabilities;
  • full workspace build:test and workspace typecheck passed;
  • npm run format:check, npm run lint, npm run check:asf-headers, and git diff --check passed;
  • focused capability, request, stream, action, reasoning, durable Tool Result, and backend set: 269 passed, 0 failed;
  • Runtime full suite: 3,097 passed, 13 skipped, 0 failed;
  • release contracts: 141 passed, 0 failed;
  • the official Alibaba reasoning-summary fixture still crosses the patched 2.0.34 package, confirming the WebSearch patch does not regress feat(providers): add Alibaba Token Plan Responses compatibility #3255's upstream reasoning mapping.

Live Token Plan evidence

A protected live smoke on the exact rebased tree used production AiSdkBackend + ModelAdapter + getAIModel, the configured Token Plan China connection, and qwen3.8-max. The credential was read only in process and was never printed, placed in command arguments, persisted, or attached.

  • request 1: HTTP 200, store:false, exactly one web_search tool descriptor, one provider-executed call/result pair, and a grounded final answer ending in the requested sentinel;
  • a companion probe on the immediately preceding main base observed two completed search actions carrying 39 source rows;
  • request 2: HTTP 200, store:false, completed from durable prior context with the requested replay sentinel;
  • no web_search_call item was replayed in request 2, preserving the explicit fail-closed adapter boundary;
  • both model turns completed with end_turn; no local Tavily or ToolRuntime WebSearch implementation ran.

Provider documentation:

Review focus

  • The product routing change is limited to both Alibaba Token Plan provider types and exact model ID qwen3.8-max.
  • Unknown provider tools and item types remain unsupported.
  • The patch is temporary, version-pinned, source-release-accounted, and bound to upstream #19933/#19939.
  • Durable reasoning, ordinary function tools, DeepSeek's existing disabled native-search route, and main's durable Tool Result projection remain covered and unchanged.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

OpenAI Codex assisted with protocol research, implementation, tests, upstream coordination, live verification, and PR drafting. The human contributor reviewed the scope and remains responsible for the contribution. The commits carry Generated-by: OpenAI Codex trailers.

Checklist

  • Tests cover the current compatibility behavior
  • Lint, format, typecheck, build, release, and affected suites pass locally
  • Exact-tree live WebSearch and next-turn replay evidence is recorded
  • Replace the dependency patch with the released upstream bare-extension codec before marking ready for review

Does this PR entail a change in behavior?

  • Yes — described under Summary
  • No

@MoonOld

Copy link
Copy Markdown
ContributorAuthor

Live Token Plan WebSearch smoke passed on exact feature head 46e452d32 (2026-08-24).

Execution path: the PR branch production getAIModel + ModelAdapter, configured Alibaba Token Plan China connection, exact model qwen3.8-max, and the canonical provider WebSearch descriptor. The credential was read only in process from the local credential vault and was never printed.

Observed result:

  • outcome: completed; finish reason: stop;
  • two WebSearch calls, both marked providerExecuted: true;
  • provider results included the official Qwen3.8-Max model page and Alibaba Model Studio Web Search documentation;
  • final grounded answer correctly reported that Qwen3.8-Max supports Web Search and named the official source URLs;
  • usage: 9,386 input / 866 output / 532 reasoning / 10,252 total tokens;
  • no local ToolRuntime WebSearch execution occurred.

Representative returned sources:

The temporary smoke runner was removed after the run and retained no credential material.

@MoonOld

Copy link
Copy Markdown
ContributorAuthor

Additional live boundary probe on exact head 46e452d32: the local DEEPSEEK_API_KEY was read in process from /Users/moonold/.env without printing or persisting it, and a forced provider descriptor was sent through the production getAIModel + ModelAdapter path to first-party https://api.deepseek.com/responses with deepseek-v4-flash.

Observed:

  • outbound tools: [{ "type": "web_search" }];
  • outcome: completed, finish reason stop;
  • six provider-executed WebSearch calls;
  • raw provider action types: search, open_page, and find_in_page;
  • the model completed a grounded final answer;
  • usage: 14,514 input / 1,497 output / 810 reasoning / 16,011 total tokens.

This proves the dependency patch fixes the common Open Responses request/stream transport for DeepSeek as well, but it does not make DeepSeek production-ready yet:

  1. resolveHostedWebSearchCapability(deepseek, ...) still returns implemented:false, so normal Maka routing never advertises the tool.
  2. The current narrow mapper is correct for Alibaba search + sources, but it rewrites DeepSeek open_page and find_in_page actions as empty search actions, losing their URL/pattern in the normalized tool result.

Therefore DeepSeek should stay disabled until the action union and tests cover all three shapes and a normal routed smoke passes. The temporary probe runner was removed and retained no credential material.

@MoonOld

Copy link
Copy Markdown
ContributorAuthor

Shared mapper follow-up pushed in 3a74825a9: Open Responses WebSearch now preserves search, open_page → openPage, and find_in_page → findInPage instead of collapsing every provider action to search. A deterministic raw-SSE contract test pins all three shapes.

DeepSeek capability enablement remains out of this Alibaba PR and is isolated in #3694 / #3689.

Route Qwen3.8 Max Token Plan sessions to provider-executed Responses web search, and extend the pinned open-responses adapter with the published web_search request and web_search_call stream shapes.
Generated-by: OpenAI Codex
Map search, open_page, and find_in_page into the canonical provider-executed WebSearch output instead of collapsing every hosted action to search.
Generated-by: OpenAI Codex
Regenerate the temporary WebSearch compatibility patch against 2.0.34 while preserving the upstream reasoning-summary mapping. Retirement is tracked by vercel/ai#19933 and #19939.
Generated-by: OpenAI Codex
Account for the temporary Apache-2.0 WebSearch compatibility patch in the source release inventory.
Generated-by: OpenAI Codex
@MoonOld
MoonOldforce-pushed the feat/alibaba-native-websearch branch from 3a74825 to 3ae8960CompareAugust 31, 2026 10:06
@MoonOld

Copy link
Copy Markdown
ContributorAuthor

#3685 has been rebuilt after #3255 merged and is now on exact head 3ae89609a, directly based on current mainbd951aa88.

Key changes:

Exact-head verification is green: fresh npm ci, build, workspace typecheck, format/lint/ASF headers, 269 focused cross-surface tests, Runtime 3,097 passed / 13 skipped / 0 failed, and release 141/141.

The Token Plan China live smoke also passed on the rebased tree: qwen3.8-max received exactly one native web_search descriptor, emitted a provider-executed WebSearch pair, completed a grounded answer, and completed a second durable-context turn without replaying a dangling web_search_call item.

This remains Draft while #19939 is awaiting upstream review. Once its bare-extension codec is published, the dependency patch and legal/README entries should be deleted before this PR is marked ready.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(runtime): map Alibaba Token Plan native Harness tools into Maka

1 participant

@MoonOld