@@ -3,7 +3,7 @@ title: Agent Collaboration
33---
44# Agent Collaboration
55
6- ** COMING SOON ** in version 0.122.0
6+ From version 0.122.0
77
88This page describes ways in which multiple agents can communicate and collaborate with each other.
99
@@ -27,12 +27,14 @@ val result: String = askAgent("assistant-agent", input = "a question").getOrNull
2727
2828A common use case is to place the ` callAgent ` function in an LLM Function
2929and let the Agent decide itself when to call the other agent. This creates a more dynamic and flexible system
30- where agents can autonomously determine when they need assistance from other specialized agents.
30+ where agents can autonomously determine when they need assistance from other agents.
3131
3232Example of a supervisor agent that can call other agents:
3333
3434``` kts
35- agent {
35+
36+ // supervisor-agent.agent.kts
37+ agent {
3638 name = " supervisor-agent"
3739 tools { + " call_agent" }
3840 prompt {
@@ -42,17 +44,30 @@ Example of a supervisor agent that can call other agents:
4244 Call the "weather-agent" if you need weather information.
4345 Call the "booking-agent" if you need to book a hotel.
4446 """
45- }
46- }
47-
48- // Define a function that the agent can use to call other agents
47+ }
48+ }
49+
50+ // weather-agent.agent.kts
51+ agent {
52+ name = " weather-agent"
53+ // ...
54+ }
55+
56+ // booking-agent.agent.kts
57+ agent {
58+ name = " booking-agent"
59+ // ...
60+ }
61+
62+ // call_agent.functions.kts - Define a function that the agent can use to call other agents.
4963function(
5064 name = " call_agent" ,
5165 description = " Calls an Agent." ,
5266 params = types(string(" name" , " the name of the agent to call." ))
5367) { (name) ->
5468 val currentConversation = get<Conversation >()
5569 val result = callAgent(name.toString(), input = currentConversation).getOrNull()
70+
5671 // Extract just the content from the assistant's message or return an error message
5772 result?.latest<AssistantMessage >()?.content ? : " Failed to call agent $name !"
5873}
0 commit comments