Skip to content

feat: dynamic tools injection#9539

Merged
jif-oai merged 16 commits intomainfrom
jif/dynamic-tools
Jan 26, 2026
Merged

feat: dynamic tools injection#9539
jif-oai merged 16 commits intomainfrom
jif/dynamic-tools

Conversation

@jif-oai
Copy link
Collaborator

@jif-oai jif-oai commented Jan 20, 2026

Summary

Add dynamic tool injection to thread startup in API v2, wire dynamic tool calls through the app server to clients, and plumb responses back into the model tool pipeline.

Flow (high level)

  • Thread start injects dynamic_tools into the model tool list for that thread (validation is done here).
  • When the model emits a tool call for one of those names, core raises a DynamicToolCallRequest event.
  • The app server forwards it to the client as item/tool/call, waits for the client’s response, then submits a DynamicToolResponse back to core.
  • Core turns that into a function_call_output in the next model request so the model can continue.

What changed

  • Added dynamic tool specs to v2 thread start params and protocol types; introduced item/tool/call (request/response) for dynamic tool execution.
  • Core now registers dynamic tool specs at request time and routes those calls via a new dynamic tool handler.
  • App server validates tool names/schemas, forwards dynamic tool call requests to clients, and publishes tool outputs back into the session.
  • Integration tests

@jif-oai
Copy link
Collaborator Author

jif-oai commented Jan 21, 2026

@codex review

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d62269ea2

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Conflicts:
#	codex-rs/tui/src/chatwidget.rs
# Conflicts:
#	codex-rs/tui2/src/chatwidget.rs
# Conflicts:
#	codex-rs/app-server-protocol/src/protocol/v2.rs
#	codex-rs/app-server/README.md
#	codex-rs/app-server/src/codex_message_processor.rs
# Conflicts:
#	codex-rs/app-server-protocol/src/protocol/v2.rs
#	codex-rs/app-server/src/codex_message_processor.rs
#	codex-rs/core/src/thread_manager.rs
@jif-oai
Copy link
Collaborator Author

jif-oai commented Jan 25, 2026

Will fix the merge ofc

Copy link
Collaborator

@dylan-hurd-oai dylan-hurd-oai left a comment

Choose a reason for hiding this comment

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

1 suggestion for specs, otherwise really like the approach!

fn dynamic_tool_to_openai_tool(
tool: &DynamicToolSpec,
) -> Result<ResponsesApiTool, serde_json::Error> {
let input_schema = parse_tool_input_schema(&tool.input_schema)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit worried that RESERVED_DYNAMIC_TOOL_NAMES will drift - should we check for conflicts/duplicates at runtime, or add a test to assert that all built-in tool names are covered by the list?

@jif-oai jif-oai merged commit d594693 into main Jan 26, 2026
32 checks passed
@jif-oai jif-oai deleted the jif/dynamic-tools branch January 26, 2026 10:06
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 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