Skip to main content
Version: 5.4.0

Work on the AI agent flow

After creating a flow in AI Agent Builder, you can continue building it on the canvas. Add components, connect them in sequence, and configure each step to define how the AI agent receives input, processes data, and returns a result.

You can start with a blank flow or a template, then test and refine the flow before using it in your application. When the flow is ready, call it from Workflow Designer or through KAIZEN-provided API endpoints to include AI-generated responses or agent actions in a business process.

Create a basic flow​

The following shows an example on how to create a basic flow using the OpenRouter model.

In this flow, OpenRouter provides the model connection and API credentials, while the Agent controls how the prompt is handled and how the response is generated.

Use this example to learn the basic pattern for building an AI agent flow. After the basic flow works, you can update the Agent Instructions or add more components.

note

Before you start, obtain the API key of OpenRouter or your preferred language model.

  1. On your project toolbar, click AI Agent Builder AI Agent Builder button.

  2. Click New Flow. On the template screen, click Blank Flow.

  3. Search for Agent in the Components panel. Drag Agent and drop it onto canvas.

    Find Agent in Components
  4. In the Agent, click the field below Language Model, then select + Connect other models.

    Connect other models
  5. Search for OpenRouter in the Components panel. Drag OpenRouter and drop it onto canvas. Place it at the left side of the Agent.

    Find OpenRouter in Components
  6. In OpenRouter, enter its API Key and select a model.

    This example uses openrouter/free. You can choose other models for your project.

  7. Connect the OpenRouter output to the input of the Agent's Language Model input.

    Connect OpenRouter to Agent
  8. Optionally, you can click the Agent then the pencil icon Pencil icon to rename it.

  9. Drag Chat Input from the Components panel and drop it onto canvas. Place it below OpenRouter.

  10. Connect the Chat Input to the Agent's Input.

    Connect OpenRouter to Agent
  11. Drag Chat Output from the Components panel and drop it onto the canvas. Place it at the right side of the Agent.

  12. Connect the Chat Output to the Agent's Response.

    Connect OpenRouter to Agent
  13. Click the field below Agent Instructions to customise the instructions. Click Finish Editing to apply your edits.

  14. Click Playground at the top right corner of canvas to start testing.

    Playground for testing

Add a MCP server​

The following example shows how to add a Playwright MCP server.

Model Context Protocol (MCP) is a standard way to connect an AI agent to external tools and services. By adding an MCP server, you give the agent access to actions that are provided outside the basic flow, such as using Playwright to inspect web pages, interact with browser elements, or support browser-based testing tasks.

In this example, the MCP Tools component stores the Playwright server configuration and exposes its tools to the Agent.

note

Before your start, obtain the following:

  • API key of OpenRouter or your preferred language model
  • System prompt for the AI Agent
  • Playwright installation instructions in JSON from Playwright official site
  1. Create a basic flow.

  2. Search for MCP Tools in the Components panel. Drag MCP Tools and drop it on canvas. Place it below the OpenRouter component.

    Add the MCP Tools component
  3. In MCP Tools, click Add MCP Server.

  4. Copy the Playwright installation instructions in JSON format and paste it into the Add MCP Server window, JSON tab. Click Add Server.

    Add the installation instructions in JSON
  5. Click the MCP Tools component. Turn on Tool Mode.

  6. Connect Toolset with the Agent's Tools.

    Add the installation instructions in JSON
  7. In the field below Agent Instructions, add the system prompt.

    A system prompt is the instruction that defines how the agent should behave, what tools it can use, and any rules it should follow when responding to users. For example:

    You are a browser automation assistant. Use the Playwright MCP tools to inspect web pages, interact with browser elements, and report clear test results. Ask for clarification before submitting forms or changing data.
  8. Click Playground at the top right corner of canvas to start testing.

AI agent components​

Use these components below when your flow needs to call KAIZEN APIs, run complex tasks, or add lifecycle control on agent tools.

note

The components below are not exhaustive. To use any other component, search for it in AI Agent Builder.

Call KAIZEN Service​

Use Call KAIZEN Service to call a KAIZEN API from an AI agent flow and return the API response as JSON Result.

To configure the component:

  1. In Service Name, select the KAIZEN service that owns the API.

    The available service options include Ai, Setup, Gateway, Iam, Common, Job, Workflow, Console, Pagescan, Theme, Dbeditor, Report, and Uirenderer.

  2. In API Version, enter the endpoint version, e.g., 1 for v1.

  3. In URL Path, enter the path to call, e.g., /myProfile.

  4. Optionally, in Additional Path, enter an extra path segment to append to the base URL.

    Use Additional Path when the API endpoint requires a request parameter in the path. This value can be provided by the Agent. For example, to retrieve a specific project from Console service, set URL Path to /api/v1/console/projects and Additional Path to /{project_id}. The full endpoint becomes /api/v1/console/projects/{project_id}, where {project_id} is the request parameter.

  5. Use JSON Result as the component output or response.

    The Call KAIZEN Service component in AI Agent Builder

CUGA​

The CUGA (Configurable Generalist Agent) component is an advanced AI agent that executes complex tasks using tools, optional browser automation, and structured output generation.

You can use the CUGA component in flows in place of an Agent component. Like the core Agent component, CUGA can use tools connected to its Tools port and can be used as a tool itself. It also includes additional features:

  • Browser automation for web scraping with Playwright.
    • To enable web scraping, set the component's browser_enabled parameter to true.
  • Custom instructions for the agent to execute.
    • To use this feature, in the component's Instructions input, attach Markdown files containing agent instructions.

Refer to LangFlow > CUGA and GitHub > CUGA for more information.

To configure the component:

  1. In Model Provider, select the language model.

    Options include OpenAI, Anthropic, Google Generative AI, IBM watsonx.ai, Ollama, and Custom.

    You may also need to provide the model name, API key, and any other required configuration.

  2. In Instructions, provide the instructions that the agent must follow.

  3. In Tools, review the tools that the agent can use to complete tasks.

  4. In Input, provide the input for the agent to process.

    CUGA component in AI Agent Builder

ALTK​

ALTK (Agent Lifecycle Toolkit) is an open-source library from IBM Research that makes AI agents more reliable by adding small middleware checks at each stage of an agent's turn: before it calls a tool, after a tool returns, and before it answers. It is not a framework for building an entire agent; it is a set of components that you plug into an existing agent pipeline.

In AI Agent Builder, it appears as the ALTK Agent component, a drop-in replacement for the standard Agent that adds two of these checks to the tool-calling loop.

  • Pre-tool validation (SPARC) reviews a candidate tool call against the conversation and the tool's spec before it runs, and sends the LLM a suggested fix if the call looks wrong.
  • Post-tool JSON processing generates a quick Python snippet to pull out just the relevant fields from a large JSON tool response, so the agent is not given a huge blob that floods its context.

Both features are on by default and can be toggled independently. Using ALTK Agent instead of the standard Agent component gives you more reliable tool calls and a smaller context footprint with no other changes to the flow.

Refer to IBM Research > ALTK and GitHub > ALTK for more information.

To configure the component:

  1. In Model Provider, select the language model.

    Options include OpenAI and Anthropic.

  2. In Language Model, configure the model, API key, and any other required settings.

  3. In Agent Instructions, provide the system prompt with initial instructions and context to guide the agent's behaviour.

  4. In Tools, review the tools that the agent can use to complete tasks.

  5. In Input, provide the input for the agent to process.

  6. Enable Tool Validation to validate tool calls using SPARC before executing.

  7. Enable Post Tool JSON Processing to process tool output through JSON analysis.

    ALTK component in AI Agent Builder

Call the AI agent flow from Workflow Designer​

note

To run an AI agent flow, kaizenadmin needs to update the endpoint name. Refer to this FAQ.

  1. In AI Agent Builder, at the top right corner, click Share > API access > Input Schema.

  2. In the Input Schema window, set the AI agent endpoint name.

    Set the endpoint name of AI agent
  3. Copy the endpoint name from AI Agent Builder.

  4. Open the Workflow Designer. Paste it into the Agent Endpoint Name property.

    Add the endpoint name in Workflow Designer
  5. You can choose to add any of the following optional variables in Workflow Designer:

    • input_value: This stores your prompt for the AI Agent to perform tasks.

    • session_id: This provides the chat context from a session of the AI agent flow.

      note

      It is optional to set the session_id value. If you haven't set this, a random and unique value will be generated.

    Add optional variables

Call the AI agent flow through KAIZEN-provided API endpoints​

note

To run an AI agent flow, kaizenadmin needs to update the endpoint name. Refer to this FAQ.

To call the AI agent flow through KAIZEN-provided API endpoints, perform the following:

1. Define the endpoint​

  1. In AI Agent Builder, at the top right corner, click Share > API access > Input Schema.

  2. In the Input Schema window, set the AI agent endpoint name.

    Set the endpoint name of AI agent

2. Create the service and datasource​

  1. Open the App Designer. On the Resources panel, click Services Services button .

  2. On the Services panel, click Add Service to create a new service e.g., ai.

  3. Expand the new service and create a controller e.g., run_flow.

  4. Expand the controller and create a datasource.

    In the Create Datasource window, provide the following information:

    • Basic Information:

      • Datasource ID: Enter the ID for datasource identity e.g., kaizen_ai_run_flow_v1
    • Connection Details:

      • Method: POST
      • Path: /gateway/ai/api/v1/run/{flow_endpoint}
      • Version (v): 1
      • Params: Leave as undefined
      • Body: Leave as undefined
      • Headers: content-type
    • Advanced Settings:

      • Response Type: Stream
      • Encode Data (Base 64): Off
      • Use Global Timeout: Off
      • Timeout (ms): Configurable by user, e.g., 5000
      • Add Function: Leave as unselected
    Information in the Create Datasource window
  5. Click Apply.

3. Call the endpoint​

  1. In App Designer, click Datasource Source Code Panel button. The Datasource panel opens. Click Create.

  2. In the Create from Datasource window, search for ai and select kaizen_ai_run_flow_v1.

    Create from Datasource
  3. Click Next. The datasource information displays. Check that the identity should be the same with the datasource ID, and the path variables should display flow_endpoint as pre-defined.

    Create Datasource
  4. Add the same endpoint name defined in AI Agent Builder into the flow_endpoint value. Click Create.

    The datasource will look like the following. From here, you can call the AI agent flow.

    Set the endpoint name of AI agent

Last updated on 19 Oct 2026