# Interface Instruction

All Known Implementing Classes:
  `Instruction.Provider, Instruction.Static`

public sealed interface Instruction permits Instruction.Static, Instruction.Provider
Represents an instruction that can be provided to an agent to guide its behavior.

In the instructions, you should describe concisely what the agent will do, when it should defer to other agents/tools, and how it should respond to the user.

Templating is supported using placeholders like `{variable_name}` or `{artifact.artifact_name}`. These are replaced with values from the agent's session state or loaded artifacts, respectively. For example, an instruction like `"Translate the following text to {language}: {user_query}"` would substitute `{language}` and `{user_query}` with their corresponding values from the session state.

Instructions can also be dynamically constructed using `Instruction.Provider`. This allows for more complex logic where the instruction text is generated based on the current `ReadonlyContext`. Additionally, an instruction could be built to include specific information based on based on some external factors fetched during the Provider call like the current time, the result of some API call, etc.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static final record`
  `Instruction.Provider`
  Returns an instruction dynamically constructed from the given context.
  `static final record`
  `Instruction.Static`
  Plain instruction directly provided to the agent.