GPT Chat Task (LLM Task)
Tool Calling
Tool calling allows an LLM to trigger Stubber actions as part of a conversation. When the LLM decides it needs to call a tool, Stubber automatically runs the corresponding action on the stub, and feeds the result back to the LLM so it can continue the conversation.
This is what makes it possible to build AI agents in Stubber — the LLM can look up data, trigger workflows, and make decisions based on real results, all within a single conversation flow.
How it works
- The
gpt_chat_taskruns withfunction_call: "auto"ortool_choice: "auto"(the defaults). - Any action in the current state that has
ai_function_calling: truein itsaction_metais automatically included as an available tool for the LLM. - The LLM receives the messages and the list of available tools.
- If the LLM decides to call a tool, it returns a tool call response naming the action and the parameter values it wants to pass.
- Stubber runs the named action on the stub. The LLM-provided parameter values are available on
stubpost.datainside that action. - Two tasks are automatically injected into the called action — the dynamic stage and the closing stage — described below.
- The LLM receives the result and generates its final response, returned via the feedback action (
_update_from_chat_assistant_task).
The two stages
When an LLM calls a tool, Stubber injects two tasks into the triggered action:
Dynamic stage
An inject_gpt_action_data task runs with submit_to_model: false. It appends the action's result to the chat context as a tool result message, but does not yet submit anything to the LLM.
By default, the following fields from the called action are injected as the tool result:
This can be overridden using action_result_inject_data in the action's ai_details (see below).
Closing stage
A gpt_chat_task runs with submit_to_model: true. It does not add any messages to the context — it simply submits the existing context (now containing the tool result injected in the previous stage) to the LLM to get the final response.
Setting up an action for tool calling
To make a Stubber action available to the LLM, set ai_function_calling: true in the action's action_meta:
The action's name becomes the tool name, its description becomes the tool description, and its fields become the tool parameters. The help text on each field becomes the parameter description.
ai_details
Behaviour for both stages can be configured in ai_details:
action_result_inject_data optional object
Overrides the default set of fields returned to the LLM as the tool result. Each key becomes a named field in the result, and the value is a reference to the data you want to inject.
clear_function_call_results optional boolean
When true, the tool call and its result are removed from the message history after the LLM has responded. This keeps the conversation history clean by stripping out the intermediate tool exchange, leaving only the final assistant response.
Default: false
disable_dynamic_tasks optional boolean
When true, neither the dynamic stage nor the closing stage tasks are added to the called action. The LLM will not receive the result of the action. This is useful for 1-shot tool calls where you want the LLM to trigger an action without needing a response.
Combine disable_dynamic_tasks: true with function_call: {"name": "my_action"} or tool_choice: {"type": "function", "function": {"name": "my_action"}} to force the LLM to call a specific action exactly once, without continuing the conversation.
Default: false
Overriding the stages
Both stages can be overridden per action via ai_details in the action's action_meta. Each override field takes an object of named tasks — you can add multiple tasks and all of them will be injected into that stage.
override_default_ai_dynamic_tasks
Overrides the dynamic stage. Tasks here use the inject_gpt_action_data tasktype and run with submit_to_model: false.
The action_result_inject_data field inside the task overrides the one defined in ai_details.action_result_inject_data. Additional params to merge into the underlying gpt_chat_task can be passed via gpt_chat_params.
override_default_ai_closing_tasks
Overrides the closing stage. Tasks here use the gpt_chat_task tasktype and must include submit_to_model: true. The default closing task only has submit_to_model: true — any additional params you need to set on the final LLM call go here.
Fallback tool result
If disable_dynamic_tasks is true and the LLM issued a tool call, Stubber needs to close the tool call loop to keep the message history valid. In this case, Stubber automatically injects a minimal tool result:
This ensures the conversation remains in a valid state for the LLM on future calls.