Skip to content

Commit 20285cf

Browse files
OskarStarkclaude
andcommitted
Support null (~) for fallback agents in handoffs configuration
- Allow using ~ (null) in addition to [] for agents with no specific triggers - Automatically convert null to empty array in processMultiAgentConfig - Update demo and documentation to use cleaner ~ syntax for fallback agents 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 949034f commit 20285cf

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

demo/config/packages/ai.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ ai:
7272
orchestrator: 'orchestrator'
7373
handoffs:
7474
technical: ['bug', 'problem', 'technical', 'error', 'code', 'debug']
75-
general: []
75+
general: ~
7676
store:
7777
chroma_db:
7878
symfonycon:

src/ai-bundle/doc/index.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ The AI Bundle provides a configuration system for creating multi-agent orchestra
450450
# Handoff rules mapping agents to trigger keywords
451451
# Minimum 2 handoffs required (otherwise use the agent directly)
452452
handoffs:
453-
'technical': ['bug', 'problem', 'technical', 'error', 'code', 'debug']
454-
'general': [] # Fallback when no specific conditions match
453+
technical: ['bug', 'problem', 'technical', 'error', 'code', 'debug']
454+
general: ~ # Fallback when no specific conditions match
455455
456456
Each multi-agent configuration automatically registers a service with the ID pattern ``ai.multi_agent.{name}``.
457457

@@ -484,7 +484,7 @@ For the example above, the service ``ai.multi_agent.support`` is registered and
484484
Handoff rules are defined as a key-value mapping where:
485485

486486
* **Key**: The name of the target agent (automatically prefixed with ``ai.agent.``)
487-
* **Value**: An array of keywords or phrases that trigger this handoff. When the orchestrator identifies these keywords in the user's request, it delegates to the specified agent. An empty array acts as a fallback for requests that don't match other rules.
487+
* **Value**: An array of keywords or phrases that trigger this handoff. When the orchestrator identifies these keywords in the user's request, it delegates to the specified agent. Use ``~`` (null) or ``[]`` (empty array) for fallback agents that handle requests not matching other rules.
488488

489489
.. note::
490490

@@ -513,10 +513,10 @@ Handoff rules are defined as a key-value mapping where:
513513
customer_service:
514514
orchestrator: 'analyzer'
515515
handoffs:
516-
'tech_support': ['error', 'bug', 'crash', 'not working', 'broken']
517-
'billing': ['payment', 'invoice', 'billing', 'subscription', 'price']
518-
'product_info': ['features', 'how to', 'tutorial', 'guide', 'documentation']
519-
'general_support': [] # Fallback for general inquiries
516+
tech_support: ['error', 'bug', 'crash', 'not working', 'broken']
517+
billing: ['payment', 'invoice', 'billing', 'subscription', 'price']
518+
product_info: ['features', 'how to', 'tutorial', 'guide', 'documentation']
519+
general_support: ~ # Fallback for general inquiries
520520
521521
Usage
522522
-----

src/ai-bundle/src/AiBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ private function processMultiAgentConfig(string $name, array $config, ContainerB
12331233

12341234
$handoffDefinition = new Definition(Handoff::class, [
12351235
$agentReference,
1236-
$whenConditions,
1236+
$whenConditions ?? [], // Convert null to empty array for fallback agents
12371237
]);
12381238

12391239
$handoffs[] = $handoffDefinition;

0 commit comments

Comments
 (0)