Agent Synchronization
This is a guide to synchronizing Agents in Fabric.
Fabric Agents can be invoked synchronously using the Agent Invoke system-Skill and the correlationId
parameter.
See synchronous-agent-invocation-example in Cortex Fabric Examples GitHub repo.
Set up Agents to invoke synchronously
Configure the calling Agent, first Agent in the sequence (of two), with the "Agent Invoke" system-Skill. When you configure the Skill, you must set the following values:
- Name of the Agent to be invoked (from)
- Name of the output Service Message that is making the call to invoke
Example
- Calling Agent is named
agent1calling
. - The last Skill in the calling Agent is
agent-invoke
(the system-Skill). - The output Service Message connected to the
agent-invoke
Skill is namedservice-out
. - Invoked Agent's first Skill is named
hubblejob
.
Invoke calling Agent.
cortex agents invoke agent1calling service-out --params '{"payload":{"text":"test"}}'Response
{"success": true,"activationId": "fdc05cde-e327-485c-8d04-1fbdc623de46"}Query the
correlationId
and add the--report
option to view details. (correlationId
,requestId
, andactivationId
are the same when system generated)cortex agents get-activations fdc05cde-e327-485c-8d04-1fbdc623de46 --reportResponse In the generated report, you can see that the
agent-invoke
system-skill (the last Skill in the calling Agent) was invoked, as was the output service connected to that Skill. The last item in the report is the first Skill in the second Agent,hubblejob
which was invoked per the desired sequence.Status: COMPLETEElapsed Time (ms): 20868┌───────────────┬───────────────────────┬─────────────┬─────────────┬───────────────┐│ Name │ Title │ Type │ Status │ Elapsed (ms) │├───────────────┼───────────────────────┼─────────────┼─────────────┼───────────────┤│ agent-invoke │ Agent invoke │ skill │ COMPLETE │ 10413 │├───────────────┼───────────────────────┼─────────────┼─────────────┼───────────────┤│ service-out │ Text │ output │ COMPLETE │ 2 │├───────────────┼───────────────────────┼─────────────┼─────────────┼───────────────┤│ hubblejob │ Compute hubble data │ skill │ COMPLETED │ 10439 │└───────────────┴───────────────────────┴─────────────┴─────────────┴───────────────┘
Use correlationId to view groups of invocations
You can query the correlationId to view groups of Agent invocations for troubleshooting issues.
For example, you can specify a correlationId when you invoke the calling Agent by passing it in as a parameter.
The correlationId test123
is passed to the downstream invocations for this Agent and any other Agent that I pass the correlationId test123
into.
You can then query that correlationId to see the results for all Skills and Services that were invoked using the correlationId test123
.