Icon

Group 3 - Implement an agentic system

<p><strong>Agentic AI Learnathon - Group 3</strong></p><p>In this exercise, you will implement an "Ask Me Anything" AI agent. The agent takes a user question as input and identifies which tool(s) to call in order to answer it. You will also practice calling tools and implementing a loop to build knowledge through recursive tool calls.</p>
Recursive Loop Start

(come back here in Step 8)

Group 3 - Implement an Agentic system

🤖 Agent - Ask me anything


In this exercise, you will implement an "Ask Me Anything" AI agent. The agent takes a user question as input and identifies which tool(s) to call in order to answer it. You will also practice calling tools and implementing a loop to build knowledge through recursive tool calls.

Step 1. Authenticate and connect to an LLM

  1. Configure the Get Api Key component to provide a valid API key for OpenAI. Ask your instructor to get username and password.

  2. Pass the key as a flow variable to the OpenAI Authenticator node.

  3. Use the OpenAI Chat Model Connector to connect to the default model.


Step 2. Type a question for the agent

Open the view of this component by clicking the 🔍 icon.

  1. Type a question for the agent,
    using one the sample questions as inspiration.

  2. Click Close and Apply temporarily to save your input.

List of tools and tool definitions

The following nodes extract the tool definitions of all the workflows in the Tools folder.

This information will be used by the LLM to select the appropriate tool and generate the correct input argument to answer your question.



🧠 Step 3. Define the brain of the agentic system

  1. Add a Chat Model Prompter node. Provide in input

    • The model selected in Step 1.

    • The user question from Step 2.

    • The tool definitions from the Get tool definitions component. Activate the third input port by clicking the plus button ⨁.

  2. Write the system prompt to define the agent’s task in plain language.

    • Tell the agent to answer user questions.

    • Let it use tools based on their descriptions.

    • Ask it to handle missing tools politely and stay concise.

  3. Make sure all columns are correctly selected in the "Tool Calling" options.


In the 💡Help metanode above you can find a system prompt example.

🤔 Step 4. Is there a tool to call?

  1. With a Row Filter node, filter the last row of the table produced by the Chat Model Prompter node.

  2. Convert the table values to flow variables with the Table Row to Variable node.

  3. With a Variable Expression node create two new variables:

    • end (BOOLEAN): TRUE if tool name = "missing", FALSE otherwise

    • port (INTEGER): 0 if the variable end is TRUE, 1 otherwise



💡Help

If you are having troubles creating prompts and expressions,
have a look at the Help metanode.

✨ Alternatively, click Ask K-AI in the Expression node
and let the copilot build an expression for you!

🔀 Step 5. CASE Switch

  1. Connect the CASE Switch Start node to the output of the Chat Model Prompter node from Step 3. Additionally, provide the flow variables created in the Step 4.

  2. Configure the node to activate port 0 or 1 according to the value of the port flow variable:

    • port 0 = no tool to call - end

    • port 1 = call the selected tool



Step 6. Retrieve the tool to be called

  1. Add a Row Filter node to the bottom output of the CASE Switch Start node. Filter the last row of the table.

  2. Retrieve the location of the tool selected by the LLM. Use a Value Lookup node to lookup the tool name column with the title column from the Get tool definitions component.

  3. Use a Table Row to Variable node to convert the Tool location column to a flow variable.



☎️ Step 7. Call the selected tool

  1. Add a Call Workflow (Row Based) node. Give it in input

    • The last row of the conversation (Row Filter from Step 6).

    • The Tool location flow variable (Table Row to Variable from Step 6).

  2. Configure the node to call the workflow in the Tool location flow variable.

  3. Select the JSON column Tool call argument as input parameter.

  4. Connect the output of the Call Workflow (Row Based) to the Append tool output to conversation metanode.

  5. Important! Some tools are intelligent tools that require credentials to access the LLM.

    1. Open the workflows in the Tool folder.

    2. Add the necessary credentials where required.

    3. Reset all the nodes and save the workflow.


❗Troubleshooting


  1. If the Call Workflow node gives an error during the execution

    • Open the tool workflow and make sure that it is correctly configured and all nodes can be executed.

    • If it is an intelligent tool, make sure that it contains the credentials for the LLM.

    • Reset all the nodes in the tool workflow, save it and close it.

  2. If the tool always produce the same output regardless of the input

    • Verify that the User Question component is still using your custom input and hasn’t reverted to the default.

    • Open the configuration of the Call Workflow node and make sure that you have selected the Tool input column as input parameter.

    • Make sure all columns are correctly selected in the Chat Model Prompter node.

🔁 Step 8. Recursive loop

Up to this point, the agent has only been able to call a single tool. In this step, you'll enable your agent to call multiple tools and generate a more complete response based on the combined output.

  1. Go to the placeholder and add a Recursive Loop Start node before the Chat Model Prompter node.

  2. Then, add a Recursive Loop End node, and connect the output of the CASE Switch End node to both of its inputs. Configure the Recursive Loop End:

    • Maximum number of iterations: 10

    • End loop with variable: end

    • ✅ Collect data from last iteration only


Step 9. Check agent output

Open the view of this component by clicking the 🔍 icon. It displays the user question, the agent’s response, and the history of tool calls.



Append tool output to conversation
Get API Key
Help - Prompt and Expressions
List all workflowtools
List Files/Folders
CASE Switch End
Agent output
Top: no tools to callBottom: call a tool
CASE Switch Start
User Question
Extract informationfrom Container Input (JSON)in tools workflow
Get tool definitions

Nodes

Extensions

Links