summaryrefslogtreecommitdiff
path: root/packages/server/src/utils/messageInspectors.ts
diff options
context:
space:
mode:
authorTaylor Mullen <[email protected]>2025-05-26 14:25:31 -0700
committerN. Taylor Mullen <[email protected]>2025-05-26 14:29:24 -0700
commit597dc86a9c7011b7f3288445b14abb11817424da (patch)
tree3c966be056310a53ef0a9e96b835755c8790378e /packages/server/src/utils/messageInspectors.ts
parent480549e02ed4ae01c7df2abbd98bb0eb5b23bdd5 (diff)
Fix(chat): Prevent empty model response after function call
- Addresses a Gemini model bug where it may return an empty content object after a function response. - Previously, the SDK attempted to inject an empty model message, which could disrupt curated history. - This change modifies our custom class to detect this scenario using an utility and avoid pushing an unnecessary empty model message, thus preserving history integrity. Workaround for https://b.corp.google.com/issues/420354090 Part of https://github.com/google-gemini/gemini-cli/issues/551
Diffstat (limited to 'packages/server/src/utils/messageInspectors.ts')
-rw-r--r--packages/server/src/utils/messageInspectors.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/server/src/utils/messageInspectors.ts b/packages/server/src/utils/messageInspectors.ts
new file mode 100644
index 00000000..b2c3cdce
--- /dev/null
+++ b/packages/server/src/utils/messageInspectors.ts
@@ -0,0 +1,15 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { Content } from '@google/genai';
+
+export function isFunctionResponse(content: Content): boolean {
+ return (
+ content.role === 'user' &&
+ !!content.parts &&
+ content.parts.every((part) => !!part.functionResponse)
+ );
+}