@devries-cameron20 / composio Mirror · read-only / commits / 370fd6188
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 12:15 UTC

fix(cli): do not memoize the missing-api-key tool version

The user context is live state that `login` fills in during the same process. Memoizing the `null` answered before that would skip the version check for that tool for the rest of the run. Resolve the key outside the memo and cache only real lookups. Claude-Session: https://claude.ai/code/session_01MTb47vexN35pLGsSZwBmrJ

jkomyno committed Sep 14, 2026 at 20:55 UTC 370fd618828606bffec882cd985afd643877f779
1 file changed +19 -7
ts/packages/cli/src/services/tool-input-validation.ts
+19 -7
@@ -189,19 +189,15 @@ export const invalidateToolInputDefinition = (slug: string) =>
189 // asks twice on every call: the background version check forked from the
190 // command, and `getOrFetchToolInputDefinition` on the executor's file-upload
191 // path. Both want the same answer within the same second.
192 -const fetchResolvedLatestToolVersion = memoizeInProcess({
192 +const fetchLatestToolVersionOnce = memoizeInProcess({
193 keyOf: (input: {
194 readonly slug: string;
195 + readonly apiKey: string;
196 readonly params?: { readonly orgId?: string; readonly projectId?: string };
197 }) => `${input.slug}\u0000${input.params?.orgId ?? ''}\u0000${input.params?.projectId ?? ''}`,
197 - make: ({ slug, params }) =>
198 + make: ({ slug, apiKey, params }) =>
199 Effect.gen(function* () {
200 const userContext = yield* ComposioUserContext;
200 - const apiKey = Option.getOrUndefined(userContext.data.apiKey);
201 - if (!apiKey) {
202 - return null;
203 - }
204 -
201 const latest = yield* getLatestToolVersion({
202 baseURL: userContext.data.baseURL,
203 apiKey,
@@ -219,6 +215,22 @@ const fetchResolvedLatestToolVersion = memoizeInProcess({
215 }),
216 });
217
218 +// The API-key check stays outside the memo: the user context is live state
219 +// that `login` can fill in later in the same process, and caching the `null`
220 +// answered before that would silence the version check for the rest of it.
221 +const fetchResolvedLatestToolVersion = (input: {
222 + readonly slug: string;
223 + readonly params?: { readonly orgId?: string; readonly projectId?: string };
224 +}) =>
225 + Effect.gen(function* () {
226 + const userContext = yield* ComposioUserContext;
227 + const apiKey = Option.getOrUndefined(userContext.data.apiKey);
228 + if (!apiKey) {
229 + return null;
230 + }
231 + return yield* fetchLatestToolVersionOnce({ ...input, apiKey });
232 + });
233 +
234 const fetchAndCacheToolInputDefinition = (
235 slug: string,
236 params?: { readonly orgId?: string; readonly projectId?: string }