mirror of
https://github.com/openai/codex.git
synced 2026-11-21 07:09:23 +00:00
Include app link metadata in MCP approval elicitations (#42134)
## What changed - Preserve the selected app account `link_id` when building native MCP tool approval requests. - Add `link_id` and `link_is_implicit` to the elicitation metadata, recognizing IDs with the reserved `implicit_link::` prefix as implicit links. ## Testing - Extend the app link policy integration test to verify elicitation metadata for default, explicitly selected, and implicit account links. GitOrigin-RevId: a76731d9f5f3640318187511ccdc0dc82967a9c5
This commit is contained in:
1 parent
2393b5c920
commit
a30fa3d830
2 files changed
+43
-11
No files matched your search
@@ -1178,6 +1178,7 @@ impl Session {
|
||||
const MCP_TOOL_OPENAI_OUTPUT_TEMPLATE_META_KEY: &str = "openai/outputTemplate";
|
||||
const MCP_TOOL_UI_RESOURCE_URI_META_KEY: &str = "ui/resourceUri";
|
||||
const MCP_TOOL_LINK_ID_META_KEY: &str = "link_id";
|
||||
const MCP_TOOL_LINK_IS_IMPLICIT_META_KEY: &str = "link_is_implicit";
|
||||
const MCP_TOOL_PLUGIN_ID_META_KEY: &str = "plugin_id";
|
||||
const MCP_TOOL_ITEM_ID_META_KEY: &str = "itemId";
|
||||
const MCP_TOOL_THREAD_ID_META_KEY: &str = "threadId";
|
||||
@@ -1567,10 +1568,14 @@ pub(crate) async fn request_mcp_tool_user_approval(
|
||||
.map(|rendered_template| rendered_template.question.as_str()),
|
||||
);
|
||||
if tool_call_mcp_elicitation_enabled {
|
||||
let link_id = sess
|
||||
.mcp_tool_approval_metadata(&turn_context.sub_id, id)
|
||||
.await
|
||||
.and_then(|(_, metadata)| metadata.link_id);
|
||||
let metadata = McpToolApprovalMetadata {
|
||||
annotations: None,
|
||||
connector_id: connector_id.clone(),
|
||||
link_id: None,
|
||||
link_id,
|
||||
connector_name: connector_name.clone(),
|
||||
connector_description: connector_description.clone(),
|
||||
connected_account_email: connected_account_email.clone(),
|
||||
@@ -1918,6 +1923,17 @@ fn build_mcp_tool_approval_elicitation_meta(
|
||||
serde_json::Value::String(connector_id.to_string()),
|
||||
);
|
||||
}
|
||||
if let Some(link_id) = metadata.link_id.as_ref() {
|
||||
meta.insert(
|
||||
MCP_TOOL_LINK_ID_META_KEY.to_string(),
|
||||
serde_json::Value::String(link_id.clone()),
|
||||
);
|
||||
// Match the Codex Apps service's reserved implicit-link ID prefix.
|
||||
meta.insert(
|
||||
MCP_TOOL_LINK_IS_IMPLICIT_META_KEY.to_string(),
|
||||
serde_json::Value::Bool(link_id.starts_with("implicit_link::")),
|
||||
);
|
||||
}
|
||||
if let Some(connector_name) = metadata.connector_name.as_ref() {
|
||||
meta.insert(
|
||||
MCP_TOOL_APPROVAL_CONNECTOR_NAME_KEY.to_string(),
|
||||
|
||||
Reference in new issue
Block a user