Skip to content

Commit 5b7c8de

Browse files
committed
fix: immutable actor cache
1 parent f5f5353 commit 5b7c8de

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/tools/actor.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,11 @@ export async function getActorsAsTools(
241241
}),
242242
);
243243

244+
const clonedActors = structuredClone(actorsInfo);
245+
244246
// Filter out nulls and separate Actors with MCP servers and normal Actors
245-
const actorMCPServersInfo = actorsInfo.filter((actorInfo) => actorInfo && actorInfo.webServerMcpPath) as ActorInfo[];
246-
const normalActorsInfo = actorsInfo.filter((actorInfo) => actorInfo && !actorInfo.webServerMcpPath) as ActorInfo[];
247+
const actorMCPServersInfo = clonedActors.filter((actorInfo) => actorInfo && actorInfo.webServerMcpPath) as ActorInfo[];
248+
const normalActorsInfo = clonedActors.filter((actorInfo) => actorInfo && !actorInfo.webServerMcpPath) as ActorInfo[];
247249

248250
const [normalTools, mcpServerTools] = await Promise.all([
249251
getNormalActorsAsTools(normalActorsInfo),
@@ -315,7 +317,6 @@ export const callActor: ToolEntry = {
315317
throw new Error('APIFY_TOKEN environment variable is not set.');
316318
}
317319
try {
318-
// FIXME: Bug, every call add "**REQUIRED**" to the description of the input properties
319320
const [actor] = await getActorsAsTools([actorName], apifyToken);
320321

321322
if (!actor) {
@@ -338,19 +339,18 @@ export const callActor: ToolEntry = {
338339
}
339340
}
340341

341-
const { actorRun, datasetInfo, items } = await callActorGetDataset(
342+
const { items } = await callActorGetDataset(
342343
actorName,
343344
input,
344345
apifyToken,
345346
callOptions,
346347
);
347348

348349
return {
349-
content: [
350-
{ type: 'text', text: `Actor run ID: ${actorRun.id}` },
351-
{ type: 'text', text: `Dataset ID: ${datasetInfo?.id}` },
352-
{ type: 'text', text: `Items count: ${items.total}` },
353-
],
350+
content: items.items.map((item: Record<string, unknown>) => ({
351+
type: 'text',
352+
text: JSON.stringify(item),
353+
})),
354354
};
355355
} catch (error) {
356356
console.error(`Error calling Actor: ${error}`);

0 commit comments

Comments
 (0)