mirror of
https://github.com/openai/codex.git
synced 2026-11-22 15:15:18 +00:00
Reuse stable MCP bindings across sampling steps (#37101)
## What changed - Cache an `McpBinding` on each published MCP runtime once server startup has settled and the tool catalog revision is stable. - Reuse the cached binding while the catalog revision remains unchanged, and rebuild it after a runtime publish or catalog change. - Treat terminal failures from optional servers as stable, while continuing to wait for required servers and reconnecting Codex Apps servers. ## Testing - Cover binding reuse within one published runtime and invalidation after a republish. - Cover stability checks for pending, failed optional, required, and reconnected servers. GitOrigin-RevId: 783a6b04897f6c484a6d56fd9cee542814041759
This commit is contained in:
1 parent
5c44f11064
commit
952e87d3f2
6 files changed
+174
-14
No files matched your search
@@ -58,6 +58,32 @@ pub fn tool_is_model_visible(tool: &ToolInfo) -> bool {
|
||||
}
|
||||
|
||||
impl McpConnectionSet {
|
||||
pub(crate) async fn stable_catalog_revision(&self) -> Option<u64> {
|
||||
for (server_name, view) in &self.servers {
|
||||
if !view
|
||||
.connection
|
||||
.client
|
||||
.startup_complete
|
||||
.load(Ordering::Acquire)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let Some(client) = view.connection.client.ready_transport() else {
|
||||
if !view.connection.client.is_codex_apps_mcp_server
|
||||
&& self.required_servers.binary_search(server_name).is_err()
|
||||
&& matches!(view.connection.client.client.peek(), Some(Err(_)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return None;
|
||||
};
|
||||
if client.is_closed().await {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some(*self.tool_catalog_revision.read().await)
|
||||
}
|
||||
|
||||
/// Returns all tools with model-visible names normalized.
|
||||
#[instrument(level = "trace", skip_all, fields(mcp_server_count = self.servers.len()))]
|
||||
pub async fn list_all_tools(&self) -> Vec<ToolInfo> {
|
||||
|
||||
Reference in new issue
Block a user