Skip to content

Compose two agents into an agency: full text ​

This page has every step and detail. The overview is the short version.

Build an agency: two agents in one project, where the entry-point agent calls the other and returns the combined result. Each agent is its own workflow.yaml. An agency.yaml manifest ties them together.

Each agent has its own resources, routes, and settings. The agent: resource runs another agent's entire pipeline and returns its apiResponse. Only the entry-point agent (targetAgentId) serves HTTP. kdeps calls the other agents internally.

Step 1: create the structure ​

bash
mkdir -p greeter-agency/agents/greeter
mkdir -p greeter-agency/agents/responder
cd greeter-agency

Step 2: write the manifest ​

Create agency.yaml:

yaml
# agency.yaml
apiVersion: kdeps.io/v1
kind: Agency

metadata:
  name: greeter-agency
  version: "1.0.0"
  targetAgentId: greeter-agent   # the agent that serves HTTP

agents:
  - agents/greeter               # relative to this file
  - agents/responder

Step 3: the helper agent ​

Create agents/responder/workflow.yaml:

yaml
# agents/responder/workflow.yaml
apiVersion: kdeps.io/v1
kind: Workflow

metadata:
  name: responder-agent          # how other agents address it
  version: "1.0.0"
  targetActionId: respond

deploy:
  runtime:
    timezone: UTC

resources:
  - actionId: respond
    name: Respond
    apiResponse:
      success: true
      response: "Hello, {{ get('name', 'World') }}! (from responder-agent)"

This agent has no apiServer: - it only runs when another agent calls it. get('name') reads the value the caller forwards.

Step 4: the entry-point agent ​

Create agents/greeter/workflow.yaml:

yaml
# agents/greeter/workflow.yaml
apiVersion: kdeps.io/v1
kind: Workflow

metadata:
  name: greeter-agent
  version: "1.0.0"
  targetActionId: greet

deploy:
  apiServer:
    portNum: 17100
    routes:
      - path: /api/v1/greet
        methods: [GET]

resources:
  - actionId: callResponder
    name: Call responder
    agent:
      name: responder-agent      # match responder's metadata.name
      params:
        name: "{{ get('name') }}" # forwarded; readable as get('name') there

  - actionId: greet
    name: Greet
    flow:
      requires: [callResponder]
    apiResponse:
      success: true
      response: "{{ output('callResponder') }}"   # the responder's reply

Step 5: validate and run ​

bash
kdeps validate .
export KDEPS_API_AUTH_TOKEN=dev-token
kdeps run agency.yaml
bash
curl "http://localhost:17100/api/v1/greet?name=Alice" \
  -H "Authorization: Bearer $KDEPS_API_AUTH_TOKEN"

Response:

json
{
  "success": true,
  "data": "Hello, Alice! (from responder-agent)"
}

Step 6: package the agency (optional) ​

bash
kdeps bundle package .            # -> greeter-agency-1.0.0.kagency
kdeps run greeter-agency-1.0.0.kagency
kdeps bundle build greeter-agency-1.0.0.kagency   # Docker image

Next steps ​

kdeps has the Apache 2.0 License.