A template is a text structure with placeholders that are filled with values before an LLM interaction. Templates standardize prompts for particular purposes and can also implement prompting techniques. section 4.1.2
In an LLMAgent, LLMAgentTemplates stores purpose-specific strings, including system messages and instructions for task execution. The agent can use default templates or receive a customized template set. section 4.1.2
Hailstone task instruction
An instruction template specifies the rules for generating a sequence and contains a {x} placeholder. Filling it with 4 produces the task instruction; the agent uses a tool to generate 4 -> 2 -> 1. section 4.3
A reflection template can give an LLM an episode’s task and result and ask it to produce a lesson for memory. The reflective-memory recipe accepts a user-supplied template or uses its default. section 7.4.2
Listing 4.2 Implementing LLMAgentTemplates
# llm_agents_from_scratch/agent/templates/llm_agent.py
from typing import TypedDict
class LLMAgentTemplates(TypedDict):
"""Prompt templates dict for LLMAgent."""
system_message: str
# for TaskHandler #A
get_next_step: str
step_rollout_chat_message: str
step_rollout_content_instruction: str
step_rollout_content_tool_call_request: str
run_step_system_message_without_rollout: str
run_step_system_message: str
run_step_user_message: str
default_templates = LLMAgentTemplates( #B
… #C
)The LLMAgentTemplates TypedDict lists the purpose-specific string fields used by the agent. section 4.1.2




























