Skip to content

Agent Mode

Agent mode (kdeps serve) starts an interactive LLM loop where whole workflows and components are registered as callable tools. The LLM decides which tool to invoke based on the user's prompt. Workflow tools run the full pipeline atomically so all requires: dependencies resolve correctly. Component tools run a single reusable component in isolation. Individual resources are never exposed as tools directly.

Single workflow vs folder

bash
# One workflow = one tool (named after metadata.name)
kdeps serve ./my-agent/

# Folder = every workflow and agency inside becomes a separate tool
kdeps serve ./agents/

When you point to a folder, kdeps discovers every workflow and agency file inside it (recursively). Each becomes a separate tool. The tool name is metadata.name from the workflow's manifest -- not the filename.

Concrete example

Given this workflow:

yaml
# my-agent/workflow.yaml
apiVersion: kdeps.io/v1
kind: Workflow

metadata:
  name: my-agent          # this becomes the tool name the LLM sees
  version: "1.0.0"
  description: "Answers questions about our product"
  targetActionId: response

settings:
  apiServer:
    hostIp: "127.0.0.1"
    portNum: 16395
    routes:
      - path: /api/v1/chat
        methods: [POST]

Running:

bash
kdeps serve ./my-agent/

The LLM receives one tool named my-agent. When it calls that tool, kdeps runs the full workflow DAG -- every resource in dependency order -- and returns apiResponse.response to the LLM.

The LLM never sees individual resources. It sees:

Tool: my-agent
Description: Answers questions about our product
Input: { "input": string }

Folder mode -- multiple tools

agents/
  research/
    workflow.yaml    # metadata.name: research-agent
  writer/
    workflow.yaml    # metadata.name: writer-agent
  summarizer/
    workflow.yaml    # metadata.name: summarizer-agent
bash
kdeps serve ./agents/

The LLM now has three tools: research-agent, writer-agent, summarizer-agent. It routes between them based on the user's prompt.

How it works

user promptLLM receives prompttool registry: one tool per workflow, one per agency, one per componenttool type?kdeps runs full workflow pipelineall requires: deps resolve in orderkdeps runs agency entry-point pipelineinternal agents resolve via agent: resource typekdeps runs component in isolationinputs map to component interface fieldsmore tools needed?final answerLLM picks a toolworkflowagencycomponentapiResponse returned to LLMresult returned to LLMresult returned to LLMyesno

Why whole workflows and not individual resources? A resource that calls get('otherDep') depends on an upstream resource having run first. If the LLM called that resource in isolation, the upstream data would be missing and the output would be wrong. Running the full workflow guarantees all dependencies execute in the correct order.

Why agencies are one tool and not one tool per internal agent? Agencies are designed as a single orchestrated unit. The entry-point agent coordinates the other agents internally via agent: resources -- the LLM does not need to know about the internal structure. One agency = one tool call.

Tool registration

kdeps serve targetTools registered
Single workflow file/dirOne tool (metadata.name) + one tool per component in that workflow
Single agency fileOne tool (agency metadata.name) -- the agency's entry-point runs when called; internal agents are not exposed individually
FolderOne tool per workflow/agency found recursively + component tools for each workflow

Workflow tool input is forwarded as get('key') request params inside the pipeline. Output is the workflow's apiResponse.response. Agency tool input runs the agency's entry-point workflow. Component tool inputs map to the component's declared interface fields.

When to use agent mode

  • You want a conversational interface that dynamically picks which workflow to run.
  • You have multiple specialized workflows and want the LLM to route between them.
  • You are prototyping before formalizing a fixed pipeline in workflow mode.
  • You are building a chatbot or assistant that calls your business logic on demand.

Command

bash
kdeps serve <path> [flags]

<path> is a workflow or agency file, or a directory. The tool name comes from metadata.name inside each file -- not from the filename itself.

Flags

FlagDefaultDescription
--modelKDEPS_AGENT_MODEL or llama3.2LLM model name
--backendKDEPS_AGENT_BACKEND or ollamaLLM backend
--base-urlKDEPS_AGENT_BASE_URLLLM API base URL
--system(none)System prompt injected at conversation start
--debugfalseEnable debug logging

Environment variables

bash
KDEPS_AGENT_MODEL=llama3.2
KDEPS_AGENT_BACKEND=ollama
KDEPS_AGENT_BASE_URL=http://localhost:11434

Examples

bash
# Single workflow -- one tool
kdeps serve ./my-agent/

# All workflows in a folder
kdeps serve ./agents/

# Specify model and system prompt
kdeps serve ./agents/ --model mistral --system "You are a data analyst."

# OpenAI-compatible backend
KDEPS_AGENT_BACKEND=openai KDEPS_AGENT_BASE_URL=https://api.openai.com \
  kdeps serve ./agents/ --model gpt-4o

Differences from workflow mode

Workflow mode (kdeps run)Agent mode (kdeps serve)
ExecutionDAG, deterministicLLM loop, tool-driven
Entry pointmetadata.targetActionIdUser prompt
Unit of workIndividual resourcesWhole workflows
Tools exposedN/AOne per workflow + one per component
InputSingle workflow pathFile or folder

See Also

Released under the Apache 2.0 License.