diff --git a/.agents/notes/implemented/feature/2026-07-31-web-default-search.i18n.yaml b/.agents/notes/implemented/feature/2026-07-31-web-default-search.i18n.yaml index b023332a1e..bc6f790d7c 100644 --- a/.agents/notes/implemented/feature/2026-07-31-web-default-search.i18n.yaml +++ b/.agents/notes/implemented/feature/2026-07-31-web-default-search.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write .agents/notes/implemented/feature/2026-07-31-web-default-search.md -2026-07-31-web-default-search.md: dfd76176aa03741df38f60c6d30116f87ced4106 -2026-07-31-web-default-search.zh.md: 19fe20d7573accbcef45ab4db8c339335e2cc08b +2026-07-31-web-default-search.md: eb0de16b5bf6133bbdb5275106f42eba75ddf607 +2026-07-31-web-default-search.zh.md: e1cc622e70d8af8e71a8c60aa7e7ceb9a2b91a5e diff --git a/.agents/notes/implemented/feature/2026-07-31-web-default-search.md b/.agents/notes/implemented/feature/2026-07-31-web-default-search.md index dfd76176aa..eb0de16b5b 100644 --- a/.agents/notes/implemented/feature/2026-07-31-web-default-search.md +++ b/.agents/notes/implemented/feature/2026-07-31-web-default-search.md @@ -14,7 +14,7 @@ The harness had a complete Web capability family—provider registry, DeepSeek/E DeepSeek search uses the same `DEEPSEEK_API_KEY` credential reference as the official conversation adapter. The provider resolves that reference inside every search through the optional `ctx.credentials` service; only a composition without the seam falls back to the launching process environment, and a non-empty literal `apiKey` remains the programmatic last resort. A stored or rotated Web Models key therefore reaches the next search without restarting or retaining the value on the provider. Because `WebSearchProvider.available()` is synchronous, it treats an installed resolver as locally usable and missing dynamic credentials fail the operation with the provider-specific `WEB_PROVIDER_CREDENTIAL_MISSING` code while the stable tool schema stays registered. -Search keeps its endpoint distinct from chat completions: `DEEPSEEK_SEARCH_BASE_URL` overrides the Anthropic-compatible base, while `DEEPSEEK_BASE_URL` continues to configure conversation requests. Each `web_search` performs an auxiliary DeepSeek Messages call with the native search server tool. Immediately before dispatch, the provider appends a log-only `web/deepseek-search-llm-request` event to the initiating Agent session with the resolved endpoint, API version, and exact secret-free JSON body. Credential preflight remains provider-local and races caller cancellation; neither concern expands the generic Web or credentials seams. +Search keeps its endpoint distinct from chat completions: `DEEPSEEK_SEARCH_BASE_URL` overrides the Anthropic-compatible base, while `DEEPSEEK_BASE_URL` continues to configure conversation requests. Each `web_search` performs an auxiliary DeepSeek Messages call with the native search server tool. Immediately before dispatch, the provider appends a log-only `web/deepseek-search-llm-request` event to the initiating Agent session with the resolved endpoint, API version, and exact secret-free JSON body. A failure after dispatch names that endpoint and tells the conversation model to guide the user to the Web search Endpoint field in Settings when the endpoint is unintended. The message names `DEEPSEEK_SEARCH_BASE_URL` and `web-search-deepseek.baseURL` when that settings page is unavailable; the model does not select or change the credential destination. Credential preflight remains provider-local and races caller cancellation; neither concern expands the generic Web or credentials seams. The default mount does not create a Web-specific permission policy. `web_search` and enabled `web_fetch` calls execute outside the shell/filesystem sandbox and approval presets, following `dsh-tool-web`'s existing contract. The HTTP provider restricts fetches to validated public destinations, but it does not constrain public data egress. The shipped `workspace-write` default governs file mutations only; a restricted-network product stance requires a `tools/pre-execute` policy or capability-specific network confinement rather than implying that filesystem access mode governs Web calls. diff --git a/.agents/notes/implemented/feature/2026-07-31-web-default-search.zh.md b/.agents/notes/implemented/feature/2026-07-31-web-default-search.zh.md index 19fe20d757..e1cc622e70 100644 --- a/.agents/notes/implemented/feature/2026-07-31-web-default-search.zh.md +++ b/.agents/notes/implemented/feature/2026-07-31-web-default-search.zh.md @@ -14,7 +14,7 @@ Status: implemented DeepSeek 搜索使用与官方会话适配器相同的 `DEEPSEEK_API_KEY` 凭据引用。提供方在每次搜索内部通过可选的 `ctx.credentials` 服务解析该引用;只有未挂载该 seam 的组合才会回退到启动进程的环境变量,非空的 `apiKey` 字面值仍作为程序化配置的最后兜底。因此,由 Web 的 Models 页存储或轮换的密钥无需重启即可用于下一次搜索,提供方也无需保留该值。由于 `WebSearchProvider.available()` 是同步方法,它会将已安装解析器视为本地可用;若动态凭据缺失,操作会以提供方专属错误码 `WEB_PROVIDER_CREDENTIAL_MISSING` 失败,而稳定的工具 schema 仍保持注册。 -搜索端点与 chat completions 保持独立:`DEEPSEEK_SEARCH_BASE_URL` 覆盖 Anthropic 兼容基址,`DEEPSEEK_BASE_URL` 则继续配置会话请求。每次 `web_search` 都会发起一次辅助 DeepSeek Messages 调用,并携带原生搜索服务器工具。发出请求前一刻,提供方会向发起请求的 agent(智能体)会话追加仅用于日志的 LLM(大语言模型)请求事件 `web/deepseek-search-llm-request`,其中包含已解析端点、API 版本,以及不含密钥的精确 JSON 请求体。凭据预检仍留在提供方内部,并与调用方取消存在竞态;这两项关注点都不会扩展通用 Web seam 或凭据 seam。 +搜索端点与 chat completions 保持独立:`DEEPSEEK_SEARCH_BASE_URL` 覆盖 Anthropic 兼容基址,`DEEPSEEK_BASE_URL` 则继续配置会话请求。每次 `web_search` 都会发起一次辅助 DeepSeek Messages 调用,并携带原生搜索服务器工具。发出请求前一刻,提供方会向发起请求的 agent(智能体)会话追加仅用于日志的 LLM(大语言模型)请求事件 `web/deepseek-search-llm-request`,其中包含已解析端点、API 版本,以及不含密钥的精确 JSON 请求体。请求发出后的失败会指出该端点;当端点不符合用户预期时,错误消息会要求会话模型指导用户在 Settings 中修改网页搜索的 Endpoint 字段。该设置页面不可用时,消息会说明 `DEEPSEEK_SEARCH_BASE_URL` 和 `web-search-deepseek.baseURL`;模型不得替用户选择或修改凭据发送目的地。凭据预检仍留在提供方内部,并与调用方取消存在竞态;这两项关注点都不会扩展通用 Web seam 或凭据 seam。 默认挂载不会创建 Web 专用权限策略。`web_search` 与已启用的 `web_fetch` 调用会在 bash/文件系统沙箱及审批 preset 之外执行,并遵循 `dsh-tool-web` 的现有约定。HTTP 提供方把抓取限制到已验证的公开目的地址,但不限制公开数据出站。已交付的 `workspace-write` 默认值只管辖文件修改;若产品采取受限网络策略,就需要添加 `tools/pre-execute` 策略或按能力限制网络访问,而不能暗示文件系统访问模式会管辖 Web 调用。 diff --git a/packages/web/web-search-deepseek/README.i18n.yaml b/packages/web/web-search-deepseek/README.i18n.yaml index 4aa1e5e255..bb3879f039 100644 --- a/packages/web/web-search-deepseek/README.i18n.yaml +++ b/packages/web/web-search-deepseek/README.i18n.yaml @@ -2,5 +2,5 @@ # side as of the last confirmed-consistent state. Both languages carry equal authority; # after editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write packages/web/web-search-deepseek/README.md -README.md: dfa7a1d497372c5a42010ca76d1f9d226d296236 -README.zh.md: 7cc3bcf7306c884a5aea9f2d7974227abb25d257 +README.md: a00bdf206acdf09d008b7e3f5604dec087930aed +README.zh.md: 578b3efac3fb1bc4bd85ccd05ca92ec3b3707c26 diff --git a/packages/web/web-search-deepseek/README.md b/packages/web/web-search-deepseek/README.md index dfa7a1d497..a00bdf206a 100644 --- a/packages/web/web-search-deepseek/README.md +++ b/packages/web/web-search-deepseek/README.md @@ -65,7 +65,7 @@ A search running under an initiating agent appends the log-only `web/deepseek-se ### Failures and recovery -Failures throw `WebError` with a machine-routable code: a missing credential is `WEB_PROVIDER_CREDENTIAL_MISSING`, caller cancellation is `WEB_ABORTED`, and provider or transport failures — including a response with no `web_search_tool_result` block — are `WEB_PROVIDER_ERROR`. HTTP redirects are rejected before the `Location` target is contacted. The model-facing `web_search` tool surfaces failure text to the model under its own error wrapper. +Failures throw `WebError` with a machine-routable code: a missing credential is `WEB_PROVIDER_CREDENTIAL_MISSING`, caller cancellation is `WEB_ABORTED`, and provider or transport failures — including a response with no `web_search_tool_result` block — are `WEB_PROVIDER_ERROR`. HTTP redirects are rejected before the `Location` target is contacted. Every failure after dispatch names the resolved search endpoint and explains that search endpoint configuration is separate from chat. If the endpoint is unintended, the message tells the conversation model to guide the user to the Endpoint field under Settings > Plugins > Plugin configuration > Web search and save the change. When that page is unavailable, it names `DEEPSEEK_SEARCH_BASE_URL` and `web-search-deepseek.baseURL` as deployment configuration alternatives. The model must not choose or change the endpoint. The model-facing `web_search` tool surfaces this text under its own error wrapper. ----- @@ -136,7 +136,7 @@ Independent of the conversation request cache. The auxiliary instruction and nat #### What the model sees -Through `dsh-tool-web`, the conversation model sees deduplicated URLs, titles, dates, and citation snippets from structured search blocks; provider prose is not trusted as an answer. This provider's exact failures include the actionable missing-credential message, `DeepSeek search credential resolution failed: `, `DeepSeek search aborted`, `DeepSeek search request failed: `, `DeepSeek returned no web_search_tool_result blocks; the request may not have triggered native web search`, and `DeepSeek returned an unprocessable response body: `; HTTP failures preserve the provider message. The consumer owns the error wrapper. +Through `dsh-tool-web`, the conversation model sees deduplicated URLs, titles, dates, and citation snippets from structured search blocks; provider prose is not trusted as an answer. This provider's exact failures include the actionable missing-credential message, `DeepSeek search credential resolution failed: `, and `DeepSeek search aborted`. Request, HTTP, native-search, and response-body failures append the resolved endpoint and the conditional configuration instruction described above. The consumer owns the error wrapper. #### Token effect diff --git a/packages/web/web-search-deepseek/README.zh.md b/packages/web/web-search-deepseek/README.zh.md index 7cc3bcf730..578b3efac3 100644 --- a/packages/web/web-search-deepseek/README.zh.md +++ b/packages/web/web-search-deepseek/README.zh.md @@ -65,7 +65,7 @@ kind: "package-reference" ### 失败与恢复 -失败抛出携带可按机器路由 code 的 `WebError`:凭据缺失为 `WEB_PROVIDER_CREDENTIAL_MISSING`,调用方取消为 `WEB_ABORTED`,提供方或传输失败——包括响应中没有 `web_search_tool_result` 块——为 `WEB_PROVIDER_ERROR`。HTTP 重定向会在接触 `Location` 指向的目标之前被拒绝。面向模型的 `web_search` 工具会在自己的错误包装层内把失败文本呈现给模型。 +失败抛出携带可按机器路由 code 的 `WebError`:凭据缺失为 `WEB_PROVIDER_CREDENTIAL_MISSING`,调用方取消为 `WEB_ABORTED`,提供方或传输失败,包括响应中没有 `web_search_tool_result` 块,为 `WEB_PROVIDER_ERROR`。HTTP 重定向会在接触 `Location` 指向的目标之前被拒绝。请求发出后的每项失败都会指出已解析的搜索端点,并说明搜索端点配置独立于聊天端点。如果该端点不符合用户预期,错误消息会要求会话模型指导用户进入 Settings > Plugins > Plugin configuration > Web search,修改 Endpoint 字段并保存。该页面不可用时,消息会把 `DEEPSEEK_SEARCH_BASE_URL` 和 `web-search-deepseek.baseURL` 作为部署配置方式。模型不得替用户选择或修改端点。面向模型的 `web_search` 工具会在自己的错误包装层内呈现这段文本。 ----- @@ -136,7 +136,7 @@ kind: "package-reference" #### 模型看到的内容 -通过 `dsh-tool-web`,会话模型会看到结构化搜索块中去重后的 URL、标题、日期与引用 snippet;提供方文本不会作为答案受到信任。该提供方的具体失败消息包括带有处理指引的凭据缺失消息、`DeepSeek search credential resolution failed: `、`DeepSeek search aborted`、`DeepSeek search request failed: `、`DeepSeek returned no web_search_tool_result blocks; the request may not have triggered native web search` 和 `DeepSeek returned an unprocessable response body: `;HTTP 失败保留提供方消息。错误包装属于消费方。 +通过 `dsh-tool-web`,会话模型会看到结构化搜索块中去重后的 URL、标题、日期与引用 snippet;提供方文本不会作为答案受到信任。该提供方的具体失败消息包括带有处理指引的凭据缺失消息、`DeepSeek search credential resolution failed: ` 和 `DeepSeek search aborted`。请求、HTTP、原生搜索和响应正文失败会追加已解析端点及前述条件式配置指引。错误包装属于消费方。 #### Token 影响 diff --git a/packages/web/web-search-deepseek/src/provider.ts b/packages/web/web-search-deepseek/src/provider.ts index d6805bcacc..8fc4a92b27 100644 --- a/packages/web/web-search-deepseek/src/provider.ts +++ b/packages/web/web-search-deepseek/src/provider.ts @@ -173,7 +173,10 @@ export function mapAnthropicResponse(response: AnthropicResponse): WebSearchResu return { sources, truncated: false } } -/** The DeepSeek-backed search provider; HTTP redirects fail as `WEB_PROVIDER_ERROR`. */ +/** + * The DeepSeek-backed search provider. HTTP redirects fail as `WEB_PROVIDER_ERROR`; + * failures after dispatch name the endpoint and tell the model how the user can configure it. + */ export class DeepSeekSearchProvider implements WebSearchProvider { readonly id = DEEPSEEK_PROVIDER_ID @@ -237,7 +240,11 @@ export class DeepSeekSearchProvider implements WebSearchProvider { }) } catch (error: unknown) { if (signal?.aborted === true || isAbortError(error)) throw searchAborted(signal, error) - throw new WebError(`DeepSeek search request failed: ${String(error)}`, 'WEB_PROVIDER_ERROR', { cause: error }) + throw searchEndpointError( + endpoint, + `DeepSeek search request failed: ${String(error)}`, + error, + ) } if (!response.ok) { @@ -246,7 +253,7 @@ export class DeepSeekSearchProvider implements WebSearchProvider { try { const parsed = await response.json() as AnthropicError const detail = typeof parsed.error === 'string' ? parsed.error : parsed.error?.message ?? parsed.message - if (detail !== undefined && detail.length > 0) message = detail + if (detail !== undefined && detail.length > 0) message += `: ${detail}` } catch (error: unknown) { // An abort fired mid-body must surface as WEB_ABORTED, not be swallowed // into a generic HTTP-error message — cancellation is not a provider @@ -256,7 +263,7 @@ export class DeepSeekSearchProvider implements WebSearchProvider { // malformed/non-JSON error body (normal for gateway 5xx/429s) can only // cost a richer provider message, never the real error. } - throw new WebError(message, 'WEB_PROVIDER_ERROR') + throw searchEndpointError(endpoint, message) } try { @@ -264,8 +271,10 @@ export class DeepSeekSearchProvider implements WebSearchProvider { return mapAnthropicResponse(payload) } catch (error: unknown) { if (signal?.aborted === true || isAbortError(error)) throw searchAborted(signal, error) - if (error instanceof WebError) throw error - throw new WebError(`DeepSeek returned an unprocessable response body: ${String(error)}`, 'WEB_PROVIDER_ERROR', { cause: error }) + const message = error instanceof WebError + ? error.message + : `DeepSeek returned an unprocessable response body: ${String(error)}` + throw searchEndpointError(endpoint, message, error) } } @@ -300,6 +309,20 @@ export class DeepSeekSearchProvider implements WebSearchProvider { } } +/** Add endpoint recovery instructions to failures that occur after request dispatch begins. */ +function searchEndpointError(endpoint: string, message: string, cause?: unknown): WebError { + return new WebError( + `${message}\n\nThe web search request used endpoint ${JSON.stringify(endpoint)}. ` + + 'Search endpoint configuration is separate from chat. If that endpoint is not intended, ' + + 'guide the user to Settings > Plugins > Plugin configuration > Web search, where they can ' + + 'change and save Endpoint. If that settings page is unavailable, the user can set ' + + 'DEEPSEEK_SEARCH_BASE_URL or configure web-search-deepseek.baseURL to a trusted ' + + 'Anthropic-compatible Messages API base. Only the user should choose or change the endpoint.', + 'WEB_PROVIDER_ERROR', + cause === undefined ? undefined : { cause }, + ) +} + /** * Race a same-process asynchronous preflight against caller cancellation. The * attached settlement handlers keep observing an uncooperative operation after diff --git a/packages/web/web-search-deepseek/tests/deepseek.spec.ts b/packages/web/web-search-deepseek/tests/deepseek.spec.ts index baf8d55a3e..2bed3147a1 100644 --- a/packages/web/web-search-deepseek/tests/deepseek.spec.ts +++ b/packages/web/web-search-deepseek/tests/deepseek.spec.ts @@ -6,7 +6,7 @@ import { Context } from '@deepseek-ai/cordis' import Loader from '@deepseek-ai/cordis-plugin-loader' import { credentialRef } from '@deepseek-ai/dsh-credentials' import LocalCredentialProvider from '@deepseek-ai/dsh-credentials-local' -import WebRuntime from '@deepseek-ai/dsh-web' +import WebRuntime, { WebError } from '@deepseek-ai/dsh-web' import { DeepSeekSearchProvider, DEEPSEEK_PROVIDER_ID, @@ -21,6 +21,17 @@ import type { DeepSeekSearchProviderOptions } from '@deepseek-ai/dsh-web-search- const searchProvider = (options: DeepSeekSearchProviderOptions): DeepSeekSearchProvider => new DeepSeekSearchProvider(() => options) +/** Return the provider's rejected WebError, or propagate an unexpected outcome. */ +async function rejectedWebError(operation: Promise): Promise { + try { + await operation + } catch (error: unknown) { + if (error instanceof WebError) return error + throw error + } + throw new Error('expected search operation to reject') +} + const options = { apiKey: 'ds-key', baseURL: 'https://api.deepseek.test/anthropic/v1', @@ -322,25 +333,34 @@ describe('DeepSeekSearchProvider error handling', () => { it('maps an HTTP error to WEB_PROVIDER_ERROR with the provider message', async () => { vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ error: { message: 'rate limited' } }, { status: 429 }))) await expect(searchProvider(options).search({ query: 'q' })) - .rejects.toThrow(expect.objectContaining({ code: 'WEB_PROVIDER_ERROR', message: 'rate limited' })) + .rejects.toThrow(expect.objectContaining({ + code: 'WEB_PROVIDER_ERROR', + message: 'DeepSeek API error (HTTP 429): rate limited\n\n' + + 'The web search request used endpoint "https://api.deepseek.test/anthropic/v1/messages". ' + + 'Search endpoint configuration is separate from chat. If that endpoint is not intended, ' + + 'guide the user to Settings > Plugins > Plugin configuration > Web search, where they can ' + + 'change and save Endpoint. If that settings page is unavailable, the user can set ' + + 'DEEPSEEK_SEARCH_BASE_URL or configure web-search-deepseek.baseURL to a trusted ' + + 'Anthropic-compatible Messages API base. Only the user should choose or change the endpoint.', + })) }) it('handles a string-form error body', async () => { vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ error: 'bad request' }, { status: 400 }))) - await expect(searchProvider(options).search({ query: 'q' })) - .rejects.toThrow(expect.objectContaining({ message: 'bad request' })) + const error = await rejectedWebError(searchProvider(options).search({ query: 'q' })) + expect(error.message).toContain('DeepSeek API error (HTTP 400): bad request') }) it('keeps a status-line message when the error body is not JSON', async () => { vi.stubGlobal('fetch', vi.fn(async () => new Response('upstream error', { status: 503 }))) - await expect(searchProvider(options).search({ query: 'q' })) - .rejects.toThrow(expect.objectContaining({ message: 'DeepSeek API error (HTTP 503)' })) + const error = await rejectedWebError(searchProvider(options).search({ query: 'q' })) + expect(error.message).toContain('DeepSeek API error (HTTP 503)') }) it('keeps the status-line message when the JSON error body carries no detail', async () => { vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({}, { status: 500 }))) - await expect(searchProvider(options).search({ query: 'q' })) - .rejects.toThrow(expect.objectContaining({ message: 'DeepSeek API error (HTTP 500)' })) + const error = await rejectedWebError(searchProvider(options).search({ query: 'q' })) + expect(error.message).toContain('DeepSeek API error (HTTP 500)') }) it('maps an abort to WEB_ABORTED', async () => { @@ -388,14 +408,16 @@ describe('DeepSeekSearchProvider error handling', () => { it('maps a network failure to WEB_PROVIDER_ERROR', async () => { vi.stubGlobal('fetch', vi.fn(() => Promise.reject(new TypeError('connection refused')))) - await expect(searchProvider(options).search({ query: 'q' })) - .rejects.toThrow(expect.objectContaining({ code: 'WEB_PROVIDER_ERROR' })) + const error = await rejectedWebError(searchProvider(options).search({ query: 'q' })) + expect(error.code).toBe('WEB_PROVIDER_ERROR') + expect(error.message).toContain('The web search request used endpoint "https://api.deepseek.test/anthropic/v1/messages".') }) it('strict mode flows through search(): a prose-only response throws WEB_PROVIDER_ERROR', async () => { vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ content: [{ type: 'text', text: 'no search happened' }] }))) - await expect(searchProvider(options).search({ query: 'q' })) - .rejects.toThrow(expect.objectContaining({ code: 'WEB_PROVIDER_ERROR' })) + const error = await rejectedWebError(searchProvider(options).search({ query: 'q' })) + expect(error.code).toBe('WEB_PROVIDER_ERROR') + expect(error.message).toContain('Search endpoint configuration is separate from chat.') }) }) diff --git a/snapshots/session/web-search-endpoint-guidance/cordis.snapshot.yml b/snapshots/session/web-search-endpoint-guidance/cordis.snapshot.yml new file mode 100644 index 0000000000..ffd6cf97f8 --- /dev/null +++ b/snapshots/session/web-search-endpoint-guidance/cordis.snapshot.yml @@ -0,0 +1,32 @@ +# Keyless replay counterpart: the failed search remains real; only the +# conversation model adapter is replaced by replay. +- id: llm-deepseek + name: '@deepseek-ai/dsh-llm-deepseek' + disabled: true + +- id: plugin-package-inventory-deepseek + disabled: true + +- insert: + - id: llm-replay + name: '@deepseek-ai/dsh-llm-replay' + config: + providers: + - id: deepseek-official + name: DeepSeek + models: + - id: deepseek-v4-flash + contextWindow: 1000000 + defaultMaxTokens: 256000 + reasoningEfforts: ['off', 'low', 'high', 'max'] + defaultReasoningEffort: max + - id: deepseek-v4-pro + + - id: web-search-error-fixture + name: './web-search-error-fixture.mjs' + +- id: web-search-deepseek + name: '@deepseek-ai/dsh-web-search-deepseek' + config: + apiKey: snapshot-key + baseURL: http://127.0.0.1:43118/anthropic/v1 diff --git a/snapshots/session/web-search-endpoint-guidance/cordis.yml b/snapshots/session/web-search-endpoint-guidance/cordis.yml new file mode 100644 index 0000000000..222db9ec16 --- /dev/null +++ b/snapshots/session/web-search-endpoint-guidance/cordis.yml @@ -0,0 +1,10 @@ +# Live-recording patch for a deterministic failed DeepSeek search request. +- insert: + - id: web-search-error-fixture + name: './web-search-error-fixture.mjs' + +- id: web-search-deepseek + name: '@deepseek-ai/dsh-web-search-deepseek' + config: + apiKey: snapshot-key + baseURL: http://127.0.0.1:43118/anthropic/v1 diff --git a/snapshots/session/web-search-endpoint-guidance/session.jsonl b/snapshots/session/web-search-endpoint-guidance/session.jsonl new file mode 100644 index 0000000000..8fa009dc13 --- /dev/null +++ b/snapshots/session/web-search-endpoint-guidance/session.jsonl @@ -0,0 +1,38 @@ +{"type":"session","version":0,"id":"{{session:1}}","createdAt":1787888585536,"cwd":"{{cwd}}","delegationDepth":0} +{"type":"permission/preset","data":{"preset":"danger-full-access"}} +{"type":"sandbox/mode","data":{"mode":"danger-full-access"}} +{"type":"approval/policy","data":{"policy":"never"}} +{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"inserted":[{"content":[{"type":"text","text":"Use web_search exactly once to search for DSH endpoint configuration snapshot. If it fails, do not retry. Report only the endpoint and the configuration or restriction facts stated in the tool error. Do not infer why it failed or whether the endpoint is correct."}],"source":{"kind":"user"},"role":"user","id":"{{message:1}}"}]}} +{"type":"turn/start","data":{"turn":1}} +{"type":"agent/inbox/spliced","data":{"target":"next-turn","start":0,"removedCount":1,"inserted":[]}} +{"type":"step/start","data":{"turn":1,"step":1}} +{"type":"user/message","data":{"content":[{"type":"text","text":"Use web_search exactly once to search for DSH endpoint configuration snapshot. If it fails, do not retry. Report only the endpoint and the configuration or restriction facts stated in the tool error. Do not infer why it failed or whether the endpoint is correct."}],"source":{"kind":"user"},"role":"user","id":"{{message:1}}"},"surfaceOp":"append"} +{"type":"user/message","data":{"content":[{"type":"text","text":"Current runtime context. This snapshot supersedes earlier runtime-context snapshots.\n\nCurrent DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations.\n\nApproval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."}],"source":{"kind":"plugin","plugin":"@deepseek-ai/dsh-system-prompt","form":"snapshot","sections":[{"name":"sandbox:policy","text":"Current DSH file policy: danger-full-access. The DSH file sandbox does not restrict file modifications by available operations."},{"name":"approval:policy","text":"Approval prompts are disabled in this session: actions that require approval are rejected automatically — do not request sandbox escalation (do not set `sandbox_permissions`)."}]},"role":"user","id":"{{message:2}}"},"surfaceOp":"append"} +{"type":"session/title","data":{"title":"Use web_search exactly once to","messageSeqs":[7],"source":{"kind":"fallback"}}} +{"type":"request/header","data":{"header":{"config":{"provider":"deepseek-official","model":"deepseek-v4-flash","maxTokens":256000,"reasoningEffort":"max"},"adapterDefaults":{"reasoningEffort":true,"maxTokens":true},"system":"{{system}}","tools":"{{tools}}"},"reason":"initial"}} +{"type":"request/context","data":{"provider":"deepseek-official","model":"deepseek-v4-flash","contextWindow":1000000}} +{"type":"assistant/chunk","data":{"turn":1,"step":1,"chunk":{"type":"block-start","index":0,"blockType":"reasoning"}}} +{"type":"reasoning-chunks","data":{"turn":1,"step":1,"index":0,"dt":[33,12,0,1,0,0,1,19,0,1,24,0,1,0,0,1,21,1,0,0,35,1,0,0,6,1,0,0,1,0,-159,0,1,0,0,1,0,0,1,0,0,0,0,0,1,0,11,1,0,0,0,1,11,1,0,0,0,0,22,1,0],"texts":["The"," user"," wants"," me"," to"," use"," web","_search"," exactly"," once"," to"," search"," for"," \"","DS","H"," endpoint"," configuration"," snapshot","\"."," If"," it"," fails",","," do"," not"," ret","ry","."," Report"," only"," the"," endpoint"," and"," configuration"," or"," restriction"," facts"," stated"," in"," the"," tool"," error","."," Do"," not"," infer"," why"," it"," failed"," or"," whether"," the"," endpoint"," is"," correct",".\n\n","Let"," me"," do"," that","."]}} +{"type":"assistant/chunk","data":{"turn":1,"step":1,"chunk":{"type":"block-start","index":1,"blockType":"tool-call"}}} +{"type":"tool-call-chunks","data":{"turn":1,"step":1,"index":1,"dt":[21,1,0,0,0,0,23,1,0,20,1,0,0,-67],"id":"call_00_A9k4j3Xfcf4JY1SeXxFW1176","name":"web_search","args":["","{","\"","qu","eries","\"",": ","[\"","DS","H"," endpoint"," configuration"," snapshot","\"]","}"]}} +{"type":"assistant/chunk","data":{"turn":1,"step":1,"chunk":{"type":"block-end","index":0,"block":{"type":"reasoning","text":"The user wants me to use web_search exactly once to search for \"DSH endpoint configuration snapshot\". If it fails, do not retry. Report only the endpoint and configuration or restriction facts stated in the tool error. Do not infer why it failed or whether the endpoint is correct.\n\nLet me do that."}}}} +{"type":"assistant/chunk","data":{"turn":1,"step":1,"chunk":{"type":"block-end","index":1,"block":{"type":"tool-call","id":"call_00_A9k4j3Xfcf4JY1SeXxFW1176","name":"web_search","arguments":"{\"queries\": [\"DSH endpoint configuration snapshot\"]}"}}}} +{"type":"assistant/chunk","data":{"turn":1,"step":1,"chunk":{"type":"usage","usage":{"inputTokens":7833,"outputTokens":113,"totalTokens":7946,"cacheReadTokens":0,"reasoningTokens":62}}}} +{"type":"assistant/chunk","data":{"turn":1,"step":1,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}} +{"type":"assistant/message","data":{"turn":1,"step":1,"message":{"role":"assistant","content":[{"type":"reasoning","text":"The user wants me to use web_search exactly once to search for \"DSH endpoint configuration snapshot\". If it fails, do not retry. Report only the endpoint and configuration or restriction facts stated in the tool error. Do not infer why it failed or whether the endpoint is correct.\n\nLet me do that."},{"type":"tool-call","id":"call_00_A9k4j3Xfcf4JY1SeXxFW1176","name":"web_search","arguments":"{\"queries\": [\"DSH endpoint configuration snapshot\"]}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash"},"id":"{{message:3}}"},"usage":{"inputTokens":7833,"outputTokens":113,"totalTokens":7946,"cacheReadTokens":0,"reasoningTokens":62}},"sourceEventSeqs":[12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94],"surfaceOp":"append"} +{"type":"tool/call","data":{"turn":1,"step":1,"callId":"call_00_A9k4j3Xfcf4JY1SeXxFW1176","name":"web_search","arguments":"{\"queries\": [\"DSH endpoint configuration snapshot\"]}"}} +{"type":"web/deepseek-search-llm-request","data":{"endpoint":"http://127.0.0.1:43118/anthropic/v1/messages","apiVersion":"2023-06-01","body":{"model":"deepseek-v4-flash","max_tokens":4096,"messages":[{"role":"user","content":[{"type":"text","text":"Perform a web search for the query: DSH endpoint configuration snapshot"}]}],"tools":[{"type":"web_search_20250305","name":"web_search","max_uses":5}]}}} +{"type":"tool/result","data":{"turn":1,"step":1,"message":{"source":{"kind":"tool","callId":"call_00_A9k4j3Xfcf4JY1SeXxFW1176"},"content":[{"type":"tool-result","toolCallId":"call_00_A9k4j3Xfcf4JY1SeXxFW1176","content":[{"type":"text","text":"Error: DeepSeek API error (HTTP 401): invalid snapshot API key\n\nThe web search request used endpoint \"http://127.0.0.1:43118/anthropic/v1/messages\". Search endpoint configuration is separate from chat. If that endpoint is not intended, guide the user to Settings > Plugins > Plugin configuration > Web search, where they can change and save Endpoint. If that settings page is unavailable, the user can set DEEPSEEK_SEARCH_BASE_URL or configure web-search-deepseek.baseURL to a trusted Anthropic-compatible Messages API base. Only the user should choose or change the endpoint."}],"isError":true}],"role":"user","id":"{{message:4}}"},"error":{"name":"WebError","code":"WEB_PROVIDER_ERROR"}},"sourceEventSeqs":[96],"surfaceOp":"append"} +{"type":"step/end","data":{"turn":1,"step":1}} +{"type":"step/start","data":{"turn":1,"step":2}} +{"type":"assistant/chunk","data":{"turn":1,"step":2,"chunk":{"type":"block-start","index":0,"blockType":"reasoning"}}} +{"type":"reasoning-chunks","data":{"turn":1,"step":2,"index":0,"dt":[94,20,0,0,0,26,20,0,0,0,-160,0,0,0,0,1,0,0,0,1,0,0,1,0,0,3,1,0,0,0,23,0,1,0,20,1,23,0,0,0,1,0,22,1,29,0,0,0,0,17,1,0,0,1,1,17,1,0,22,0,1,0,1,0,-190,0,1,0,0,0,22,0,1,22,23,1,0,0,0,0,22,0,0,22,0,0,1,23,0,0,23,0,20,-181,1,22,0,1,0,81,-105,1,0,0,0,0,1,0,-2,0,0,1,-1,1,0,0,0,0,8,0,22,0,1,24,1,0,0,0,0,20,1,0,0,0,0,23,0,0,0,0,1,19,1,0,0,0,24,0,22,0,1,25,0,-194,0,10,1,0,20],"texts":["The"," user"," asked"," me"," to"," report"," only"," the"," endpoint"," and"," the"," configuration"," or"," restriction"," facts"," stated"," in"," the"," tool"," error","."," Do"," not"," infer"," why"," it"," failed"," or"," whether"," the"," endpoint"," is"," correct",".\n\n","F","acts"," stated"," in"," the"," error",":\n","-"," End","point"," used",":"," \"","http","://","127",".","0",".","0",".","1",":","431","18","/an","throp","ic","/v","1","/m","essages","\"\n","-"," Error",":"," HTTP"," ","401",","," \"","invalid"," snapshot"," API"," key","\"\n","-"," Search"," endpoint"," configuration"," is"," separate"," from"," chat","\n","-"," Guidance",":"," user"," can"," change"," endpoint"," at"," Settings"," >"," Plug","ins"," >"," Plugin"," configuration"," >"," Web"," search",";"," or"," set"," D","EEP","SEE","K","_SE","ARCH","_B","ASE","_URL"," or"," configure"," web","-search","-de","ep","seek",".base","URL"," to"," a"," trusted"," Anthrop","ic","-com","patible"," Messages"," API"," base","\n","-"," Only"," the"," user"," should"," choose"," or"," change"," the"," endpoint",".\n\n","I"," should"," report"," only"," these"," facts",","," no"," inference","."]}} +{"type":"assistant/chunk","data":{"turn":1,"step":2,"chunk":{"type":"block-start","index":1,"blockType":"text"}}} +{"type":"text-chunks","data":{"turn":1,"step":2,"index":1,"dt":[0,0,20,21,1,23,22,1,0,24,0,0,0,0,1,-113,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,12,1,0,0,0,0,16,1,0,20,0,0,0,20,0,0,0,22,0,1,0,0,21,0,0,23,1,0,0,1,37,0,1,0,0,-180,1,0,0,0,1,0,0,0,0,1,1,0,0,4,0,0,1,23,1,0,0,30,0,0,1,0,20,1,0,0,0,0,16,19,1,0,0,0,25,1,0,0,1,0,18,0,0,24,1,0,-191,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,-4,0,1,0,0,19,1,0,0,0,22,0,0,1,22,0,23,0],"texts":["The"," web"," search"," attempt"," failed","."," Facts"," from"," the"," tool"," error",":\n\n","-"," **","Endpoint"," used",":**"," `","http","://","127",".","0",".","0",".","1",":","431","18","/an","throp","ic","/v","1","/m","essages","`\n","-"," **","Error",":**"," HTTP"," ","401"," —"," \"","invalid"," snapshot"," API"," key","\"\n","-"," **","Configuration"," facts"," stated",":","**\n"," "," -"," Search"," endpoint"," configuration"," is"," separate"," from"," chat"," configuration",".\n"," "," -"," The"," endpoint"," can"," be"," changed","/s","aved"," at"," Settings"," >"," Plug","ins"," >"," Plugin"," configuration"," >"," Web"," search",".\n"," "," -"," If"," that"," settings"," page"," is"," unavailable",","," alternatives"," are"," setting"," `","D","EEP","SEE","K","_SE","ARCH","_B","ASE","_URL","`"," or"," configuring"," `","web","-search","-de","ep","seek",".base","URL","`"," to"," a"," trusted"," Anthrop","ic","-com","patible"," Messages"," API"," base",".\n"," "," -"," Only"," the"," user"," should"," choose"," or"," change"," the"," endpoint",".\n\n","No"," ret","ry"," was"," performed",","," per"," your"," instruction","."]}} +{"type":"assistant/chunk","data":{"turn":1,"step":2,"chunk":{"type":"block-end","index":0,"block":{"type":"reasoning","text":"The user asked me to report only the endpoint and the configuration or restriction facts stated in the tool error. Do not infer why it failed or whether the endpoint is correct.\n\nFacts stated in the error:\n- Endpoint used: \"http://127.0.0.1:43118/anthropic/v1/messages\"\n- Error: HTTP 401, \"invalid snapshot API key\"\n- Search endpoint configuration is separate from chat\n- Guidance: user can change endpoint at Settings > Plugins > Plugin configuration > Web search; or set DEEPSEEK_SEARCH_BASE_URL or configure web-search-deepseek.baseURL to a trusted Anthropic-compatible Messages API base\n- Only the user should choose or change the endpoint.\n\nI should report only these facts, no inference."}}}} +{"type":"assistant/chunk","data":{"turn":1,"step":2,"chunk":{"type":"block-end","index":1,"block":{"type":"text","text":"The web search attempt failed. Facts from the tool error:\n\n- **Endpoint used:** `http://127.0.0.1:43118/anthropic/v1/messages`\n- **Error:** HTTP 401 — \"invalid snapshot API key\"\n- **Configuration facts stated:**\n - Search endpoint configuration is separate from chat configuration.\n - The endpoint can be changed/saved at Settings > Plugins > Plugin configuration > Web search.\n - If that settings page is unavailable, alternatives are setting `DEEPSEEK_SEARCH_BASE_URL` or configuring `web-search-deepseek.baseURL` to a trusted Anthropic-compatible Messages API base.\n - Only the user should choose or change the endpoint.\n\nNo retry was performed, per your instruction."}}}} +{"type":"assistant/chunk","data":{"turn":1,"step":2,"chunk":{"type":"usage","usage":{"inputTokens":154,"outputTokens":319,"totalTokens":8409,"cacheReadTokens":7936,"reasoningTokens":160}}}} +{"type":"assistant/chunk","data":{"turn":1,"step":2,"chunk":{"type":"finish","reason":{"kind":"stop"}}}} +{"type":"assistant/message","data":{"turn":1,"step":2,"message":{"role":"assistant","content":[{"type":"reasoning","text":"The user asked me to report only the endpoint and the configuration or restriction facts stated in the tool error. Do not infer why it failed or whether the endpoint is correct.\n\nFacts stated in the error:\n- Endpoint used: \"http://127.0.0.1:43118/anthropic/v1/messages\"\n- Error: HTTP 401, \"invalid snapshot API key\"\n- Search endpoint configuration is separate from chat\n- Guidance: user can change endpoint at Settings > Plugins > Plugin configuration > Web search; or set DEEPSEEK_SEARCH_BASE_URL or configure web-search-deepseek.baseURL to a trusted Anthropic-compatible Messages API base\n- Only the user should choose or change the endpoint.\n\nI should report only these facts, no inference."},{"type":"text","text":"The web search attempt failed. Facts from the tool error:\n\n- **Endpoint used:** `http://127.0.0.1:43118/anthropic/v1/messages`\n- **Error:** HTTP 401 — \"invalid snapshot API key\"\n- **Configuration facts stated:**\n - Search endpoint configuration is separate from chat configuration.\n - The endpoint can be changed/saved at Settings > Plugins > Plugin configuration > Web search.\n - If that settings page is unavailable, alternatives are setting `DEEPSEEK_SEARCH_BASE_URL` or configuring `web-search-deepseek.baseURL` to a trusted Anthropic-compatible Messages API base.\n - Only the user should choose or change the endpoint.\n\nNo retry was performed, per your instruction."}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash"},"id":"{{message:5}}"},"usage":{"inputTokens":154,"outputTokens":319,"totalTokens":8409,"cacheReadTokens":7936,"reasoningTokens":160}},"sourceEventSeqs":[101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424],"surfaceOp":"append"} +{"type":"step/end","data":{"turn":1,"step":2}} +{"type":"turn/end","data":{"turn":1,"reason":{"kind":"completed"}}} diff --git a/snapshots/session/web-search-endpoint-guidance/snapshot.yml b/snapshots/session/web-search-endpoint-guidance/snapshot.yml new file mode 100644 index 0000000000..31548acb92 --- /dev/null +++ b/snapshots/session/web-search-endpoint-guidance/snapshot.yml @@ -0,0 +1,10 @@ +version: 1 +scenario: web-search-endpoint-guidance +profile: headless +composition: web-search-endpoint-guidance +recording: live +header: + class: web-search-endpoint-guidance + pin: true + systemPromptSource: text-turn + toolSchemasSource: text-turn diff --git a/snapshots/session/web-search-endpoint-guidance/web-search-error-fixture.mjs b/snapshots/session/web-search-endpoint-guidance/web-search-error-fixture.mjs new file mode 100644 index 0000000000..291ef07715 --- /dev/null +++ b/snapshots/session/web-search-endpoint-guidance/web-search-error-fixture.mjs @@ -0,0 +1,32 @@ +/** Deterministic authentication failure for the search endpoint guidance snapshot. */ +import { createServer } from 'node:http' + +/** Fixed loopback port recorded in the provider diagnostic. */ +const PORT = 43118 + +/** Cordis plugin name. */ +export const name = 'web-search-error-fixture' + +/** Start the local Messages endpoint and stop it with the plugin fiber. */ +export async function apply(ctx) { + const server = createServer((request, response) => { + if (request.method === 'POST' && request.url === '/anthropic/v1/messages') { + response.writeHead(401, { 'content-type': 'application/json' }) + response.end(JSON.stringify({ error: { message: 'invalid snapshot API key' } })) + return + } + response.writeHead(404, { 'content-type': 'text/plain; charset=utf-8' }) + response.end('not found') + }) + await new Promise((resolve, reject) => { + server.once('error', reject) + server.listen(PORT, '127.0.0.1', () => resolve(undefined)) + }) + server.unref() + ctx.effect(() => async () => { + await new Promise((resolve, reject) => { + server.close(error => error ? reject(error) : resolve(undefined)) + server.closeAllConnections() + }) + }, 'web-search-error-fixture') +}