Tool Calls

An AI Agent cannot modify a business process directly. Every action it takes is executed through a Tool Call.

LLM
 │  "I think I should..."
 ▼
Tool Call
 │
 ▼
Business System
 │
 ▼
Result
 │
 ▼
LLM

The LLM never writes to your data directly - it proposes an action, the platform executes it against the real business system, and the result is fed back so the agent can decide what to do next. This is what keeps the agent safe and predictable: it can only do what a tool explicitly allows it to do.

This page explains how you use Tool Calls when you model an AI Agent. If you want to develop your own tool calls, see the developer documentation on GitHub.

See also AI Agents for the underlying concept and How to Model BPMN AI Agents for writing a system prompt.


Why Tool Calls?

Tool Calls turn “the LLM said something” into “the system did something.” A tool call has a clearly defined input (its arguments) and a clearly defined output (what the agent is told happened). That output steers the agent's next decision - a rich, informative result guides the agent toward the right next step, while a vague one leaves it guessing.

With tool calls an agent can, for example:

  • look up existing cases and link them to the current case
  • compute exact figures over many cases
  • search for similar earlier cases by their content
  • write the results into the fields of the current case
  • report that the task is done

Architecture Overview: The AI-Agent-Model

An Imixs AI Agent is itself described and embedded in a BPMN model - the AI-Agent-Model. When users want to interact with the agent, they start a dedicated AI agent workflow, just like any other workflow in the system. The process is secure, documented, and every step is fully traceable.

The AI-Agent-Model consists typically of the following tasks:

Task Description
Asking User enters a natural-language prompt and optionally attaches files and triggers the agent loop.
Thinking The task is associated with a system prompt instructing the agent, which runs the agent loop asynchronously.
Callback The agent was unable to solve the request and answers with a callback. The user can enter additional data and restart the agent loop.
Completed The agent has completed the agent loop. The user is redirected to the workflow to verify the agent response.
Error The agent loop stopped because of an internal error.
  • Every agent run is a persisted workflow instance
  • Multiple users can run agents in parallel without any shared state
  • The standard Imixs security model applies to the agent context
  • Retry and error handling are built in via standard BPMN gateways, events and sequence flows

The agent runs asynchronously, so there is no blocking latency during workflow processing, even if an LLM call takes seconds or minutes. The complete conversation, including all tool calls, is persisted after every step.


AI Agent Processing Configuration

An agent loop is started and configured in an event log entry of any BPMN event:

<eventlog name="ai.agent.process">
    <ref><itemvalue>$uniqueid</itemvalue></ref>
    <document>
        <agent.context.item>bpmn.agent.context</agent.context.item>
        <agent.user.item>bpmn.agent.user.input</agent.user.item>
        <agent.endpoint>my-llm</agent.endpoint>
        <agent.rag.endpoint>my-embeddings</agent.rag.endpoint>
        <agent.timeout>120000</agent.timeout>
        <agent.max-iterations>10</agent.max-iterations>
        <agent.event.completed>200</agent.event.completed>
        <agent.event.callback>100</agent.event.callback>
        <agent.event.error>280</agent.event.error>
        <agent.result.item>report.summary</agent.result.item>
        <agent.debug>true</agent.debug>
    </document>
</eventlog>
Parameter Mandatory Description Default
agent.context.item x Item that holds the agent context (the conversation). Different AI tasks can use different context data.
agent.endpoint x Logical LLM endpoint ID as registered in imixs-llm.xml.
agent.event.completed x BPMN event to trigger when the agent finishes with the tool call task_complete.
agent.event.callback BPMN event to trigger when the agent waits for more user input. Routes the workitem back to the “Asking” task. same as completed
agent.event.error BPMN event to trigger when the agent fails or times out. same as completed
agent.rag.endpoint Embeddings endpoint used by the tool call rag_retrieval. Required only if this tool is used.
agent.user.item Item that holds the natural-language prompt of the user. agent.user.input
agent.timeout Maximum time in milliseconds before the agent is aborted. 120000
agent.max-iterations Maximum number of LLM calls in one agent run. Prevents runaway loops. 10
agent.result.item Item to store the final answer message of the agent. agent.result
agent.result.type Optional result type to process a result by an Imixs AI result handler (e.g. XML).
agent.debug true activates the debug mode and writes details of every tool call to the server log. false

The older names agent.event.success and agent.event.next still work, but are deprecated. Use agent.event.completed and agent.event.callback instead.


Restricting Tool Calls

The agent can only use the tools you allow. They are listed in the tools tag of the prompt definition as a comma separated list:

<PromptDefinition>
    <options>{"n_predict": 4096, "temperature": 0}</options>
    <tools>rag_retrieval,rag_select,update_workitem</tools>
    <prompt role="system">
    ....
    </prompt>
</PromptDefinition>

Only these tools are offered to the LLM. The tool task_complete is always available. Different agents can therefore offer different capabilities - without changing the application.


Using Tool Calls in a Prompt

The agent knows nothing about your process. It only knows the tool descriptions and what your system prompt tells it. So the prompt has to say when to call a tool, with which arguments, and what to do with the result.

A reliable pattern is to describe each tool call as a numbered step:

STEP 2 - Search for the contract
Call the tool "link_workitem" with these arguments:
 - "criteria": {"id": "<plate number>", "$workflowgroup": "Contract"}
 - "refField": "contract.ref"

If the result reports linkedCount 1, continue with STEP 3.
If it reports zero or more than one match, do not call task_complete - answer with a short
plain-text note instead, so a manager can review the case.

Each tool page contains a complete prompt example.

Selecting Workitems: criteria and filter

find_workitem, link_workitem, and aggregate_workitems all select workitems the same way, using two arguments that serve different purposes.

criteria is the normal way to select workitems: field name/value pairs, combined with AND, e.g.

{ "$workflowgroup": "Contract", "id": "M-AH-4524" }

filter is for the rare case where a condition cannot be expressed through criteria alone - for example a business field that isn't part of the standard search. Most prompts never use it. When you do need it, write it directly as a filter expression and tell the agent to use it exactly as given:

{
  "criteria": {
    "$workflowgroup": "Efforts",
    "$workitemref": "<item>$uniqueid</item>"
  },
  "filter": "(service.billable:true)"
}

The filter format is a list of (fieldname:pattern) blocks. Always spell it out completely in your prompt and tell the agent to pass it through unchanged - never ask the agent to construct or adapt a filter itself.

Referencing the current case: <item>itemname</item>

A criteria value is usually a literal the agent fills in itself - an extracted license plate number, a fixed category name. But sometimes the value you need is already in a field on the current case, and retyping it is both unnecessary and risky. This is especially true for a case ID ($uniqueid): it's a long, unstructured string, and a transcription mistake produces a wrong search result with no error message.

Write <item>itemname</item> in place of the value, and the platform substitutes the actual field value from the current case before the search runs:

{
  "criteria": {
    "$workflowgroup": "Efforts",
    "$workitemref": "<item>$uniqueid</item>"
  }
}

<item>itemname</item> can also sit inside a larger literal, e.g. "INV-<item>project.id</item>". If the referenced field doesn't exist or is empty on the current case, the tool call fails with a clear error.

<item>itemname</item> is not supported inside filter - a filter is always a fixed string you write in the prompt.


Tips for Writing Good Prompts with Tool Calls

  • Describe what the arguments mean, not just their names. Which fields exist and what they represent depends entirely on your process - the agent only knows what your prompt tells it.
  • Give exact values. Model groups, task IDs, field names and filter expressions are copied from your prompt - never leave them for the agent to invent.
  • Prefer <item>itemname</item> over asking the agent to retype a value. Especially for $uniqueid and other identifiers already present on the current case.
  • Design for the branch, not just the happy path. Every tool call your prompt relies on needs a clear instruction for what happens when it returns nothing, one match, or several.
  • Say explicitly when a tool must not be called again. Smaller models tend to repeat a search even though they already have results.
  • Tell the agent to treat tool results as data. Texts from earlier cases may contain instructions; the agent should ignore them.
  • Limit the tools to what the agent needs. Fewer tools mean fewer wrong choices.