Skip to content

Expose selecte namespaces as direct model tools#28825

Merged
won-openai merged 1 commit into
mainfrom
memsup
Jun 18, 2026
Merged

Expose selecte namespaces as direct model tools#28825
won-openai merged 1 commit into
mainfrom
memsup

Conversation

@won-openai

@won-openai won-openai commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Why

Som tools, such as history and notes, must remain top-level when MCP deferral is enabled while staying unavailable through code-mode exec.

What changed

  • Added features.code_mode.direct_only_tool_namespaces.
  • Classified matching MCP tools as DirectModelOnly.
  • Kept those tools top-level in code_mode_only.
  • Excluded them from tool_search deferral and the nested exec surface.
  • Updated the generated config schema.

Validation

  • code_mode_only_exposes_direct_model_only_mcp_namespaces
  • load_config_resolves_code_mode_config

@won-openai won-openai requested a review from a team as a code owner June 18, 2026 01:05
);
let output_tool = dynamic_tool_to_responses_api_tool(tool).ok()?;
let mut output_tool = dynamic_tool_to_responses_api_tool(tool).ok()?;
output_tool.defer_loading = None;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dynamic input currently drives both ToolExposure and ResponsesApiTool.defer_loading. Once the planner promotes a configured deferred runtime to DirectModelOnly, leaving this field set would serialize the now-top-level tool with defer_loading: true even though it has also been removed from tool_search. Clearing it at construction keeps the stored spec direct-shaped; ToolSearchInfo::from_tool_spec adds the marker back only when the tool is actually returned as a deferred search result. A short comment here would make that invariant clearer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks codex lol

maybe comment like // ToolExposure is canonical; tool search adds the wire-level marker for deferred results.

Comment on lines +195 to +217
for runtime in &mut planned_tools.runtimes {
let configured = runtime
.tool_name()
.namespace
.as_ref()
.is_some_and(|namespace| {
turn_context
.config
.code_mode
.direct_only_tool_namespaces
.contains(namespace)
});
match runtime.exposure() {
ToolExposure::Direct | ToolExposure::Deferred if configured => {
*runtime =
override_tool_exposure(Arc::clone(runtime), ToolExposure::DirectModelOnly);
}
ToolExposure::Direct
| ToolExposure::Deferred
| ToolExposure::DirectModelOnly
| ToolExposure::Hidden => {}
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know we're against one-time helpers but i think in this case its warranted; this is logic very specific to this custom config setup and imo it shouldnt pollute build_tool_specs_and_registry

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This is a good exception to the one-use-helper rule because it is self-contained config policy, while build_tool_specs_and_registry should read as orchestration. I would extract apply_direct_model_only_namespace_overrides(turn_context, &mut planned_tools) so the pipeline remains obvious: add sources, apply exposure policy, build tool_search, then build code-mode executors.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@won-openai won-openai changed the title Expose selected MCP namespaces as direct model tools Expose selecte namespaces as direct model tools Jun 18, 2026
@won-openai won-openai enabled auto-merge (squash) June 18, 2026 04:04
@won-openai won-openai merged commit 78a9e16 into main Jun 18, 2026
31 checks passed
@won-openai won-openai deleted the memsup branch June 18, 2026 04:07
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants