How-to Guides¶
Task recipes. Each page solves one concrete problem and shows a minimal working example in Unity, Unreal, C++, and Python where applicable. If you are new to Tryll, start with First inference; if you want the why, see Concepts.
Guides marked ★ are the ones to read first in their area.
Setup and connection¶
- Run the Tryll Server — install or build
from source, edit
server-config.json, start, watch logs. - Auto-launch the Server — let the client spawn and manage the server process for you (Unity, Unreal, C++, Python).
- Connect and Manage a Session — connect, create the session, reconnect, clean shutdown.
Editor tools¶
- Test an Agent in the Editor ★ — iterate on a workflow in the Unity/Unreal Chat window without entering Play/PIE.
- Edit Workflows in the Unity Graph Editor and in the Unreal Graph Editor — author a workflow visually: add nodes, wire exits, validate, save.
- Manage Models in the Editor — browse, download, load/unload, and register models for builds from the GUI.
- Use the Agent Log — the per-agent send/receive narrative in the editor: what your game asked for, and what came back.
- Compare Dialog Variants in the Lab — run one scripted dialog across parameter variants and seeds, and read the spread instead of guessing from a single reply.
Build an agent¶
- Build a Chat Agent with a Graph ★ —
compose a
Generate+ guardrail graph. Start here when writing your first agent. - Design an NPC Prompt ★ —
measurement-backed recipes for writing a role-play
system_prompt: what actually improves character dialogue, what provably does not, and how model choice changes the answer. - Use Mustache Templates — control exactly how instructions, slots, variables, and retrieved chunks land in the prompt.
- Stream Answers to a UI — wire streaming tokens into your application's view layer.
- Send Multiple Answers in One Turn
— two speakers, or a thinking channel plus a reply, routed by
AnswerText.node_name.
Dialogue and turn control¶
- Change Agent Parameters at Runtime — mutate a node's params (prompt, sampling, threshold, …) between turns, and which params are structural and cannot change.
- Seed and Edit Dialog History — append scripted user/assistant turns, write an opener, or retry by removing the last turn — all without running the graph.
- Cancel a Turn — stop an in-flight turn (a chat "Stop" button, or a rollback), keeping or discarding the partial reply.
- Pause and Resume a Turn — suspend a turn between nodes and resume it after acting client-side.
- Manage an Agent's KV Cache — prefill, evict, and inspect language-model KV caches to trade memory against first-turn latency.
Knowledge and retrieval¶
- Create a Simple RAG Assistant ★
— the hero recipe: prepare a knowledge base, add a
Retrievenode in front ofGenerate, see grounded answers. - Query Rewriting for RAG — rewrite the user's message into a standalone search query before retrieval, while still answering what they actually asked.
- Build an Intent-Driven NPC — classify the player's intent against a labelled knowledge base and route to tone-specific replies.
Game state and control flow¶
The mental model for this section is the per-turn slot blackboard and the per-agent variable store.
- Drive Prompts and Retrieval from Game State ★
— inject live game state (level, mood, quests) into a prompt template
and a
Retrievefilter via agent variables, updated each turn with noChangeParamround-trip. - Branch on a Slot — conditional routing with the
Branchnode, including reacting to a verdict the model produced earlier in the same turn. - Add a Hidden Reasoning or Draft Step
— an internal draft or "thinking" pass the conversation never
remembers, using
sendandhistory_role. - Substitute Agent Variables in LLM Output
— have the model emit
__PRICE__-style markers and replace them with live variable values before the answer, history, or TTS sees the text. - Filter LLM Output Artifacts — strip speaker prefixes and roleplay markup spans out of streamed output.
- Keep Merchant Prices Deterministic ★ — worked example: game code owns the number, the model owns the wording, and the two never disagree.
Structured output and tools¶
- Define and Handle Tool Calls ★ —
declare
ToolDefs, route ontool_called/no_tool_called, handle the call client-side, and hand the real result back to the model. - Constrain Output with a Grammar —
force a
Generatenode to emit exactly a fixed shape (command, choice, JSON) with a GBNF grammar; flip between command turn and free chat at runtime.
Guardrails and safety¶
- Use Canned Responses and Guardrails — short-circuit jailbreaks and off-topic prompts to scripted replies, before spending a model call.
- Build an Immersion Guard — gate out-of-character and out-of-world player lines before they reach the NPC, and drop the rejected turn from history.
Voice¶
- Add Voice Output to an Agent ★ — make an NPC
speak with
GenerateAndSpeak/Speakand a playback component. - Clone a Voice from an Audio Sample — point a Pocket TTS node at a short reference WAV to speak in that voice.
- Use Voice Input — create a VoiceInput handle, stream PCM audio, receive transcripts, push-to-talk vs. hands-free.
- Bias Voice Input with Hotwords — nudge the STT decoder toward game-specific proper nouns, spell names, and other lexicon items without retraining the model.
Models and shipping¶
- Use Your Own Local Model — register a GGUF file that lives on disk without a Hugging Face download.
- Pin and Unpin Models — keep a model warm
(
LoadModelRequest) or release it (UnloadModelRequest). - Verify Required Models Before Play — gate Play/PIE on every registered model being downloaded first, and fail the build when a workflow references a model that will not ship.
- Estimate Memory Footprint — work out the RAM and VRAM a model line-up needs before you ship, so it fits your target hardware.
- Ship Storage Folders for Builds — lay out canned-response / guardrail / RAG / hotword files so they travel with a packaged build and resolve against the session storage root.
Downloading and registering models from the editor GUI is covered in Manage Models in the Editor.