Skip to content

Agentic Concepts

Prompty agents are still Prompty prompts: a .prompty file renders and parses into messages. The agentic layer starts when you run a conversational turn with tools or runtime controls.

This section is for application developers who need to build, debug, or govern tool-using agents. After reading it, you should be able to answer:

  • where the boundary is between a .prompty file and host runtime code;
  • how a single turn() differs from a full chat session;
  • when messages are prepared, appended, trimmed, compacted, or steered;
  • where to enforce policy with guardrails instead of prompt instructions;
  • how to observe and stop a long-running tool loop.
flowchart TD
    A[".prompty file"] --> B["prepare()\nrender + parse + thread expansion"]
    B --> C["turn()\nagentic runtime"]
    C --> D["LLM call"]
    D --> E{"tool calls?"}
    E -- yes --> F["dispatch tools"]
    F --> G["append tool result messages"]
    G --> C
    E -- no --> H["process final response"]

    C -. "optional controls" .-> I["events"]
    C -. "optional controls" .-> J["cancellation"]
    C -. "optional controls" .-> K["context budget + compaction"]
    C -. "optional controls" .-> L["guardrails"]
    C -. "optional controls" .-> M["steering"]

The key distinction is:

  • prepare() renders the template and parses role-marked text into messages.
  • turn() runs one user turn and, if needed, loops internally for tool calls.
  • Tool-loop iterations do not re-render the template. They mutate the prepared message array by appending assistant/tool messages.
  • External user turns call turn() again. If you pass conversation history as a thread input, that thread is expanded during the next prepare() call.
ConceptWhat it controlsStart here
Agent loopHow tool calls are executed and fed back to the modelAgent Loop
Runtime controlsThe per-iteration order for cancellation, steering, context, guardrails, model calls, and toolsRuntime Controls
GuardrailsValidate or rewrite inputs, outputs, and tool argumentsGuardrails
Context budgetTrim messages before model callsContext & Compaction
CompactionReplace dropped-message summaries with a custom summaryContext & Compaction
SteeringInject messages between loop iterationsSteering
EventsObserve status, tool calls, message updates, completion, errorsEvents & Cancellation
CancellationStop a running loop cooperativelyEvents & Cancellation
Parallel toolsRun multiple tool calls concurrentlyTool Execution
RetriesRetry transient LLM failures inside the loopTool Execution

The agentic controls are runtime API options, not frontmatter fields. They are available in the v2 runtimes:

RuntimeAgent loopGuardrailsCompactionSteering
PythonYesYesYesYes
TypeScriptYesYesYesYes
C#YesYesYesYes
RustYesYesYesYes