Repository navigation
refactor(agent-core-v2): decouple tool disclosure from execution - #4538
Conversation
|
Codex Review SummaryThis 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: 312444662e
ℹ️ 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".
| durationMs: z.number().optional(), | ||
| stopReason: z.string().optional(), | ||
| traceId: z.string().optional(), | ||
| requestId: z.string().optional(), |
There was a problem hiding this comment.
Preserve the legacy traceId field on turn-ended events
When replaying a session written by the previous release, durable turn.ended records contain traceId, while this schema now accepts and emits only requestId; the updated survey recovery consequently drops the identifier, and existing Klient/SDK consumers reading traceId also receive no value despite the PR claiming public event shapes remain unchanged. Emit both fields during the compatibility window and read requestId with a traceId fallback for persisted records.
AGENTS.md reference: AGENTS.md:L111-L113
Useful? React with 👍 / 👎.
| @@ -0,0 +1,264 @@ | |||
| # AgentLoopRequester 职责清单 | |||
There was a problem hiding this comment.
Remove the committed requester planning notes
Delete todo.md from the commit: it is a root-level work-in-progress responsibility checklist containing discussion conclusions, accepted exceptions, and validation notes rather than maintained product documentation. Keeping this exploratory artifact makes stale implementation notes appear authoritative and directly violates the repository rule against staging agent working notes or other throwaway scratch files.
AGENTS.md reference: AGENTS.md:L94-L97
Useful? React with 👍 / 👎.
| const alreadyDegraded = appliedRecoveries.some( | ||
| (recovery) => recovery.strategy === MEDIA_RECOVERY_ID && recovery.action === 'degraded', | ||
| ); | ||
| if (count === 0 && alreadyDegraded) return undefined; |
There was a problem hiding this comment.
Skip media recoveries that cannot rewrite the request
When a request-too-large response occurs with no media, or with at most the two media parts retained by degradation, this condition returns a degraded proposal whose rewrite is undefined; proposeFirst accepts it, so the requester resends the identical request, and stripEntry repeats the same no-op behavior when there is no media. This adds up to two guaranteed duplicate provider calls before the real error surfaces and delays actual stripping for requests with one or two media parts, whereas the old path skipped recoveries that could not change the projection. Return undefined whenever the recovery has nothing to rewrite.
AGENTS.md reference: AGENTS.md:L127-L129
Useful? React with 👍 / 👎.
| const uploaded = await files.upload( | ||
| { ...input, kind: 'image' }, | ||
| { endpoint: await resolveEndpoint(contentsOf(request).endpoint), signal: signal ?? new AbortController().signal }, |
There was a problem hiding this comment.
Preserve no-credential media upload fallbacks
When a Kimi-compatible model has no API key—for example an unauthenticated local proxy that accepts inline images—this new path still exposes an uploader because the endpoint advertises file support, then calls the OpenAI file client with its placeholder Bearer unused credential. If that file endpoint returns 401, the media resolver treats it as a terminal authentication error instead of falling back to inline image data or a video path; the previous KimiFiles implementation failed locally when the key was absent, which allowed those fallbacks to run. Treat an upload with no usable credential as unsupported before making the remote call so no-key sessions retain the old media behavior.
AGENTS.md reference: AGENTS.md:L127-L129
Useful? React with 👍 / 👎.
- replace model requester services with core requester initialization - move media degradation into core recovery and simplify loop projection - update client boundaries, tests, documentation, and the task plan
- run normal projection through a structure resolver - recover structural rejections with a strict request rewrite - keep media recovery composable without persisting strict repairs
- build default tools and shape history in a tool-select resolver - evaluate dynamic tool support from each request's effective model - record resolved tools and preserve recovery composition
- add content-addressed put/get and kimi-file media production - resolve and upload media in the llm policy pipeline - defer provider uploads and preserve recovery and cancellation behavior
- register ReadMediaFile independently of model capabilities and store references on execution - hide unsupported media tool calls and results, then resolve references during requests - preserve legacy image-format recovery and update focused coverage
- record implemented and accepted media behaviors - separate undecided and unreviewed alignment items
- simplify compaction cache diagnostics using response usage - restore provider error classification and abort-safe media metadata - refresh inherited media recovery display paths
- add optional diagnoseError and failed-outcome diagnostics - use requestId across successful responses and error telemetry - update requester tests, documentation, and manifests
- replace pending tool schema state with loop reminders - strip dynamic tool context for models without dynamic loading - remove execution-time model gates and align tests and docs
- initialize tool disclosure once per agent session and persist runtime changes - project initial and runtime tools according to model capabilities - update wire renderers, manifests, and focused coverage
3124446 to
25aa425
Compare
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25aa425b77
ℹ️ 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".
| args.full_resolution === true && | ||
| stat.size > this.inlineImageByteBudget | ||
| stat.size > imageDeliveryLimits.readByteBudget |
There was a problem hiding this comment.
Restore the full-resolution image budget
For default-configured ReadMediaFile users requesting full_resolution: true, this now applies the 256 KiB compression target as a hard limit. The parent instead allowed the provider-specific inline limit—3.75 MiB generally and 5 MiB for Kimi—so images between those thresholds previously retained native resolution but now return an error unless users override image.readByteBudget. Keep the provider limit, or introduce a separate full-resolution limit, rather than reusing the normal compressed-read budget.
AGENTS.md reference: AGENTS.md:L111-L113
Useful? React with 👍 / 👎.
| const reference = await this.attachmentStore.put({ | ||
| bytes: mediaBytes, | ||
| mimeType: mediaMimeType, | ||
| filename: safePath.split(/[\\/]/).at(-1) ?? safePath, |
There was a problem hiding this comment.
Preserve conversion guidance for unsupported image formats
When an image-capable non-Kimi model reads a provider-unsupported format such as HEIC, this now stores the file and reports a successful media result without validating the selected provider. During the next request, resolveImageUncached rejects that MIME and substitutes only a local <image path> tag, so the model receives no image pixels and none of the conversion command that the previous implementation returned as an error. Validate the provider MIME before reporting tool success, or carry the conversion guidance through the resolver fallback.
AGENTS.md reference: AGENTS.md:L127-L129
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 84c8adfe98
ℹ️ 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".
| private defaultToolsForDisclosure(disclosure: boolean): readonly Tool[] { | ||
| const entries = disclosure ? this.capableTools() : this.initialTools(); | ||
| return this.shapeToolsForDisclosure(entries, disclosure).map((tool) => ({ |
There was a problem hiding this comment.
Project live tools for non-disclosure models
When an MCP server reconnects or a plugin adds/removes a tool after the first request, and the active model lacks dynamically_loaded_tools, this branch always projects initialTools() rather than the current registry. Consequently, newly available tools are omitted while removed tools remain advertised; before this refactor, shapeTools() used the live registry even when disclosure was disabled. This contradicts the stated fallback to ordinary tools[] for such models, so use the reconciled current tool set when disclosure is off.
AGENTS.md reference: AGENTS.md:L127-L129
Useful? React with 👍 / 👎.
| const keep = isMcpToolName(tool.name) | ||
| ? this.toolPolicy.isToolActive(tool.name, 'mcp') |
There was a problem hiding this comment.
Drop stale MCP schemas after schema changes
When an MCP server reconnects and re-registers a same-name tool with changed parameters or description, collectLoadedDynamicTools() invalidates the old version, but this MCP-specific branch retains its historical schema solely because the name remains active. The next request therefore still advertises the stale definition even though load() reports the current version as not loaded, and reselection can leave both definitions in history; apply the signature check when the MCP tool is currently registered, reserving name-only retention for disconnected servers.
AGENTS.md reference: AGENTS.md:L127-L129
Useful? React with 👍 / 👎.
Stops before #4538 so the code-app branch can pin a commit that has both this change and the server code code-app main runs on, without the tool-select API change that desktop has not adapted to yet.
Requirement or Bug
统一 Agent LLM 请求所有权,删除平行的 requester / projector Service,同时保持 turn、compaction、media 和 klient direct-generate 的既有调用契约。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
Behavior Changes and Affected Users
公开 klient direct-generate 输入、事件形状和顺序保持不变;除表内明确调整外,既有 wire 事件名称与持久化行为未作额外变更。
验证:agent-core-v2、klient、product typecheck,agent-core build、comment-free、完整 lint(0 errors)通过;本地 select_tools 94/94,远程聚焦 276/276。远程全量 17877 passed / 11 failed / 26 skipped,修正后失败文件复跑剩 8 个既有失败(config 1、Loop 快照 3、plan 快照 2、tool 快照 1、已知子代理中断 1),requester、stateManifest 与 session-import 均恢复通过。
lint:imports仍只有 main 基线已有的human/agent/origin.ts违规。Checklist
gen-changesetsskill, or this PR needs no changeset(任务作者已确认不写).