Suppress add new agent and add new tool by copilot if one exists already

This commit is contained in:
akhisud3195 2025-07-16 16:46:31 +05:30
parent c72728bf3d
commit 54e2574816

View file

@ -223,7 +223,11 @@ function AssistantMessage({
// Only apply, do not update appliedActions here // Only apply, do not update appliedActions here
if (action.action === 'create_new') { if (action.action === 'create_new') {
switch (action.config_type) { switch (action.config_type) {
case 'agent': case 'agent': {
// Prevent duplicate agent names
if (workflow.agents.some((agent: any) => agent.name === action.name)) {
return;
}
dispatch({ dispatch({
type: 'add_agent', type: 'add_agent',
agent: { agent: {
@ -232,7 +236,12 @@ function AssistantMessage({
} }
}); });
break; break;
case 'tool': }
case 'tool': {
// Prevent duplicate tool names
if (workflow.tools.some((tool: any) => tool.name === action.name)) {
return;
}
dispatch({ dispatch({
type: 'add_tool', type: 'add_tool',
tool: { tool: {
@ -241,6 +250,7 @@ function AssistantMessage({
} }
}); });
break; break;
}
case 'prompt': case 'prompt':
dispatch({ dispatch({
type: 'add_prompt', type: 'add_prompt',
@ -276,7 +286,7 @@ function AssistantMessage({
break; break;
} }
} }
}, [dispatch]); }, [dispatch, workflow.agents, workflow.tools]);
// Memoized handleApplyAll for useEffect dependencies // Memoized handleApplyAll for useEffect dependencies
const handleApplyAll = useCallback(() => { const handleApplyAll = useCallback(() => {