Repository navigation
Conversation
|
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: 39b6487952
ℹ️ 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 baseline = options.tools ?? this.loop.state.profile.tools; | ||
| const visible = options.tools === undefined && baseline !== undefined | ||
| ? this.operationTools(baseline, config.resolved.model.capability) | ||
| : baseline; | ||
| const tools = await this.prepareTools(signal, config.resolved.model.capability, visible); | ||
| const tools = await this.prepareTools(signal, config.resolved.model.capability, baseline); |
There was a problem hiding this comment.
Restore policy filtering for side-request baselines
When the active tool policy or profile allowlist changes after the Loop baseline is captured, prompt prediction and full compaction call prepareOperation without explicit tools, so this now passes the frozen baseline through unchanged. The removed operationTools path filtered that baseline against the current defaultTools, while the replacement resolver only removes deferred tools or select_tools and does not filter ordinary inactive tools. Consequently, newly disallowed tools are disclosed again in these side requests and can make prediction or compaction return an unusable tool call; reapply the current-policy filter before constructing the operation requester.
AGENTS.md reference: AGENTS.md:L206-L208
Useful? React with 👍 / 👎.
| const tools = base ?? []; | ||
| const drop = disclosure | ||
| ? (tool: Tool) => tool.deferred === true | ||
| : (tool: Tool) => tool.name === SELECT_TOOLS_TOOL_NAME; | ||
| return tools.some(drop) ? tools.filter((tool) => !drop(tool)) : tools; |
There was a problem hiding this comment.
Populate non-dynamic requests after deferred MCP discovery
When deferred MCP tools finish asynchronous discovery after the Loop has frozen its initial tool baseline, prepareForRequest updates the ToolSelect catalog but this method only filters the stale base array and never adds those newly discovered declarations. A session starting directly with a model that lacks dynamically_loaded_tools therefore still sends no schema for those deferred MCP tools, even though this change is intended to retain them as ordinary declarations; legalize-tools can strip metadata only from tools that are already present. Merge the reconciled initial deferred declarations into the non-disclosure request view before returning it.
AGENTS.md reference: AGENTS.md:L206-L208
Useful? React with 👍 / 👎.
- unify run boundaries, request summaries, delta events, retries, and outcomes - migrate Loop, agent-core-v2, and klient consumers to the unified event vocabulary - add aimock-backed transport coverage and restore historical LLM behavior tests - update the Nix dependency hash and affected snapshots
- strip deferred metadata during legalize for models without dynamic loading - stop convert from dropping deferred tools and dedupe declarations with top-level priority - merge protocol capabilities once at the encode pipeline entry - remove deferred tools in the dynamic loop resolver and announce their names first
- remove dynamic-only request branching from ToolSelect resolution - keep non-dynamic system schemas out of top-level tools - preserve baseline tools for side requests before capability shaping
- reuse deferred shaping in the resolver and request preview - preserve initial tool announcements in request previews - cover preview parity with deferred tools
39b6487 to
7f31628
Compare
commit: |
|
Superseded by #5142. |
Requirement or Bug
Deferred-tool behavior was split between protocol conversion and ToolSelect resolution. Models without dynamic loading could lose deferred declarations entirely, while main Loop and side requests could derive different tool views and promote selected system schemas into the top-level tool list.
This PR moves deferred handling into the ToolSelect resolver and the LLM legalization boundary, with the same request-view rules for every request path.
Bug Reproduction Steps
For dynamic-loading models, register deferred tools and verify that they are removed from the resolved top-level tools, announced by name, and loaded into system messages through
select_tools.For models without dynamic loading, verify that initial deferred declarations remain callable as ordinary declarations after their metadata is stripped, while
select_toolsand historical dynamic system schemas are removed rather than promoted into the top-level list.Root Cause
convert()used to drop deferred tools during protocol encoding, while the resolver used a separatedynamicToolsbranch for main Loop and side requests. This split ownership made legalization depend on the request path and allowed historical schemas to be copied back intoprofile.tools.The fix centralizes capability-specific disclosure in the resolver and keeps only metadata legalization and duplicate handling in the encoder; it is not a compatibility workaround.
Code Changes
legalize-toolsafter model legalization: removedeferredmetadata for models without dynamic loading, deduplicate declarations with top-level priority, and emit aggregated notices and warnings for removed duplicates.select_toolsand dynamic system schemas without copying those schemas into the top-level tools.dynamic/dynamicToolsbranches so main Loop and side requests use the same resolver and capability shaping.loop.remind, and runtime changes are disclosed through reminders rather than by rewriting the initial tool list.Start with
packages/core/src/llm/protocol/rules/tools.ts,packages/agent-core-v2/src/agent/loop/toolSelectPolicy.ts, andpackages/agent-core-v2/src/agent/toolSelect/toolSelectService.ts.Behavior Changes and Affected Users
select_toolssupplies schemas through remindersdeferredmetadata is strippedprofile.toolsselect_toolsare removed without promotion into the top-level listValidation
After rebasing onto the merged engineering PR:
packages/coreandpackages/agent-core-v2typecheck passed.pnpm lintpassed, including comment, oxlint, import-boundary, guard, ratchet, and instruction checks.Checklist