Show max calls per parent-child only for child internal agents

This commit is contained in:
akhisud3195 2025-07-11 17:27:55 +05:30
parent 173dd9142f
commit 1b2a9e3dcb
2 changed files with 39 additions and 26 deletions

View file

@ -1025,6 +1025,17 @@ export async function* streamResponse(
break; break;
} }
// Only apply max calls limit to internal agents (task agents)
const targetAgentConfig = agentConfig[event.item.targetAgent.name];
if (targetAgentConfig?.outputVisibility === 'internal') {
const maxCalls = targetAgentConfig?.maxCallsPerParentAgent || 3;
const currentCalls = transferCounter.get(agentName, event.item.targetAgent.name);
if (currentCalls >= maxCalls) {
eventLogger.log(`skipping handoff to ${event.item.targetAgent.name} || reason: max calls ${maxCalls} exceeded from ${agentName} to internal agent ${event.item.targetAgent.name}`);
continue;
}
}
// inject give up control instructions if needed (parent handing off to child) // inject give up control instructions if needed (parent handing off to child)
maybeInjectGiveUpControlInstructions( maybeInjectGiveUpControlInstructions(
agents, agents,

View file

@ -576,35 +576,37 @@ export function AgentConfig({
</div> </div>
</div> </div>
<div className="space-y-4"> {agent.outputVisibility === "internal" && (
<div className="flex items-center"> <div className="space-y-4">
<label className={sectionHeaderStyles}> <div className="flex items-center">
Max calls from parent agent per turn <label className={sectionHeaderStyles}>
</label> Max calls from parent agent per turn
<div className="relative ml-2 group"> </label>
<Info <div className="relative ml-2 group">
className="w-4 h-4 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 cursor-pointer transition-colors" <Info
/> className="w-4 h-4 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 cursor-pointer transition-colors"
<div className="absolute bottom-full left-0 mb-2 p-3 w-80 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-xs invisible group-hover:visible z-50"> />
<div className="mb-1 font-medium">Max Calls Configuration</div> <div className="absolute bottom-full left-0 mb-2 p-3 w-80 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-xs invisible group-hover:visible z-50">
This setting limits how many times a parent agent can call this agent in a single turn, to prevent infinite loops. <div className="mb-1 font-medium">Max Calls Configuration</div>
<div className="absolute h-2 w-2 bg-white dark:bg-gray-800 transform rotate-45 -bottom-1 left-4 border-r border-b border-gray-200 dark:border-gray-700"></div> This setting limits how many times a parent agent can call this agent in a single turn, to prevent infinite loops.
<div className="absolute h-2 w-2 bg-white dark:bg-gray-800 transform rotate-45 -bottom-1 left-4 border-r border-b border-gray-200 dark:border-gray-700"></div>
</div>
</div> </div>
</div> </div>
<div className="w-full">
<Input
type="number"
min="1"
value={agent.maxCallsPerParentAgent || 3}
onChange={(e) => handleUpdate({
...agent,
maxCallsPerParentAgent: parseInt(e.target.value)
})}
className="w-full max-w-24"
/>
</div>
</div> </div>
<div className="w-full"> )}
<Input
type="number"
min="1"
value={agent.maxCallsPerParentAgent || 3}
onChange={(e) => handleUpdate({
...agent,
maxCallsPerParentAgent: parseInt(e.target.value)
})}
className="w-full max-w-24"
/>
</div>
</div>
{USE_TRANSFER_CONTROL_OPTIONS && ( {USE_TRANSFER_CONTROL_OPTIONS && (
<div className="space-y-4"> <div className="space-y-4">