View Source Agens.Prefixes (agens v0.2.0)
The Prefixes struct is used to configure prompt prefixes for building advanced prompts.
For each field used in the prompt (based on the configuration of Servings, Jobs, and their Nodes), a heading will be added, as well as some additional detail.
For example, if you are running an Agens.Job and have defined an objective for the current Agens.Job.Node, the following will be added to the prompt:
## Node Objective
The objective of this node is to {{node.objective}}However, if you have not defined an objective for the current Agens.Job.Node, the heading and detail will also be omitted.
Default prefixes are returned by default/0. To customize, build an %Agens.Prefixes{} struct and set it on the :prefixes field of Agens.Serving.Config. To share custom prefixes across many Servings, define a module that returns the struct and reference it from each Serving's Config.
Fields and Sources
Each field maps a prompt section to a value sourced from the running Agens.Message. Fields with nil/empty values are omitted from the final prompt entirely.
| Field | Source |
|---|---|
context | Agens.Serving.load_context/2 (derived from agent_id) |
objective | Agens.Job.Node.objective |
description | Agens.Job.Config.description |
input | The original value passed to Agens.Job.run/3 (never overwritten across Nodes) |
previous_result | The result of the previous Node in the Job (nil on the starting Node) |
schema | JSON schema built from the Router's declared outputs/1 (plus response/tool-call shape) |
retry | Validation/retry reason when re-running a Node |
tool_defs | Agens.Job.Node.tools (MCP-style tool schemas) |
tool_calls | Tool call requests emitted by the LM in the previous turn |
tool_results | Resolved tool-call results merged back from Agens.Serving.tool_call/3 |
resources | Loaded Agens.Resource content (from Agens.Serving.load_resource/3) |
Note:
Depending on your use case, some fields may be more relevant than others. It's often beneficial to be more descriptive at granular levels (Node
objective, Routeroutputs) while taking a more minimal approach at higher levels (Jobdescription).
Summary
Functions
Returns the default Agens.Prefixes struct used when a Serving's Agens.Serving.Config.prefixes is nil.
Types
Functions
@spec default() :: t()
Returns the default Agens.Prefixes struct used when a Serving's Agens.Serving.Config.prefixes is nil.
Customize by building your own struct (typically starting from this default and overriding select fields) and setting it on the relevant Agens.Serving.Config.