Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(ts/cli): prevent cache corruption when using FORCE_USE_CACHE=true

jkomyno269c444c2ee2
diff --git a/ts/packages/cli/src/services/composio-clients-cached.ts b/ts/packages/cli/src/services/composio-clients-cached.ts
index fcc5af903..6286d140c 100644
--- a/ts/packages/cli/src/services/composio-clients-cached.ts
+++ b/ts/packages/cli/src/services/composio-clients-cached.ts
@@ -80,13 +80,16 @@ function createCachedEffect<T, E, R>(
// Fetch from the underlying service
const result = yield* computation;
- // Write to cache (best effort: don't fail if cache write fails)
- yield* encoder(result).pipe(
- Effect.flatMap(content => fs.writeFileString(cacheFilePath, content)),
- Effect.catchAll(error =>
- Effect.logWarning(`Failed to write to cache ${cacheFilePath}: ${error}`)
- )
- );
+ // Write to cache only if we're fetching the full dataset (no cacheFilter).
+ // Filtered API calls fetch partial data that would corrupt the shared cache file.
+ if (!cacheFilter) {
+ yield* encoder(result).pipe(
+ Effect.flatMap(content => fs.writeFileString(cacheFilePath, content)),
+ Effect.catchAll(error =>
+ Effect.logWarning(`Failed to write to cache ${cacheFilePath}: ${error}`)
+ )
+ );
+ }
return result;
});