mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
Preserve app invocation context across MCP tool refreshes (#59991)
## What changed Keep the advertised `_codex_apps.invocation_context` when an app's tool metadata refreshes on the same server connection, while using refreshed values for other metadata. If the invocation context changes on a different connection, skip the call as unavailable. ## Testing Extend the code-mode compaction test to refresh app tools before resuming a cell and verify that calls retain the original invocation context while picking up the refreshed `resource_uri`. GitOrigin-RevId: 1b6072faed74623994ea82035a6ed977451984a4
This commit is contained in:
@@ -284,6 +284,12 @@ impl PreparedMcpCall {
|
||||
self.tool_info.get()
|
||||
}
|
||||
|
||||
/// Whether the server connection that issued the step's tools still owns this call.
|
||||
pub fn uses_connection_from(&self, binding: &McpBinding) -> bool {
|
||||
self.connections
|
||||
.shares_server_connection(&binding.connections, &self.server_name)
|
||||
}
|
||||
|
||||
/// Returns the configuration and approval authority captured with this client.
|
||||
pub fn config(&self) -> &McpConfig {
|
||||
&self.config
|
||||
|
||||
@@ -1195,6 +1195,13 @@ impl McpConnectionSet {
|
||||
self.servers.contains_key(server_name)
|
||||
}
|
||||
|
||||
pub(crate) fn shares_server_connection(&self, other: &Self, server: &str) -> bool {
|
||||
self.servers
|
||||
.get(server)
|
||||
.zip(other.servers.get(server))
|
||||
.is_some_and(|(left, right)| Arc::ptr_eq(&left.connection, &right.connection))
|
||||
}
|
||||
|
||||
pub(crate) async fn authentication_failed_servers(&self) -> Vec<String> {
|
||||
let mut failed_servers = Vec::new();
|
||||
for (server_name, view) in &self.servers {
|
||||
|
||||
@@ -181,13 +181,7 @@ impl McpConnectionSet {
|
||||
}
|
||||
|
||||
fn shares_test_connection_with(&self, other: &Self, name: &str) -> bool {
|
||||
let Some(left) = self.servers.get(name) else {
|
||||
return false;
|
||||
};
|
||||
let Some(right) = other.servers.get(name) else {
|
||||
return false;
|
||||
};
|
||||
Arc::ptr_eq(&left.connection, &right.connection)
|
||||
self.shares_server_connection(other, name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user