Repository navigation
feat(registry): support search_url and feedback_url on custom registry providers - #4875
Conversation
🦋 Changeset detectedLatest commit: 6ac735d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1f6e979f0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (provider === undefined || feedbackUrl === undefined || feedbackUrl.length === 0) { | ||
| return undefined; | ||
| } | ||
| const credential = declaredProviderCredential(provider, providerName); |
There was a problem hiding this comment.
Honor provider env credentials for custom feedback
When a provider relies on the documented [providers.<name>.env] credential fallback, declaredProviderCredential returns none because it only examines apiKey, apiKeyEnv, and OAuth. The facade consequently ignores the configured feedback_url and falls through to the managed OAuth path, even though the same provider credential works for model requests and WebSearch. Resolve the provider-type-specific env credential here before selecting the custom feedback target.
Useful? React with 👍 / 👎.
| if (custom?.kind === 'custom') { | ||
| return fetchSubmitFeedback(custom.feedbackUrl, custom.apiKey, body); |
There was a problem hiding this comment.
Forward provider custom headers to feedback endpoints
When a custom provider requires [providers.<name>.custom_headers]—for example, a gateway that requires an organization or routing header—the new feedback path passes only the URL, API key, and body. The submit and both attachment helpers then construct fixed headers, so /feedback fails even though model requests and the new WebSearch path forward the provider's custom headers. Include these headers in all three custom feedback requests.
Useful? React with 👍 / 👎.
| when: (accessor) => | ||
| accessor | ||
| .get(IWebSearchProviderService) | ||
| .hasWebSearchProvider(accessor.get(IAgentLoopService).getModel()), |
There was a problem hiding this comment.
Deactivate WebSearch after switching providers
When a session starts on a model whose provider has search_url and later switches to a model with neither search_url nor a managed/service fallback, this model-dependent predicate has already registered WebSearch. AgentToolActivationService skips registered contributions and never deactivates them when when becomes false, so subsequent tool reconciliation continues advertising WebSearch; any call then fails with “web search is no longer configured.” Reevaluate and remove this contribution on model changes, or filter it from the request tool set dynamically.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 297fb9819e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| "@moonshot-ai/kimi-code": patch | ||
| --- | ||
|
|
||
| Support optional `search_url` and `feedback_url` fields on custom registry (`api.json`) providers for `WebSearch` and `/feedback`. |
There was a problem hiding this comment.
Preserve the existing feedback SDK methods
When an SDK consumer calls KimiHarness.auth.submitFeedback, createFeedbackUploadUrl, or completeFeedbackUpload, this release removes those exported KimiAuthFacade methods and result types, so previously valid clients stop compiling or fail at runtime. The replacement methods on KimiHarness do not preserve that API, while this changeset advertises only the new registry fields; retain deprecated forwarding methods, or obtain explicit approval for the break and name the lost API and migration in the changeset.
AGENTS.md reference: AGENTS.md:L114-L116
Useful? React with 👍 / 👎.
| feedback: { | ||
| availability: (modelAlias) => | ||
| call('feedbackService', 'availability', [modelAlias]) as Promise<FeedbackAvailability>, |
There was a problem hiding this comment.
Add cross-transport conformance coverage for feedback
For the new global.feedback facade, no case was added to test/helpers/conformance.ts, so none of its four methods or result variants is exercised through the memory and IPC transports that this public facade must support. Add the feedback flow to the shared conformance suite, including the optional model alias and error/login results, rather than relying only on direct core and TUI tests.
AGENTS.md reference: packages/klient/AGENTS.md:L36-L40
Useful? React with 👍 / 👎.
| const providerName = nonEmptyString(model.provider ?? model.providerId); | ||
| if (providerName === undefined) return undefined; |
There was a problem hiding this comment.
Resolve the effective provider consistently
When a model relies on default_provider, this resolver returns undefined even though the model catalog runs that model through IProviderService.getDefaultProvider(); when both providerId and provider are present, it also chooses them in the opposite order from the catalog. The same divergence exists in FeedbackService.customProvider, with feedback additionally ignoring the default model when its optional alias is omitted. These supported configurations therefore disable the custom endpoints or, in the dual-field case, can send searches and feedback to a different provider than the model request; mirror the catalog's providerId ?? provider ?? defaultProvider resolution and its default-model fallback in both services.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ee63280406
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const token = refresh | ||
| ? await this.oauth.resolveTokenProvider(key, auth.oauth)?.getAccessToken() | ||
| : await this.oauth.getCachedAccessToken(key, auth.oauth); |
There was a problem hiding this comment.
Return structured errors for custom OAuth failures
When a provider with feedback_url uses OAuth and reading or refreshing its token rejects—for example because the token store is unavailable or the refresh token is expired—the rejection escapes bearer() instead of producing the FeedbackSubmitResult/availability { kind: 'error' } variant. Consequently the kap-server route returns a transport-level 500 and klient callers receive a rejected call, unlike the managed branch which catches getAccessToken() failures. Catch both OAuth calls here and convert them to the declared error result.
Useful? React with 👍 / 👎.
| input: FeedbackUploadUrlInput, | ||
| modelAlias?: string, | ||
| ): Promise<FeedbackUploadUrlResult> { | ||
| const target = await this.resolveTarget(modelAlias, true); |
There was a problem hiding this comment.
Pin uploads to the original feedback target
When provider configuration changes after text feedback is submitted but before its attachments finish—for example, a runtime registry refresh removes the active alias or changes its feedback_url while the TUI is exporting and packaging the session—createUploadUrl() resolves the target again and can switch from the original custom endpoint to a different endpoint or the managed fallback. The resulting request carries an ID issued by the first backend, so attachment upload fails or can be associated with an unrelated record if IDs overlap; completeUpload() repeats the same re-resolution. Bind the upload flow to the target selected by submit() rather than consulting mutable model configuration at every stage.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
commit: |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Web and desktop reach this machine through kap-server, so feedback submission resolves the active model's provider in the engine and is exposed on the same route and klient method. The SDK facade keeps the managed OAuth path and no longer re-derives provider credentials.
Product clients submit feedback through the engine. The SDK facade and oauth toolkit no longer keep a second managed-only submission path.
The HTTP body uses the engine field names, so the route forwards it and the klient contract imports the same schemas.
TUI reaches IFeedbackService through the harness. The HTTP routes, klient facade, and the schemas that only served them have no caller.
The feedback codebase scanner added in this branch calls promisify(execFile) at module scope and is now reachable from the agent-core-v2 index, so partial child_process mocks in these suites failed module evaluation.
a827029 to
6ac735d
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…y providers Port MoonshotAI#4875: custom registry entries carry optional search_url/feedback_url into provider config; WebSearch and /feedback resolve the active model's provider credential, with the engine owning feedback submission and attachment packaging. The fork keeps its streaming dual-hash session digest, pre-read size guard and codebaseTruncated reporting. Also refresh the tool.test content-part snapshots that had drifted from the emitted block/startedAt fields.
* fix(agent-core-v2): avoid quadratic cloning during session replay (#4885) * fix(agent-core-v2): avoid quadratic cloning during session replay * fix(agent-core-v2): isolate replay assignments and preserve rollback order * refactor(agent-core-v2): make participant mutable replay explicit opt-in --------- Co-authored-by: kimi-agent-bot <[email protected]> * fix(agent-core-v2): validate Kimi media upload status (#4905) * fix(agent-core-v2): reject failed Kimi image extraction * chore: add Kimi image extraction changeset * fix(agent-core-v2): validate Kimi media upload status * fix(kap-server): forward swarm member task events (#4922) * test(agent-core-v2): make zero-timeout task wait deterministic (#4925) Co-authored-by: kimi-agent-bot <[email protected]> * feat(registry): support search_url and feedback_url on custom registry providers (#4875) * feat(registry): support search_url and feedback_url on custom registry providers * fix(sdk): honor provider.env credentials and custom_headers for feedback_url * refactor(core): submit feedback through the engine Web and desktop reach this machine through kap-server, so feedback submission resolves the active model's provider in the engine and is exposed on the same route and klient method. The SDK facade keeps the managed OAuth path and no longer re-derives provider credentials. * refactor(sdk): drop the unused feedback facade Product clients submit feedback through the engine. The SDK facade and oauth toolkit no longer keep a second managed-only submission path. * refactor(feedback): share engine schemas across route and klient The HTTP body uses the engine field names, so the route forwards it and the klient contract imports the same schemas. * refactor(feedback): drop unused kap and klient surfaces TUI reaches IFeedbackService through the harness. The HTTP routes, klient facade, and the schemas that only served them have no caller. * refactor(feedback): package and upload feedback attachments in the engine * refactor(feedback): keep FeedbackService internal to agent-core-v2 * test(cli): provide execFile in node:child_process mocks The feedback codebase scanner added in this branch calls promisify(execFile) at module scope and is now reachable from the agent-core-v2 index, so partial child_process mocks in these suites failed module evaluation. * feat(feedback): disclose submitted files, attach request_id, and drop text-only option (#4876) * feat(registry): support search_url and feedback_url on custom registry providers * fix(sdk): honor provider.env credentials and custom_headers for feedback_url * refactor(core): submit feedback through the engine Web and desktop reach this machine through kap-server, so feedback submission resolves the active model's provider in the engine and is exposed on the same route and klient method. The SDK facade keeps the managed OAuth path and no longer re-derives provider credentials. * refactor(sdk): drop the unused feedback facade Product clients submit feedback through the engine. The SDK facade and oauth toolkit no longer keep a second managed-only submission path. * refactor(feedback): share engine schemas across route and klient The HTTP body uses the engine field names, so the route forwards it and the klient contract imports the same schemas. * refactor(feedback): drop unused kap and klient surfaces TUI reaches IFeedbackService through the harness. The HTTP routes, klient facade, and the schemas that only served them have no caller. * refactor(feedback): package and upload feedback attachments in the engine * refactor(feedback): keep FeedbackService internal to agent-core-v2 * test(cli): provide execFile in node:child_process mocks The feedback codebase scanner added in this branch calls promisify(execFile) at module scope and is now reachable from the agent-core-v2 index, so partial child_process mocks in these suites failed module evaluation. * feat(feedback): disclose submitted files, attach request_id, and drop text-only option * fix(session-export): keep SESSION_NOT_FOUND for missing non-empty session ids The global-log-only fallback exists for feedback submissions without an active session (empty id). Scoping it to empty ids restores the 40401 envelope that kap-server's export route promises for unknown sessions. * test(agent-core-v2): pin retained request id semantics in llmRequester assertions * chore: sync web dist from code-app code-app: 11563df26b92f0035659083327976a2e9b8e6727 code-app-release: b0b6d9c7a45c96ca48039ff05789c6e90f76ef20 code-app-local-build: 005d2b437493b7ab04d01f70542f3b6356699f4d * ci: release packages (#4918) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(agent-core-v2): align request id back-sync with main --------- Co-authored-by: kimi-agent-bot <[email protected]> Co-authored-by: Haozhe <[email protected]> Co-authored-by: 7Sageer <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Requirement or Bug
通过自定义注册表(兼容
models.dev的api.json)接入自有模型网关的团队,在使用未登录托管 Kimi Code OAuth 账号的环境(或同时登录了托管账号但切到自定义注册表模型的会话)时,无法将WebSearch和/feedback路由到该注册表配套的搜索与反馈服务。本 PR 支持在api.json的每个 Provider 条目下声明可选的search_url与feedback_url,自动按当前模型所属 Provider 启用并复用其凭证鉴权。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
在兼容
models.dev的api.json每个 Provider 条目下扩展两个扁平可选字符串字段search_url与feedback_url,导入和启动刷新时落盘到config.toml对应[providers.<id>]表中(字段非空即启用,上游移除后下次刷新自动从本地移除)。运行时通过resolveActiveModelProvider(对齐模型目录的model.providerId ?? model.provider ?? default_provider与default_model优先级)反查当前模型所属 Provider 的配置与凭证(resolveModelAuthMaterial:api_key、api_key_env、[providers.<id>.env]、oauth 及custom_headers)发送请求。WebSearch留在WebSearchProviderService。/feedback(含文本提交、session.zip导出与repo.zip扫描打包及分片上传)统一收敛到引擎 App 级IFeedbackService,外部契约只保留availability与submit两个方法。TUI 只负责门控、弹窗和显示结果,提交走KimiHarness.submitFeedback。flowchart LR Registry["api.json Provider Entry<br/>(search_url / feedback_url)"] -->|import / refresh| Config["config.toml<br/>[providers.<id>]"] Config --> Resolve["resolveActiveModelProvider<br/>+ resolveModelAuthMaterial"] Resolve --> WebSearch["WebSearchProviderService"] Resolve --> Feedback["IFeedbackService<br/>(availability / submit)"] TUI["TUI /feedback"] --> Harness["KimiHarness"] Harness --> Feedback Feedback -->|export| SessionZip["ISessionExportService<br/>(session.zip)"] Feedback -->|scan + pack| RepoZip["feedback/codebase<br/>(repo.zip)"] WebSearch -->|Bearer provider credential| SearchAPI["POST <search_url>"] Feedback -->|Bearer provider credential| FeedbackAPI["POST <feedback_url><br/>+ /upload_url & /upload_complete"]当前模型的 provider 有非空
feedback_url时,只用该 provider 的凭证发往该地址;凭证缺失或冲突时返回错误,不落到托管通道。没有feedback_url时才走托管 OAuth。session.zip与repo.zip的准备、流式哈希计算和分片上传都在FeedbackService.submit内完成,附件部分失败通过attachmentFailed: true返回,不影响文本反馈的成功状态。api.jsonProvider 条目 →[providers.<id>])[services]api.json顶层是同构字典,顶层加元数据会让旧客户端触发无效条目告警;落盘在 Provider 下可避免被 OAuth 登录/登出覆盖,且切换模型时不会跨 Provider 串台上传会话或源码search_url/feedback_url,非空即启用enable子对象[services.moonshot_search]> 当前模型 Providersearch_url> 托管 OAuth 搜索[services.moonshot_search]无条件最高/login会自动落盘带oauth引用的[services.moonshot_search],区分是否携带oauth可同时保留KIMI_WEB_SEARCH_BASE_URL等显式覆盖能力,并避免托管登录遮蔽当前 Provider 的search_urlIFeedbackService收拢文本提交与附件打包上传,只暴露availability与submitcreateUploadUrl/completeUploadISessionExportService、缓存与日志目录都在引擎内;分片上传是提交的内部步骤,收进submit后无需跨层暴露分片接口阅读指南:
packages/oauth/src/custom-registry.ts:api.json解析、刷新落盘与api_key_env端点变更保护。packages/agent-core-v2/src/llm-adapter/model/model-auth.ts:resolveActiveModelProvider统一解析模型与所属 Provider。packages/agent-core-v2/src/app/auth/webSearch/webSearchService.ts:搜索三层优先级。packages/agent-core-v2/src/app/auth/feedbackService.ts:按模型解析feedback_url或托管 OAuth,完成文本提交及session.zip/repo.zip打包分片上传。apps/kimi-code/src/tui/commands/info.ts:只做门控和弹窗,提交走harness.submitFeedback。feedback/{archive,upload,codebase}从apps/kimi-code/src/feedback/平移至packages/agent-core-v2/src/app/auth/feedback/,可以略读。Behavior Changes and Affected Users
search_url的自定义 Provider 模型时调用WebSearch/login自动写入的[services.moonshot_search]托管端点search_url;切回无search_url的模型仍走托管 OAuth 搜索/login登录态与带search_url的自定义注册表配置的所有客户端(TUI、print 模式、desktop/web、VS Code、ACP、SDK)KIMI_WEB_SEARCH_BASE_URL/KIMI_WEB_SEARCH_API_KEY或手写不含oauth的[services.moonshot_search]feedback_url的 Provider 模型提交反馈feedback_url提交文本和附件分片上传feedback_url的自定义注册表模型的 TUI 用户feedback_urlapi_key_env的自定义注册表 Provider 在刷新时上游新增或修改search_url/feedback_urlapi(base_url)变更时报错拦截search_url或feedback_url新增/变更同样报错拦截;上游移除字段允许正常刷新清除api_key_env绑定环境变量密钥的自定义注册表用户api_key_env重新导入核验地址后再恢复packages/agent-core-v2/docs/config-manifest.toml与 SDKProviderConfigSchema[providers."<name>"]无search_url/feedback_urlconfig.toml的客户端及外部配置消费者@moonshot-ai/kimi-code-sdk的KimiAuthFacade.submitFeedback/createFeedbackUploadUrl/completeFeedbackUploadKimiHarness.feedbackAvailability与KimiHarness.submitFeedback调引擎IFeedbackServiceKimiAuthFacade反馈方法的调用方(仓库内仅 TUI 使用,已迁移)KimiHarness.submitFeedback(维护者已在 PR 确认移除旧内部入口)受影响模块与测试覆盖:
@moonshot-ai/kimi-code-oauth:custom-registry.test.ts覆盖导入、刷新移除及api_key_env地址变更拦截。@moonshot-ai/agent-core-v2:test/app/auth/feedback.test.ts与test/app/auth/auth.test.ts覆盖feedback_url/search_url凭证、default_model/default_provider/providerId优先级、provider.env、缺凭证不串到托管地址、无配置时回退托管 OAuth,以及session.zip+repo.zip打包上传与部分失败降级;codebase-upload.test.ts覆盖代码库扫描打包与分片上传。@moonshot-ai/kimi-code:kimi-tui-message-flow.test.ts覆盖 TUI 在引擎报告needs-login/ 抛错 /ready/attachmentFailed时的门控与提示。验证详情
packages/oauth、packages/node-sdk、packages/agent-core-v2、apps/kimi-code相关 9 个测试文件共 874 项测试全部通过。typecheck、lint:imports、oxlint --type-aware零错误。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.