Module instruction

Module instruction 

Source
Expand description

Instruction templating — inject state values into instruction strings.

Replaces {key} placeholders with values from the state container. Supports optional {key?} syntax that resolves to empty string if missing.

Structs§

TemplateInstruction
A full template-engine instruction (feature templates) — minijinja (Jinja2 syntax: conditionals, loops, filters) over the session state, mirroring ADK’s use_jinja2 instructions. The whole state is exposed as state (subscript prefixed keys: {{ state["session:turn_count"] }}), and every key that is a bare identifier is also available at top level ({{ name }}). Falls back to the empty string for missing values under Jinja’s default undefined semantics.

Traits§

InstructionProvider
A dynamic instruction source — the ADK “instruction provider” pattern: instead of a string fixed at build time, the instruction is produced from live session state on every model request (persona switching, risk-driven guardrails, multi-tenant instructions without rebuilding the agent). Any Fn(&State) -> String closure is a provider.

Functions§

inject_session_state
Replace {key} placeholders in template with values from state.