@google/gemini-cli-core 0.1.12 → 0.1.13-nightly.250727.3e81359c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/README.md +30 -3
  2. package/dist/google-gemini-cli-core-0.1.13.tgz +0 -0
  3. package/dist/src/code_assist/codeAssist.js +2 -2
  4. package/dist/src/code_assist/codeAssist.js.map +1 -1
  5. package/dist/src/code_assist/oauth2.js +46 -5
  6. package/dist/src/code_assist/oauth2.js.map +1 -1
  7. package/dist/src/code_assist/oauth2.test.js +107 -10
  8. package/dist/src/code_assist/oauth2.test.js.map +1 -1
  9. package/dist/src/code_assist/server.d.ts +4 -6
  10. package/dist/src/code_assist/server.js +4 -69
  11. package/dist/src/code_assist/server.js.map +1 -1
  12. package/dist/src/code_assist/server.test.js +10 -2
  13. package/dist/src/code_assist/server.test.js.map +1 -1
  14. package/dist/src/code_assist/setup.d.ts +6 -1
  15. package/dist/src/code_assist/setup.js +4 -1
  16. package/dist/src/code_assist/setup.js.map +1 -1
  17. package/dist/src/code_assist/setup.test.js +4 -1
  18. package/dist/src/code_assist/setup.test.js.map +1 -1
  19. package/dist/src/code_assist/types.d.ts +2 -2
  20. package/dist/src/config/config.d.ts +55 -11
  21. package/dist/src/config/config.js +85 -33
  22. package/dist/src/config/config.js.map +1 -1
  23. package/dist/src/config/config.test.js +29 -26
  24. package/dist/src/config/config.test.js.map +1 -1
  25. package/dist/src/config/flashFallback.test.js +1 -1
  26. package/dist/src/config/flashFallback.test.js.map +1 -1
  27. package/dist/src/core/client.d.ts +8 -3
  28. package/dist/src/core/client.js +62 -3
  29. package/dist/src/core/client.js.map +1 -1
  30. package/dist/src/core/client.test.js +145 -37
  31. package/dist/src/core/client.test.js.map +1 -1
  32. package/dist/src/core/contentGenerator.d.ts +3 -2
  33. package/dist/src/core/contentGenerator.js +5 -4
  34. package/dist/src/core/contentGenerator.js.map +1 -1
  35. package/dist/src/core/contentGenerator.test.js +12 -5
  36. package/dist/src/core/contentGenerator.test.js.map +1 -1
  37. package/dist/src/core/coreToolScheduler.js +14 -1
  38. package/dist/src/core/coreToolScheduler.js.map +1 -1
  39. package/dist/src/core/coreToolScheduler.test.js +84 -2
  40. package/dist/src/core/coreToolScheduler.test.js.map +1 -1
  41. package/dist/src/core/geminiChat.d.ts +4 -3
  42. package/dist/src/core/geminiChat.js +8 -11
  43. package/dist/src/core/geminiChat.js.map +1 -1
  44. package/dist/src/core/geminiRequest.js +2 -37
  45. package/dist/src/core/geminiRequest.js.map +1 -1
  46. package/dist/src/core/logger.js +6 -0
  47. package/dist/src/core/logger.js.map +1 -1
  48. package/dist/src/core/logger.test.js +1 -1
  49. package/dist/src/core/logger.test.js.map +1 -1
  50. package/dist/src/core/modelCheck.d.ts +1 -1
  51. package/dist/src/core/modelCheck.js +10 -3
  52. package/dist/src/core/modelCheck.js.map +1 -1
  53. package/dist/src/core/nonInteractiveToolExecutor.test.js +8 -5
  54. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
  55. package/dist/src/core/prompts.js +42 -18
  56. package/dist/src/core/prompts.js.map +1 -1
  57. package/dist/src/core/prompts.test.js +121 -4
  58. package/dist/src/core/prompts.test.js.map +1 -1
  59. package/dist/src/core/turn.d.ts +12 -3
  60. package/dist/src/core/turn.js +10 -0
  61. package/dist/src/core/turn.js.map +1 -1
  62. package/dist/src/core/turn.test.js +129 -0
  63. package/dist/src/core/turn.test.js.map +1 -1
  64. package/dist/src/ide/ide-client.d.ts +28 -0
  65. package/dist/src/ide/ide-client.js +88 -0
  66. package/dist/src/ide/ide-client.js.map +1 -0
  67. package/dist/src/ide/ideContext.d.ts +174 -0
  68. package/dist/src/ide/ideContext.js +101 -0
  69. package/dist/src/ide/ideContext.js.map +1 -0
  70. package/dist/src/ide/ideContext.test.js +111 -0
  71. package/dist/src/ide/ideContext.test.js.map +1 -0
  72. package/dist/src/index.d.ts +15 -0
  73. package/dist/src/index.js +17 -0
  74. package/dist/src/index.js.map +1 -1
  75. package/dist/src/mcp/google-auth-provider.d.ts +23 -0
  76. package/dist/src/mcp/google-auth-provider.js +63 -0
  77. package/dist/src/mcp/google-auth-provider.js.map +1 -0
  78. package/dist/src/mcp/google-auth-provider.test.d.ts +6 -0
  79. package/dist/src/mcp/google-auth-provider.test.js +54 -0
  80. package/dist/src/mcp/google-auth-provider.test.js.map +1 -0
  81. package/dist/src/mcp/oauth-provider.d.ts +142 -0
  82. package/dist/src/mcp/oauth-provider.js +446 -0
  83. package/dist/src/mcp/oauth-provider.js.map +1 -0
  84. package/dist/src/mcp/oauth-provider.test.d.ts +6 -0
  85. package/dist/src/mcp/oauth-provider.test.js +520 -0
  86. package/dist/src/mcp/oauth-provider.test.js.map +1 -0
  87. package/dist/src/mcp/oauth-token-storage.d.ts +81 -0
  88. package/dist/src/mcp/oauth-token-storage.js +149 -0
  89. package/dist/src/mcp/oauth-token-storage.js.map +1 -0
  90. package/dist/src/mcp/oauth-token-storage.test.d.ts +6 -0
  91. package/dist/src/mcp/oauth-token-storage.test.js +205 -0
  92. package/dist/src/mcp/oauth-token-storage.test.js.map +1 -0
  93. package/dist/src/mcp/oauth-utils.d.ts +109 -0
  94. package/dist/src/mcp/oauth-utils.js +183 -0
  95. package/dist/src/mcp/oauth-utils.js.map +1 -0
  96. package/dist/src/mcp/oauth-utils.test.d.ts +6 -0
  97. package/dist/src/mcp/oauth-utils.test.js +144 -0
  98. package/dist/src/mcp/oauth-utils.test.js.map +1 -0
  99. package/dist/src/prompts/mcp-prompts.d.ts +8 -0
  100. package/dist/src/prompts/mcp-prompts.js +13 -0
  101. package/dist/src/prompts/mcp-prompts.js.map +1 -0
  102. package/dist/src/prompts/prompt-registry.d.ts +26 -0
  103. package/dist/src/prompts/prompt-registry.js +47 -0
  104. package/dist/src/prompts/prompt-registry.js.map +1 -0
  105. package/dist/src/services/fileDiscoveryService.test.js +101 -60
  106. package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
  107. package/dist/src/services/gitService.js +1 -5
  108. package/dist/src/services/gitService.js.map +1 -1
  109. package/dist/src/services/gitService.test.js +68 -92
  110. package/dist/src/services/gitService.test.js.map +1 -1
  111. package/dist/src/services/loopDetectionService.d.ts +94 -0
  112. package/dist/src/services/loopDetectionService.js +318 -0
  113. package/dist/src/services/loopDetectionService.js.map +1 -0
  114. package/dist/src/services/loopDetectionService.test.d.ts +6 -0
  115. package/dist/src/services/loopDetectionService.test.js +266 -0
  116. package/dist/src/services/loopDetectionService.test.js.map +1 -0
  117. package/dist/src/services/shellExecutionService.d.ts +70 -0
  118. package/dist/src/services/shellExecutionService.js +152 -0
  119. package/dist/src/services/shellExecutionService.js.map +1 -0
  120. package/dist/src/services/shellExecutionService.test.d.ts +6 -0
  121. package/dist/src/services/shellExecutionService.test.js +258 -0
  122. package/dist/src/services/shellExecutionService.test.js.map +1 -0
  123. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +5 -1
  124. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +69 -4
  125. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
  126. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +4 -1
  127. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +9 -0
  128. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
  129. package/dist/src/telemetry/constants.d.ts +1 -0
  130. package/dist/src/telemetry/constants.js +1 -0
  131. package/dist/src/telemetry/constants.js.map +1 -1
  132. package/dist/src/telemetry/file-exporters.d.ts +28 -0
  133. package/dist/src/telemetry/file-exporters.js +62 -0
  134. package/dist/src/telemetry/file-exporters.js.map +1 -0
  135. package/dist/src/telemetry/integration.test.circular.d.ts +6 -0
  136. package/dist/src/telemetry/integration.test.circular.js +53 -0
  137. package/dist/src/telemetry/integration.test.circular.js.map +1 -0
  138. package/dist/src/telemetry/loggers.d.ts +3 -1
  139. package/dist/src/telemetry/loggers.js +34 -2
  140. package/dist/src/telemetry/loggers.js.map +1 -1
  141. package/dist/src/telemetry/loggers.test.circular.d.ts +6 -0
  142. package/dist/src/telemetry/loggers.test.circular.js +100 -0
  143. package/dist/src/telemetry/loggers.test.circular.js.map +1 -0
  144. package/dist/src/telemetry/sdk.js +17 -6
  145. package/dist/src/telemetry/sdk.js.map +1 -1
  146. package/dist/src/telemetry/types.d.ts +19 -1
  147. package/dist/src/telemetry/types.js +28 -0
  148. package/dist/src/telemetry/types.js.map +1 -1
  149. package/dist/src/telemetry/uiTelemetry.d.ts +1 -0
  150. package/dist/src/telemetry/uiTelemetry.js +7 -0
  151. package/dist/src/telemetry/uiTelemetry.js.map +1 -1
  152. package/dist/src/telemetry/uiTelemetry.test.js +92 -0
  153. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
  154. package/dist/src/tools/edit.d.ts +7 -12
  155. package/dist/src/tools/edit.js +34 -32
  156. package/dist/src/tools/edit.js.map +1 -1
  157. package/dist/src/tools/edit.test.js +12 -0
  158. package/dist/src/tools/edit.test.js.map +1 -1
  159. package/dist/src/tools/glob.d.ts +1 -14
  160. package/dist/src/tools/glob.js +13 -36
  161. package/dist/src/tools/glob.js.map +1 -1
  162. package/dist/src/tools/glob.test.js +11 -7
  163. package/dist/src/tools/glob.test.js.map +1 -1
  164. package/dist/src/tools/grep.d.ts +3 -6
  165. package/dist/src/tools/grep.js +12 -18
  166. package/dist/src/tools/grep.js.map +1 -1
  167. package/dist/src/tools/grep.test.js +9 -6
  168. package/dist/src/tools/grep.test.js.map +1 -1
  169. package/dist/src/tools/ls.d.ts +6 -14
  170. package/dist/src/tools/ls.js +47 -40
  171. package/dist/src/tools/ls.js.map +1 -1
  172. package/dist/src/tools/mcp-client.d.ts +83 -1
  173. package/dist/src/tools/mcp-client.js +613 -148
  174. package/dist/src/tools/mcp-client.js.map +1 -1
  175. package/dist/src/tools/mcp-client.test.js +211 -616
  176. package/dist/src/tools/mcp-client.test.js.map +1 -1
  177. package/dist/src/tools/mcp-tool.d.ts +11 -5
  178. package/dist/src/tools/mcp-tool.js +34 -10
  179. package/dist/src/tools/mcp-tool.js.map +1 -1
  180. package/dist/src/tools/mcp-tool.test.js +74 -24
  181. package/dist/src/tools/mcp-tool.test.js.map +1 -1
  182. package/dist/src/tools/memoryTool.js +2 -2
  183. package/dist/src/tools/memoryTool.js.map +1 -1
  184. package/dist/src/tools/modifiable-tool.test.js +51 -62
  185. package/dist/src/tools/modifiable-tool.test.js.map +1 -1
  186. package/dist/src/tools/read-file.d.ts +3 -3
  187. package/dist/src/tools/read-file.js +10 -10
  188. package/dist/src/tools/read-file.js.map +1 -1
  189. package/dist/src/tools/read-file.test.js +100 -70
  190. package/dist/src/tools/read-file.test.js.map +1 -1
  191. package/dist/src/tools/read-many-files.d.ts +6 -10
  192. package/dist/src/tools/read-many-files.js +74 -43
  193. package/dist/src/tools/read-many-files.js.map +1 -1
  194. package/dist/src/tools/read-many-files.test.js +7 -3
  195. package/dist/src/tools/read-many-files.test.js.map +1 -1
  196. package/dist/src/tools/shell.d.ts +3 -23
  197. package/dist/src/tools/shell.js +169 -293
  198. package/dist/src/tools/shell.js.map +1 -1
  199. package/dist/src/tools/shell.test.js +255 -333
  200. package/dist/src/tools/shell.test.js.map +1 -1
  201. package/dist/src/tools/tool-registry.d.ts +13 -2
  202. package/dist/src/tools/tool-registry.js +57 -10
  203. package/dist/src/tools/tool-registry.js.map +1 -1
  204. package/dist/src/tools/tool-registry.test.js +112 -41
  205. package/dist/src/tools/tool-registry.test.js.map +1 -1
  206. package/dist/src/tools/tools.d.ts +37 -2
  207. package/dist/src/tools/tools.js +25 -2
  208. package/dist/src/tools/tools.js.map +1 -1
  209. package/dist/src/tools/web-fetch.js +7 -2
  210. package/dist/src/tools/web-fetch.js.map +1 -1
  211. package/dist/src/tools/web-fetch.test.js +1 -0
  212. package/dist/src/tools/web-fetch.test.js.map +1 -1
  213. package/dist/src/tools/web-search.js +2 -2
  214. package/dist/src/tools/web-search.js.map +1 -1
  215. package/dist/src/tools/write-file.d.ts +0 -8
  216. package/dist/src/tools/write-file.js +14 -23
  217. package/dist/src/tools/write-file.js.map +1 -1
  218. package/dist/src/utils/bfsFileSearch.d.ts +2 -0
  219. package/dist/src/utils/bfsFileSearch.js +4 -1
  220. package/dist/src/utils/bfsFileSearch.js.map +1 -1
  221. package/dist/src/utils/bfsFileSearch.test.js +108 -105
  222. package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
  223. package/dist/src/utils/browser.d.ts +13 -0
  224. package/dist/src/utils/browser.js +49 -0
  225. package/dist/src/utils/browser.js.map +1 -0
  226. package/dist/src/utils/editCorrector.js +4 -4
  227. package/dist/src/utils/editCorrector.js.map +1 -1
  228. package/dist/src/utils/editCorrector.test.js +1 -1
  229. package/dist/src/utils/editor.js +16 -10
  230. package/dist/src/utils/editor.js.map +1 -1
  231. package/dist/src/utils/editor.test.js +128 -28
  232. package/dist/src/utils/editor.test.js.map +1 -1
  233. package/dist/src/utils/errorReporting.d.ts +1 -1
  234. package/dist/src/utils/errorReporting.js +2 -2
  235. package/dist/src/utils/errorReporting.js.map +1 -1
  236. package/dist/src/utils/errorReporting.test.js +44 -38
  237. package/dist/src/utils/errorReporting.test.js.map +1 -1
  238. package/dist/src/utils/errors.js +4 -4
  239. package/dist/src/utils/errors.js.map +1 -1
  240. package/dist/src/utils/fileUtils.d.ts +4 -4
  241. package/dist/src/utils/fileUtils.js +33 -17
  242. package/dist/src/utils/fileUtils.js.map +1 -1
  243. package/dist/src/utils/fileUtils.test.js +37 -37
  244. package/dist/src/utils/fileUtils.test.js.map +1 -1
  245. package/dist/src/utils/formatters.d.ts +6 -0
  246. package/dist/src/utils/formatters.js +16 -0
  247. package/dist/src/utils/formatters.js.map +1 -0
  248. package/dist/src/utils/getFolderStructure.d.ts +3 -2
  249. package/dist/src/utils/getFolderStructure.js +27 -28
  250. package/dist/src/utils/getFolderStructure.js.map +1 -1
  251. package/dist/src/utils/getFolderStructure.test.js +169 -187
  252. package/dist/src/utils/getFolderStructure.test.js.map +1 -1
  253. package/dist/src/utils/gitIgnoreParser.js +4 -7
  254. package/dist/src/utils/gitIgnoreParser.js.map +1 -1
  255. package/dist/src/utils/gitIgnoreParser.test.js +70 -61
  256. package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
  257. package/dist/src/utils/memoryDiscovery.d.ts +2 -1
  258. package/dist/src/utils/memoryDiscovery.js +11 -5
  259. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  260. package/dist/src/utils/memoryDiscovery.test.js +160 -371
  261. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  262. package/dist/src/utils/partUtils.d.ts +14 -0
  263. package/dist/src/utils/partUtils.js +65 -0
  264. package/dist/src/utils/partUtils.js.map +1 -0
  265. package/dist/src/utils/partUtils.test.d.ts +6 -0
  266. package/dist/src/utils/partUtils.test.js +130 -0
  267. package/dist/src/utils/partUtils.test.js.map +1 -0
  268. package/dist/src/utils/paths.d.ts +11 -0
  269. package/dist/src/utils/paths.js +17 -1
  270. package/dist/src/utils/paths.js.map +1 -1
  271. package/dist/src/utils/quotaErrorDetection.js +2 -11
  272. package/dist/src/utils/quotaErrorDetection.js.map +1 -1
  273. package/dist/src/utils/retry.d.ts +6 -0
  274. package/dist/src/utils/retry.js +2 -2
  275. package/dist/src/utils/retry.js.map +1 -1
  276. package/dist/src/utils/safeJsonStringify.d.ts +13 -0
  277. package/dist/src/utils/safeJsonStringify.js +25 -0
  278. package/dist/src/utils/safeJsonStringify.js.map +1 -0
  279. package/dist/src/utils/safeJsonStringify.test.d.ts +6 -0
  280. package/dist/src/utils/safeJsonStringify.test.js +61 -0
  281. package/dist/src/utils/safeJsonStringify.test.js.map +1 -0
  282. package/dist/src/utils/schemaValidator.d.ts +1 -1
  283. package/dist/src/utils/schemaValidator.js +6 -3
  284. package/dist/src/utils/schemaValidator.js.map +1 -1
  285. package/dist/src/utils/shell-utils.d.ts +44 -0
  286. package/dist/src/utils/shell-utils.js +243 -0
  287. package/dist/src/utils/shell-utils.js.map +1 -0
  288. package/dist/src/utils/shell-utils.test.d.ts +6 -0
  289. package/dist/src/utils/shell-utils.test.js +450 -0
  290. package/dist/src/utils/shell-utils.test.js.map +1 -0
  291. package/dist/src/utils/summarizer.d.ts +1 -1
  292. package/dist/src/utils/summarizer.js +11 -39
  293. package/dist/src/utils/summarizer.js.map +1 -1
  294. package/dist/src/utils/summarizer.test.js +1 -1
  295. package/dist/src/utils/systemEncoding.d.ts +40 -0
  296. package/dist/src/utils/systemEncoding.js +149 -0
  297. package/dist/src/utils/systemEncoding.js.map +1 -0
  298. package/dist/src/utils/systemEncoding.test.d.ts +6 -0
  299. package/dist/src/utils/systemEncoding.test.js +368 -0
  300. package/dist/src/utils/systemEncoding.test.js.map +1 -0
  301. package/dist/src/utils/textUtils.d.ts +13 -0
  302. package/dist/src/utils/textUtils.js +28 -0
  303. package/dist/src/utils/textUtils.js.map +1 -0
  304. package/dist/tsconfig.tsbuildinfo +1 -1
  305. package/package.json +4 -3
  306. package/dist/google-gemini-cli-core-0.1.11.tgz +0 -0
  307. package/dist/src/core/geminiRequest.test.js +0 -72
  308. package/dist/src/core/geminiRequest.test.js.map +0 -1
  309. /package/dist/src/{core/geminiRequest.test.d.ts → ide/ideContext.test.d.ts} +0 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ServerGeminiStreamEvent } from '../core/turn.js';
7
+ import { Config } from '../config/config.js';
8
+ /**
9
+ * Service for detecting and preventing infinite loops in AI responses.
10
+ * Monitors tool call repetitions and content sentence repetitions.
11
+ */
12
+ export declare class LoopDetectionService {
13
+ private readonly config;
14
+ private promptId;
15
+ private lastToolCallKey;
16
+ private toolCallRepetitionCount;
17
+ private streamContentHistory;
18
+ private contentStats;
19
+ private lastContentIndex;
20
+ private loopDetected;
21
+ private turnsInCurrentPrompt;
22
+ private llmCheckInterval;
23
+ private lastCheckTurn;
24
+ constructor(config: Config);
25
+ private getToolCallKey;
26
+ /**
27
+ * Processes a stream event and checks for loop conditions.
28
+ * @param event - The stream event to process
29
+ * @returns true if a loop is detected, false otherwise
30
+ */
31
+ addAndCheck(event: ServerGeminiStreamEvent): boolean;
32
+ /**
33
+ * Signals the start of a new turn in the conversation.
34
+ *
35
+ * This method increments the turn counter and, if specific conditions are met,
36
+ * triggers an LLM-based check to detect potential conversation loops. The check
37
+ * is performed periodically based on the `llmCheckInterval`.
38
+ *
39
+ * @param signal - An AbortSignal to allow for cancellation of the asynchronous LLM check.
40
+ * @returns A promise that resolves to `true` if a loop is detected, and `false` otherwise.
41
+ */
42
+ turnStarted(signal: AbortSignal): Promise<boolean>;
43
+ private checkToolCallLoop;
44
+ /**
45
+ * Detects content loops by analyzing streaming text for repetitive patterns.
46
+ *
47
+ * The algorithm works by:
48
+ * 1. Appending new content to the streaming history
49
+ * 2. Truncating history if it exceeds the maximum length
50
+ * 3. Analyzing content chunks for repetitive patterns using hashing
51
+ * 4. Detecting loops when identical chunks appear frequently within a short distance
52
+ */
53
+ private checkContentLoop;
54
+ /**
55
+ * Truncates the content history to prevent unbounded memory growth.
56
+ * When truncating, adjusts all stored indices to maintain their relative positions.
57
+ */
58
+ private truncateAndUpdate;
59
+ /**
60
+ * Analyzes content in fixed-size chunks to detect repetitive patterns.
61
+ *
62
+ * Uses a sliding window approach:
63
+ * 1. Extract chunks of fixed size (CONTENT_CHUNK_SIZE)
64
+ * 2. Hash each chunk for efficient comparison
65
+ * 3. Track positions where identical chunks appear
66
+ * 4. Detect loops when chunks repeat frequently within a short distance
67
+ */
68
+ private analyzeContentChunksForLoop;
69
+ private hasMoreChunksToProcess;
70
+ /**
71
+ * Determines if a content chunk indicates a loop pattern.
72
+ *
73
+ * Loop detection logic:
74
+ * 1. Check if we've seen this hash before (new chunks are stored for future comparison)
75
+ * 2. Verify actual content matches to prevent hash collisions
76
+ * 3. Track all positions where this chunk appears
77
+ * 4. A loop is detected when the same chunk appears CONTENT_LOOP_THRESHOLD times
78
+ * within a small average distance (≤ 1.5 * chunk size)
79
+ */
80
+ private isLoopDetectedForChunk;
81
+ /**
82
+ * Verifies that two chunks with the same hash actually contain identical content.
83
+ * This prevents false positives from hash collisions.
84
+ */
85
+ private isActualContentMatch;
86
+ private checkForLoopWithLLM;
87
+ /**
88
+ * Resets all loop detection state.
89
+ */
90
+ reset(promptId: string): void;
91
+ private resetToolCallCount;
92
+ private resetContentTracking;
93
+ private resetLlmCheckTracking;
94
+ }
@@ -0,0 +1,318 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { createHash } from 'crypto';
7
+ import { GeminiEventType } from '../core/turn.js';
8
+ import { logLoopDetected } from '../telemetry/loggers.js';
9
+ import { LoopDetectedEvent, LoopType } from '../telemetry/types.js';
10
+ import { DEFAULT_GEMINI_FLASH_MODEL } from '../config/config.js';
11
+ import { Type } from '@google/genai';
12
+ const TOOL_CALL_LOOP_THRESHOLD = 5;
13
+ const CONTENT_LOOP_THRESHOLD = 10;
14
+ const CONTENT_CHUNK_SIZE = 50;
15
+ const MAX_HISTORY_LENGTH = 1000;
16
+ /**
17
+ * The number of recent conversation turns to include in the history when asking the LLM to check for a loop.
18
+ */
19
+ const LLM_LOOP_CHECK_HISTORY_COUNT = 20;
20
+ /**
21
+ * The number of turns that must pass in a single prompt before the LLM-based loop check is activated.
22
+ */
23
+ const LLM_CHECK_AFTER_TURNS = 30;
24
+ /**
25
+ * The default interval, in number of turns, at which the LLM-based loop check is performed.
26
+ * This value is adjusted dynamically based on the LLM's confidence.
27
+ */
28
+ const DEFAULT_LLM_CHECK_INTERVAL = 3;
29
+ /**
30
+ * The minimum interval for LLM-based loop checks.
31
+ * This is used when the confidence of a loop is high, to check more frequently.
32
+ */
33
+ const MIN_LLM_CHECK_INTERVAL = 5;
34
+ /**
35
+ * The maximum interval for LLM-based loop checks.
36
+ * This is used when the confidence of a loop is low, to check less frequently.
37
+ */
38
+ const MAX_LLM_CHECK_INTERVAL = 15;
39
+ /**
40
+ * Service for detecting and preventing infinite loops in AI responses.
41
+ * Monitors tool call repetitions and content sentence repetitions.
42
+ */
43
+ export class LoopDetectionService {
44
+ config;
45
+ promptId = '';
46
+ // Tool call tracking
47
+ lastToolCallKey = null;
48
+ toolCallRepetitionCount = 0;
49
+ // Content streaming tracking
50
+ streamContentHistory = '';
51
+ contentStats = new Map();
52
+ lastContentIndex = 0;
53
+ loopDetected = false;
54
+ // LLM loop track tracking
55
+ turnsInCurrentPrompt = 0;
56
+ llmCheckInterval = DEFAULT_LLM_CHECK_INTERVAL;
57
+ lastCheckTurn = 0;
58
+ constructor(config) {
59
+ this.config = config;
60
+ }
61
+ getToolCallKey(toolCall) {
62
+ const argsString = JSON.stringify(toolCall.args);
63
+ const keyString = `${toolCall.name}:${argsString}`;
64
+ return createHash('sha256').update(keyString).digest('hex');
65
+ }
66
+ /**
67
+ * Processes a stream event and checks for loop conditions.
68
+ * @param event - The stream event to process
69
+ * @returns true if a loop is detected, false otherwise
70
+ */
71
+ addAndCheck(event) {
72
+ if (this.loopDetected) {
73
+ return true;
74
+ }
75
+ switch (event.type) {
76
+ case GeminiEventType.ToolCallRequest:
77
+ // content chanting only happens in one single stream, reset if there
78
+ // is a tool call in between
79
+ this.resetContentTracking();
80
+ this.loopDetected = this.checkToolCallLoop(event.value);
81
+ break;
82
+ case GeminiEventType.Content:
83
+ this.loopDetected = this.checkContentLoop(event.value);
84
+ break;
85
+ default:
86
+ break;
87
+ }
88
+ return this.loopDetected;
89
+ }
90
+ /**
91
+ * Signals the start of a new turn in the conversation.
92
+ *
93
+ * This method increments the turn counter and, if specific conditions are met,
94
+ * triggers an LLM-based check to detect potential conversation loops. The check
95
+ * is performed periodically based on the `llmCheckInterval`.
96
+ *
97
+ * @param signal - An AbortSignal to allow for cancellation of the asynchronous LLM check.
98
+ * @returns A promise that resolves to `true` if a loop is detected, and `false` otherwise.
99
+ */
100
+ async turnStarted(signal) {
101
+ this.turnsInCurrentPrompt++;
102
+ if (this.turnsInCurrentPrompt >= LLM_CHECK_AFTER_TURNS &&
103
+ this.turnsInCurrentPrompt - this.lastCheckTurn >= this.llmCheckInterval) {
104
+ this.lastCheckTurn = this.turnsInCurrentPrompt;
105
+ return await this.checkForLoopWithLLM(signal);
106
+ }
107
+ return false;
108
+ }
109
+ checkToolCallLoop(toolCall) {
110
+ const key = this.getToolCallKey(toolCall);
111
+ if (this.lastToolCallKey === key) {
112
+ this.toolCallRepetitionCount++;
113
+ }
114
+ else {
115
+ this.lastToolCallKey = key;
116
+ this.toolCallRepetitionCount = 1;
117
+ }
118
+ if (this.toolCallRepetitionCount >= TOOL_CALL_LOOP_THRESHOLD) {
119
+ logLoopDetected(this.config, new LoopDetectedEvent(LoopType.CONSECUTIVE_IDENTICAL_TOOL_CALLS, this.promptId));
120
+ return true;
121
+ }
122
+ return false;
123
+ }
124
+ /**
125
+ * Detects content loops by analyzing streaming text for repetitive patterns.
126
+ *
127
+ * The algorithm works by:
128
+ * 1. Appending new content to the streaming history
129
+ * 2. Truncating history if it exceeds the maximum length
130
+ * 3. Analyzing content chunks for repetitive patterns using hashing
131
+ * 4. Detecting loops when identical chunks appear frequently within a short distance
132
+ */
133
+ checkContentLoop(content) {
134
+ this.streamContentHistory += content;
135
+ this.truncateAndUpdate();
136
+ return this.analyzeContentChunksForLoop();
137
+ }
138
+ /**
139
+ * Truncates the content history to prevent unbounded memory growth.
140
+ * When truncating, adjusts all stored indices to maintain their relative positions.
141
+ */
142
+ truncateAndUpdate() {
143
+ if (this.streamContentHistory.length <= MAX_HISTORY_LENGTH) {
144
+ return;
145
+ }
146
+ // Calculate how much content to remove from the beginning
147
+ const truncationAmount = this.streamContentHistory.length - MAX_HISTORY_LENGTH;
148
+ this.streamContentHistory =
149
+ this.streamContentHistory.slice(truncationAmount);
150
+ this.lastContentIndex = Math.max(0, this.lastContentIndex - truncationAmount);
151
+ // Update all stored chunk indices to account for the truncation
152
+ for (const [hash, oldIndices] of this.contentStats.entries()) {
153
+ const adjustedIndices = oldIndices
154
+ .map((index) => index - truncationAmount)
155
+ .filter((index) => index >= 0);
156
+ if (adjustedIndices.length > 0) {
157
+ this.contentStats.set(hash, adjustedIndices);
158
+ }
159
+ else {
160
+ this.contentStats.delete(hash);
161
+ }
162
+ }
163
+ }
164
+ /**
165
+ * Analyzes content in fixed-size chunks to detect repetitive patterns.
166
+ *
167
+ * Uses a sliding window approach:
168
+ * 1. Extract chunks of fixed size (CONTENT_CHUNK_SIZE)
169
+ * 2. Hash each chunk for efficient comparison
170
+ * 3. Track positions where identical chunks appear
171
+ * 4. Detect loops when chunks repeat frequently within a short distance
172
+ */
173
+ analyzeContentChunksForLoop() {
174
+ while (this.hasMoreChunksToProcess()) {
175
+ // Extract current chunk of text
176
+ const currentChunk = this.streamContentHistory.substring(this.lastContentIndex, this.lastContentIndex + CONTENT_CHUNK_SIZE);
177
+ const chunkHash = createHash('sha256').update(currentChunk).digest('hex');
178
+ if (this.isLoopDetectedForChunk(currentChunk, chunkHash)) {
179
+ logLoopDetected(this.config, new LoopDetectedEvent(LoopType.CHANTING_IDENTICAL_SENTENCES, this.promptId));
180
+ return true;
181
+ }
182
+ // Move to next position in the sliding window
183
+ this.lastContentIndex++;
184
+ }
185
+ return false;
186
+ }
187
+ hasMoreChunksToProcess() {
188
+ return (this.lastContentIndex + CONTENT_CHUNK_SIZE <=
189
+ this.streamContentHistory.length);
190
+ }
191
+ /**
192
+ * Determines if a content chunk indicates a loop pattern.
193
+ *
194
+ * Loop detection logic:
195
+ * 1. Check if we've seen this hash before (new chunks are stored for future comparison)
196
+ * 2. Verify actual content matches to prevent hash collisions
197
+ * 3. Track all positions where this chunk appears
198
+ * 4. A loop is detected when the same chunk appears CONTENT_LOOP_THRESHOLD times
199
+ * within a small average distance (≤ 1.5 * chunk size)
200
+ */
201
+ isLoopDetectedForChunk(chunk, hash) {
202
+ const existingIndices = this.contentStats.get(hash);
203
+ if (!existingIndices) {
204
+ this.contentStats.set(hash, [this.lastContentIndex]);
205
+ return false;
206
+ }
207
+ if (!this.isActualContentMatch(chunk, existingIndices[0])) {
208
+ return false;
209
+ }
210
+ existingIndices.push(this.lastContentIndex);
211
+ if (existingIndices.length < CONTENT_LOOP_THRESHOLD) {
212
+ return false;
213
+ }
214
+ // Analyze the most recent occurrences to see if they're clustered closely together
215
+ const recentIndices = existingIndices.slice(-CONTENT_LOOP_THRESHOLD);
216
+ const totalDistance = recentIndices[recentIndices.length - 1] - recentIndices[0];
217
+ const averageDistance = totalDistance / (CONTENT_LOOP_THRESHOLD - 1);
218
+ const maxAllowedDistance = CONTENT_CHUNK_SIZE * 1.5;
219
+ return averageDistance <= maxAllowedDistance;
220
+ }
221
+ /**
222
+ * Verifies that two chunks with the same hash actually contain identical content.
223
+ * This prevents false positives from hash collisions.
224
+ */
225
+ isActualContentMatch(currentChunk, originalIndex) {
226
+ const originalChunk = this.streamContentHistory.substring(originalIndex, originalIndex + CONTENT_CHUNK_SIZE);
227
+ return originalChunk === currentChunk;
228
+ }
229
+ async checkForLoopWithLLM(signal) {
230
+ const recentHistory = this.config
231
+ .getGeminiClient()
232
+ .getHistory()
233
+ .slice(-LLM_LOOP_CHECK_HISTORY_COUNT);
234
+ const prompt = `You are a sophisticated AI diagnostic agent specializing in identifying when a conversational AI is stuck in an unproductive state. Your task is to analyze the provided conversation history and determine if the assistant has ceased to make meaningful progress.
235
+
236
+ An unproductive state is characterized by one or more of the following patterns over the last 5 or more assistant turns:
237
+
238
+ Repetitive Actions: The assistant repeats the same tool calls or conversational responses a decent number of times. This includes simple loops (e.g., tool_A, tool_A, tool_A) and alternating patterns (e.g., tool_A, tool_B, tool_A, tool_B, ...).
239
+
240
+ Cognitive Loop: The assistant seems unable to determine the next logical step. It might express confusion, repeatedly ask the same questions, or generate responses that don't logically follow from the previous turns, indicating it's stuck and not advancing the task.
241
+
242
+ Crucially, differentiate between a true unproductive state and legitimate, incremental progress.
243
+ For example, a series of 'tool_A' or 'tool_B' tool calls that make small, distinct changes to the same file (like adding docstrings to functions one by one) is considered forward progress and is NOT a loop. A loop would be repeatedly replacing the same text with the same content, or cycling between a small set of files with no net change.
244
+
245
+ Please analyze the conversation history to determine the possibility that the conversation is stuck in a repetitive, non-productive state.`;
246
+ const contents = [
247
+ ...recentHistory,
248
+ { role: 'user', parts: [{ text: prompt }] },
249
+ ];
250
+ const schema = {
251
+ type: Type.OBJECT,
252
+ properties: {
253
+ reasoning: {
254
+ type: Type.STRING,
255
+ description: 'Your reasoning on if the conversation is looping without forward progress.',
256
+ },
257
+ confidence: {
258
+ type: Type.NUMBER,
259
+ description: 'A number between 0.0 and 1.0 representing your confidence that the conversation is in an unproductive state.',
260
+ },
261
+ },
262
+ required: ['reasoning', 'confidence'],
263
+ };
264
+ let result;
265
+ try {
266
+ result = await this.config
267
+ .getGeminiClient()
268
+ .generateJson(contents, schema, signal, DEFAULT_GEMINI_FLASH_MODEL);
269
+ }
270
+ catch (e) {
271
+ // Do nothing, treat it as a non-loop.
272
+ this.config.getDebugMode() ? console.error(e) : console.debug(e);
273
+ return false;
274
+ }
275
+ if (typeof result.confidence === 'number') {
276
+ if (result.confidence > 0.9) {
277
+ if (typeof result.reasoning === 'string' && result.reasoning) {
278
+ console.warn(result.reasoning);
279
+ }
280
+ logLoopDetected(this.config, new LoopDetectedEvent(LoopType.LLM_DETECTED_LOOP, this.promptId));
281
+ return true;
282
+ }
283
+ else {
284
+ this.llmCheckInterval = Math.round(MIN_LLM_CHECK_INTERVAL +
285
+ (MAX_LLM_CHECK_INTERVAL - MIN_LLM_CHECK_INTERVAL) *
286
+ (1 - result.confidence));
287
+ }
288
+ }
289
+ return false;
290
+ }
291
+ /**
292
+ * Resets all loop detection state.
293
+ */
294
+ reset(promptId) {
295
+ this.promptId = promptId;
296
+ this.resetToolCallCount();
297
+ this.resetContentTracking();
298
+ this.resetLlmCheckTracking();
299
+ this.loopDetected = false;
300
+ }
301
+ resetToolCallCount() {
302
+ this.lastToolCallKey = null;
303
+ this.toolCallRepetitionCount = 0;
304
+ }
305
+ resetContentTracking(resetHistory = true) {
306
+ if (resetHistory) {
307
+ this.streamContentHistory = '';
308
+ }
309
+ this.contentStats.clear();
310
+ this.lastContentIndex = 0;
311
+ }
312
+ resetLlmCheckTracking() {
313
+ this.turnsInCurrentPrompt = 0;
314
+ this.llmCheckInterval = DEFAULT_LLM_CHECK_INTERVAL;
315
+ this.lastCheckTurn = 0;
316
+ }
317
+ }
318
+ //# sourceMappingURL=loopDetectionService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loopDetectionService.js","sourceRoot":"","sources":["../../../src/services/loopDetectionService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,eAAe,EAA2B,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAU,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAe,IAAI,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC;;GAEG;AACH,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAExC;;GAEG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC;;;GAGG;AACH,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAErC;;;GAGG;AACH,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC;;;GAGG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACd,MAAM,CAAS;I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