mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Support structured dynamic tool results in Code Mode (#63766)
## Why Dynamic tool clients could return JSON as text in `contentItems`, so Code Mode scripts had to parse that text to access fields in the result. ## What changed App server dynamic tool requests advertise `supportedResultFormat: "structuredContent"`. Clients can reply with `structuredContent` and a `success` flag, report a failure with `errorMessage` and `success: false`, or continue using `contentItems`. Code Mode exposes structured replies as MCP-style tool results, with the original JSON under `structuredContent` and failure status in `isError`. Completed tool items include a text representation of the reply. Matching post-tool-use hooks can receive the structured result for successful calls. ## Testing Add protocol tests for the wire formats and rejection of ambiguous replies, plus an app server integration test that exercises structured results, content items, and errors through Code Mode. GitOrigin-RevId: d63152633b43bd5bd236f6e0dcb41ee7e98e7947
This commit is contained in:
@@ -263,6 +263,17 @@ impl Hooks {
|
||||
self.engine.max_permission_request_timeout()
|
||||
}
|
||||
|
||||
/// Check the same names used by PostToolUse before preparing a large tool response.
|
||||
pub fn has_post_tool_use_match(&self, name: &str, aliases: &[String]) -> bool {
|
||||
let inputs = crate::events::common::matcher_inputs(name, aliases);
|
||||
!crate::engine::dispatcher::select_handlers_for_matcher_inputs(
|
||||
&self.engine.handlers,
|
||||
HookEventName::PostToolUse,
|
||||
&inputs,
|
||||
)
|
||||
.is_empty()
|
||||
}
|
||||
|
||||
pub fn preview_post_tool_use(
|
||||
&self,
|
||||
request: &PostToolUseRequest,
|
||||
|
||||
Reference in New Issue
Block a user