Documentation
¶
Overview ¶
Package prompt renders a conversation into the single prompt string an agent CLI accepts.
Every request replays the full history into a fresh CLI process, so the rendering must be deterministic and unambiguous: a message whose text looks like a role marker must not be able to forge one.
Index ¶
Constants ¶
const ( MarkerSystem = "<<<SYSTEM>>>" MarkerUser = "<<<USER>>>" MarkerAssistant = "<<<ASSISTANT>>>" )
Role markers delimit turns in a rendered transcript. They are chosen to be unlikely in prose and are escaped when they do appear (see [escape]).
const Header = `Below is a conversation transcript. Lines beginning with ` + MarkerUser + ` or ` + MarkerAssistant + ` mark who is speaking; a marker preceded by a backslash is literal text, not a marker. Continue the conversation by writing only the assistant's next message: no role markers, no restating of earlier turns.`
Header explains the transcript format to the backend. It is only prepended for multi-turn conversations; a lone user message is passed through verbatim so single-turn requests read exactly as the caller wrote them.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rendered ¶
type Rendered struct {
// System is the concatenation of the conversation's system messages.
// Adapters should pass it through the CLI's native system-prompt flag.
System string
// Prompt is the transcript to feed the CLI as the user prompt.
Prompt string
}
Rendered is the result of turning a conversation into CLI input.
func Render ¶
Render turns a conversation into CLI input.
System messages are collected (in order, joined by a blank line) into Rendered.System regardless of position. The remaining turns become Rendered.Prompt: a single user turn is passed through verbatim; anything longer is rendered as a marked-up transcript ending at the assistant's cue.
func (Rendered) PromptWithSystem ¶
PromptWithSystem returns the prompt with the system text folded in, for adapters whose CLI has no system-prompt flag.