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

View file

@ -136,13 +136,38 @@ async function searchRelevantTools(query: string): Promise<string> {
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(', ')}`);
console.log("✅ TOOL CALL SUCCESS: COMPOSIO_SEARCH_TOOLS", {
toolSlugs,
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
console.log("🔧 TOOL CALL: getTool (multiple calls)", { toolSlugs });
const composioTools = await Promise.all(toolSlugs.map(slug => getTool(slug)));