From 7224d4c8d10b73c7c67b1b198c15f6eee168c9db Mon Sep 17 00:00:00 2001 From: "Blessing Jones, Joshua Divine" Date: Tue, 24 Nov 2026 20:48:52 +0530 Subject: [PATCH] fix: only send google_interactions_replay_available to Vertex engines The flag was added to the request for every model on the OpenAI and Anthropic compatible endpoints. Non-Vertex engines (e.g. GPT) forward it to the provider, which rejects it and returns a masked 500 (empty stream when stream=true). Set it and run the Google Interactions sidecar only for Vertex engines, and skip preserveInteractions when the flag is absent. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../web/services/local/AnthropicEndpoints.java | 12 ++++++++++-- .../web/services/local/OpenAIEndpoints.java | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/prerna/semoss/web/services/local/AnthropicEndpoints.java b/src/prerna/semoss/web/services/local/AnthropicEndpoints.java index 187c7471..326b9359 100644 --- a/src/prerna/semoss/web/services/local/AnthropicEndpoints.java +++ b/src/prerna/semoss/web/services/local/AnthropicEndpoints.java @@ -64,6 +64,7 @@ import prerna.auth.User; import prerna.auth.utils.SecurityEngineUtils; import prerna.engine.api.IModelEngine; +import prerna.engine.api.ModelTypeEnum; import prerna.engine.impl.model.AbstractModelEngine; import prerna.engine.impl.model.ModelPixelInvoker; import prerna.engine.impl.model.Room; @@ -288,9 +289,16 @@ public Response createMessage(@Context HttpServletRequest request, @Context Http // can re-attach them to replayed tool_use blocks. Empty map for non-Vertex // paths (no file written) - no-op then. Map thoughtSigMap = ThoughtSignatureSidecar.load(room.getRoomFolderPath()); - boolean interactionReplay = engine.keepInputOutput() && engine.keepsConversationHistory() + // Google Interactions replay is a Vertex-only feature. Only set the flag and + // run the sidecar for Vertex engines; any other engine must not get the + // parameter, or it leaks to that provider's API through the compatibility + // endpoint and the request is rejected. + boolean isVertex = engine.getModelType() == ModelTypeEnum.VERTEX; + boolean interactionReplay = isVertex && engine.keepInputOutput() && engine.keepsConversationHistory() && !"false".equalsIgnoreCase(String.valueOf(dataMap.get("use_history"))); - dataMap.put("google_interactions_replay_available", interactionReplay); + if (isVertex) { + dataMap.put("google_interactions_replay_available", interactionReplay); + } // HANDLE NON-STREAMING REQUESTS THROUGH THE LLM PIXEL if (!isStreamingRequest) { diff --git a/src/prerna/semoss/web/services/local/OpenAIEndpoints.java b/src/prerna/semoss/web/services/local/OpenAIEndpoints.java index 3ccdaa5c..c63e280e 100644 --- a/src/prerna/semoss/web/services/local/OpenAIEndpoints.java +++ b/src/prerna/semoss/web/services/local/OpenAIEndpoints.java @@ -68,6 +68,7 @@ import prerna.auth.User; import prerna.auth.utils.SecurityEngineUtils; import prerna.engine.api.IModelEngine; +import prerna.engine.api.ModelTypeEnum; import prerna.engine.impl.model.AbstractModelEngine; import prerna.engine.impl.model.ModelPixelInvoker; import prerna.engine.impl.model.Room; @@ -447,9 +448,16 @@ private static List> restoreInteractions(IModelEngine engine message.remove(GoogleInteractionsState.KEY); messages.add(message); } - boolean replay = engine.keepInputOutput() && engine.keepsConversationHistory() + // Google Interactions replay is a Vertex-only feature. Only set the flag and + // run the sidecar for Vertex engines; any other engine (OpenAI, Anthropic, ...) + // must not get the parameter, or it leaks to that provider's API through the + // OpenAI-compatibility endpoint and the request is rejected. + boolean isVertex = engine.getModelType() == ModelTypeEnum.VERTEX; + boolean replay = isVertex && engine.keepInputOutput() && engine.keepsConversationHistory() && !"false".equalsIgnoreCase(String.valueOf(parameters.get("use_history"))); - parameters.put("google_interactions_replay_available", replay); + if (isVertex) { + parameters.put("google_interactions_replay_available", replay); + } if (replay) { ThoughtSignatureSidecar.restoreInteractions(room.getRoomFolderPath(), messages); } @@ -471,6 +479,11 @@ private static void preserveInteractions(Room room, Map paramete @SuppressWarnings("unchecked") private static void preserveInteractions(Room room, Map parameters, Map assistant, Object state) throws IOException { + // Non-Vertex engines never carry this flag (restoreInteractions only sets it for + // Vertex), so there is nothing to preserve: skip cleanly rather than error. + if (!parameters.containsKey("google_interactions_replay_available")) { + return; + } if (!Boolean.TRUE.equals(parameters.get("google_interactions_replay_available"))) { throw new IOException("Room retention settings prevent preserving Google Interactions history"); }