fixed copilot issue with searching composio and applying pipeline tools

This commit is contained in:
arkml 2025-08-13 22:45:38 +05:30
parent beee4306ac
commit c0180e2779
2 changed files with 33 additions and 4 deletions

View file

@ -20,10 +20,13 @@ export function validateConfigChanges(configType: string, configChanges: Record<
break; break;
} }
case 'agent': { case 'agent': {
// Determine if this is a pipeline agent from the config changes
const isPipelineAgent = configChanges.type === 'pipeline';
testObject = { testObject = {
name: 'test', name: 'test',
description: 'test', description: 'test',
type: 'conversation', type: isPipelineAgent ? 'pipeline' : 'conversation',
instructions: 'test', instructions: 'test',
prompts: [], prompts: [],
tools: [], tools: [],
@ -31,8 +34,9 @@ export function validateConfigChanges(configType: string, configChanges: Record<
ragReturnType: 'chunks', ragReturnType: 'chunks',
ragK: 10, ragK: 10,
connectedAgents: [], connectedAgents: [],
controlType: 'retain', // Set correct defaults based on agent type
outputVisibility: 'user_facing', controlType: isPipelineAgent ? 'relinquish_to_parent' : 'retain',
outputVisibility: isPipelineAgent ? 'internal' : 'user_facing',
maxCallsPerParentAgent: 3, maxCallsPerParentAgent: 3,
} as z.infer<typeof WorkflowAgent>; } as z.infer<typeof WorkflowAgent>;
schema = WorkflowAgent; schema = WorkflowAgent;

View file

@ -136,13 +136,38 @@ async function searchRelevantTools(query: string): Promise<string> {
return ''; return '';
} }
const toolSlugs: string[] = searchResult.data.results.map((result: any) => result.tool); // Log the actual response structure to debug
logger.log("Raw search results:", JSON.stringify(searchResult.data.results, null, 2));
// Extract tool slugs with defensive handling for different possible field names
const toolSlugs: string[] = searchResult.data.results
.map((result: any) => {
// Try different possible field names for the tool slug
const slug = result.tool || result.slug || result.tool_slug || result.name;
logger.log(`Processing result:`, { result, extractedSlug: slug });
return slug;
})
.filter((slug): slug is string => {
const isValid = typeof slug === 'string' && slug.length > 0;
if (!isValid) {
logger.log(`Filtering out invalid slug:`, slug);
}
return isValid;
});
logger.log(`found tool slugs: ${toolSlugs.join(', ')}`); logger.log(`found tool slugs: ${toolSlugs.join(', ')}`);
console.log("✅ TOOL CALL SUCCESS: COMPOSIO_SEARCH_TOOLS", { console.log("✅ TOOL CALL SUCCESS: COMPOSIO_SEARCH_TOOLS", {
toolSlugs, toolSlugs,
resultCount: toolSlugs.length resultCount: toolSlugs.length
}); });
// Check if we have any valid tool slugs before proceeding
if (toolSlugs.length === 0) {
logger.log("No valid tool slugs found after filtering");
console.log("⚠️ TOOL CALL WARNING: No valid tools found after filtering");
return 'No valid tools found for the given query. The search returned results but they contained invalid tool identifiers.';
}
// Enrich tools with full details // Enrich tools with full details
console.log("🔧 TOOL CALL: getTool (multiple calls)", { toolSlugs }); console.log("🔧 TOOL CALL: getTool (multiple calls)", { toolSlugs });
const composioTools = await Promise.all(toolSlugs.map(slug => getTool(slug))); const composioTools = await Promise.all(toolSlugs.map(slug => getTool(slug)));