Skip to content

Instruction Node

NodeType = Instruction (wire ordinal 5)

Attaches a named instruction string to the current interaction. A downstream Generate node can reference it inside a Mustache template via the {{#instructions}} list or the {{instruction_<name>}} flat key.

The node itself does not call a model and does not modify the conversation history that the model sees. It only adds an InstructionComponent to the current turn's interaction data, which the projection stage picks up when rendering the Generate node's template.


Parameters

Param Required Mutable Default Description
instruction Yes Yes The instruction text. Exposed as {{instruction_<node_name>}} and included in the {{#instructions}} list under {{text}}.

instruction can be updated at runtime via ChangeAgentParamRequest while the agent is idle — see Change Agent Parameters at Runtime.


Exit routes

Exit Condition
default Always taken after the instruction is attached.

Mustache exposure

Given a node named greeter with instruction = "Welcome the user.":

Template expression Renders to
{{instruction_greeter}} Welcome the user.
{{#instructions}}{{name}}: {{text}}{{/instructions}} greeter: Welcome the user.

Multiple Instruction nodes in one graph each contribute one entry to the {{#instructions}} list, in the order they executed.


Example

from tryll_client import GraphDescription, NodeType

graph = (
    GraphDescription()
    .add_node("greeter", NodeType.Instruction, {
        "instruction": "You are a friendly greeter. Welcome the user warmly.",
    })
    .add_node("generate", NodeType.Generate, {
        "template":  "{{instruction_greeter}}",
        "placement": "before_user_as_system",
    })
    .wire("greeter",  "default", "generate")
    .wire("generate", "default", "END")
    .set_start_node("greeter")
    .set_default_model_name("Llama 3.2 3B Instruct (Q4_K_M)")
)

# Change the instruction without recreating the agent:
agent.change_param("greeter", "instruction", "You are a stern librarian.")
namespace TC = Tryll::Client;

TC::GraphDescription graph;
graph.AddNode("greeter", TC::NodeType::Instruction, {
         {"instruction", "You are a friendly greeter. Welcome the user warmly."},
     })
     .AddNode("generate", TC::NodeType::Generate, {
         {"template",  "{{instruction_greeter}}"},
         {"placement", "before_user_as_system"},
     })
     .Wire("greeter",  "default", "generate")
     .Wire("generate", "default", "END")
     .SetStartNode("greeter")
     .SetDefaultModelName("Llama 3.2 3B Instruct (Q4_K_M)");

// Change the instruction without recreating the agent:
agent.ChangeParam("greeter", "instruction", "You are a stern librarian.");