Skip to main content

Architecture Patterns

๐Ÿ“ฆ v1.4.0 (Stable)

Archived Version

This is the v1.4.0 documentation. For the latest features, see v1.4.1 docs โ†’

PromptPack has grown from a simple prompt-packaging format into a full-stack specification for conversational AI systems. This page explains how the major building blocks relate to each other and when to use each one.

How the Pieces Fit Togetherโ€‹

A PromptPack is organized in layers. Lower layers are simpler and more universal; higher layers are optional and compose on top of the lower ones.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Agent Loops Bounded iteration + artifacts โ”‚ v1.4
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Skills Progressive knowledge loading โ”‚ v1.3.1
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Agents Inter-system discovery (A2A) โ”‚ v1.3
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Workflow Intra-pack state machine โ”‚ v1.3
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Evals Async quality measurement โ”‚ v1.2
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Validators Inline guardrails โ”‚ v1.0
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Tools & Fragments Shared resources โ”‚ v1.0
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Prompts Core behavior definitions โ”‚ v1.0
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Prompts define what the LLM does. Tools & Fragments provide shared resources that prompts reference. Validators add inline guardrails that block bad output. Evals add async quality measurement that scores and reports. Workflow orchestrates transitions between prompts via a state machine. Agents expose prompts as discoverable services via the A2A protocol. Skills provide progressive-disclosure knowledge that agents load on demand. Agent Loops layer terminal states, visit guards, artifact slots, and execution budgets onto the workflow so iterative, self-correcting patterns stay production-safe.

Each layer is optional โ€” a valid PromptPack only requires id, name, version, template_engine, and at least one prompt. You adopt higher layers only when you need them.

Workflows vs Agentsโ€‹

These two v1.3 features solve different problems and can be used independently or together.

AspectWorkflowAgents
PurposeOrchestrate transitions within a packMake prompts discoverable across systems
MechanismState machine with event-driven transitionsA2A Agent Cards with metadata and tags
ScopeIntra-pack (states reference prompt keys)Inter-system (external services discover agents)
Requiresworkflow top-level fieldagents top-level field
Entry pointworkflow.entry โ€” first state in the machineagents.entry โ€” default agent for incoming requests
Key benefitAutomated routing without caller logicMulti-agent discovery and interoperability

Decision Matrixโ€‹

ScenarioUse Workflow?Use Agents?
Single prompt, no routing neededโ€”โ€”
Multiple prompts, caller chooses which to invokeโ€”โ€”
Automated routing between prompts based on eventsYesโ€”
Prompts need to be discoverable by external systemsโ€”Yes
Automated routing and external discoveryYesYes
Standalone agents communicating via A2A (no internal state machine)โ€”Yes
info

Workflow and agents are orthogonal. A prompt can participate in a workflow state and be an agent member simultaneously. The workflow manages intra-pack state; agents manage inter-system discovery.

Validators vs Evalsโ€‹

Both assess LLM output quality, but they operate at different points in the pipeline and serve different purposes.

AspectValidatorsEvals
Runs when?Inline, every responseAsync, on schedule or trigger
Blocks output?Yes (when fail_on_violation: true)No โ€” scores and reports
ScopePrompt-level onlyPrompt-level or pack-level
Type systemEnum with custom escape hatchFree string (runtimes define types)
MetricsNonePrometheus-style metric declarations
Version introducedv1.0v1.2

Decision Matrixโ€‹

ScenarioUse Validators?Use Evals?
Block toxic or unsafe content before it reaches usersYesโ€”
Monitor tone quality over time with dashboardsโ€”Yes
Enforce character limits on social media responsesYesโ€”
Measure brand voice consistency across all promptsโ€”Yes
PII detection that must never leakYesโ€”
Sample 10% of responses for LLM-judge quality scoringโ€”Yes
Both block bad output and track quality trendsYesYes
info

Validators and evals are complementary, not competitive. Use validators for hard safety guardrails and evals for continuous quality monitoring. The same prompt engineer typically authors both.

Orchestration Patternsโ€‹

The workflow state machine supports several common multi-prompt patterns. Choose based on your use case.

Router + Specialistsโ€‹

A triage prompt classifies requests and routes to specialized prompts.

         โ”Œโ”€ billing โ”€โ”€โ”€โ”€โ”€โ”
triage โ”€โ”€โ”ค โ”œโ”€โ”€ closing
โ””โ”€ technical โ”€โ”€โ”€โ”˜

When to use: Customer support, help desks, any system where incoming requests need classification before handling.

Pipelineโ€‹

Prompts execute in sequence, each processing the output of the previous one.

intake โ”€โ”€ analyze โ”€โ”€ draft โ”€โ”€ review

When to use: Document processing, content generation pipelines, multi-step analysis.

Agent Meshโ€‹

Multiple agents communicate via A2A without a central workflow. Each agent discovers and invokes others through tool references.

researcher โ†โ†’ fact_checker โ†โ†’ writer

When to use: Loosely coupled agents that need to collaborate without rigid sequencing. Use the agents section without workflow.

Hybridโ€‹

Combine workflow orchestration internally with agent discovery externally.

[Workflow: triage โ†’ specialist โ†’ closing]
โ†• A2A
[External systems discover and invoke agents]

When to use: Systems that need both internal routing logic and external interoperability.

Agent Loop (v1.4+)โ€‹

The workflow visits a state repeatedly until it succeeds or hits a guardrail. A code-generation loop, a research-and-refine cycle, a generate-test-fix cycle.

plan โ†’ implement โ‡„ test โ†’ done (terminal)
โ”‚ โ†‘ โ”‚
โ”‚ โ””โ”€โ”€ TestsFailed (loop back, max_visits=5)
โ†“
review (terminal, on_max_visits)

When to use: Self-correcting agents โ€” codegen with test feedback, research crews that refine via critic feedback, drafting workflows where a reviewer sends edits back. Use max_visits + on_max_visits to bound each loop, declare artifacts to flow structured state across visits, and set engine.budget as a global runaway-loop safety net.

Multimodal Integrationโ€‹

The media configuration (v1.1+) composes with all other features:

  • With Prompts: Each prompt can declare its own media config โ€” supported types, format restrictions, size limits, and multimodal examples with parts arrays
  • With Validators: Validators run on the text output regardless of whether the input was multimodal
  • With Evals: Evals can assess multimodal interactions (e.g., an LLM judge evaluating whether the response correctly interpreted an image)
  • With Workflow: A workflow state can route to a prompt that accepts images, while another state routes to a text-only prompt
  • With Agents: Agent input/output modes (input_modes, output_modes) declare which MIME types the agent supports, complementing the prompt-level media config
info

Multimodal and text-only prompts can coexist in the same pack. A pack might have an image-aware product_lookup prompt and a text-only catalog_writer prompt โ€” the media config is per-prompt, not per-pack.

Skills Integration (v1.3.1+)โ€‹

Skills provide progressive-disclosure knowledge loading โ€” modular expertise that agents activate on demand rather than embedding everything in system templates.

Skills vs Fragmentsโ€‹

AspectFragmentsSkills
Resolved when?Compile time (template substitution)Runtime (on demand)
ContentStatic text stringsInstructions, knowledge, behavioral patterns
LoadingAlways included in rendered templateLoaded progressively when relevant
ScopingReferenced explicitly in templatesAvailable to all prompts, filterable per workflow state
Version introducedv1.0v1.3.1

When to Use Skillsโ€‹

ScenarioUse Fragments?Use Skills?
Shared text like company intro or disclaimersYesโ€”
Domain expertise loaded on demandโ€”Yes
Static template sectionsYesโ€”
Context-specific behavioral instructionsโ€”Yes
Small reusable text blocksYesโ€”
Large knowledge bases scoped per workflow stateโ€”Yes
info

Fragments and skills are complementary. Use fragments for compile-time text substitution and skills for runtime knowledge loading. A pack can use both.

Agent Loops Integration (v1.4+)โ€‹

Agent loops are not a new top-level section โ€” they are four small fields layered onto the existing workflow block. They turn an unbounded state machine into a production-safe iterative agent.

Agent Loops vs Plain Workflowโ€‹

AspectPlain Workflow (v1.3)Workflow + Agent Loops (v1.4)
TerminationTerminal = empty on_event: {} (implicit)terminal: true (explicit)
Loop boundsNone โ€” relies on event design to convergePer-state max_visits + optional on_max_visits redirect
Cross-visit stateConversation context only (persistent/transient)Named artifacts slots (replace/append) โ€” pointers, summaries, structured results
Global safety netNoneengine.budget: max_total_visits, max_tool_calls, max_wall_time_sec
DebuggingReplay conversation logReplay artifact transitions (time-travel debugging)

When to Reach for Agent Loop Fieldsโ€‹

ScenarioUse terminalUse max_visitsUse artifactsUse engine.budget
Linear pipeline (intake โ†’ analyze โ†’ close)Yes (mark exit states)โ€”โ€”โ€”
Code generation that loops with test feedbackYesYesYes (commit_sha, test_report)Yes
Research-and-critique cycleYesYesYes (draft, critique log)Yes
Long-running batch jobs that must hard-stop after N minutesโ€”โ€”โ€”Yes
Anything where a model could loop forever in productionStrongly recommendStrongly recommendOptionalStrongly recommend
Backwards compatibility

v1.3 packs are valid v1.4 packs unchanged. The new fields are opt-in. A state without terminal/max_visits behaves exactly as it did in v1.3.

Feature Compatibility Matrixโ€‹

FeatureVersionCombines With
Promptsv1.0Everything
Tools & Fragmentsv1.0Prompts, Workflow, Agents
Validatorsv1.0Prompts
Parametersv1.0Prompts, Model Overrides
Tested Modelsv1.0Prompts
Model Overridesv1.0Prompts
Media (multimodal)v1.1Prompts, Agents (MIME types)
Evalsv1.2Prompts (prompt-level), Pack (pack-level)
Workflowv1.3Prompts (via prompt_task), Agents, Skills (state scoping), Agent Loops
Agentsv1.3Prompts (via members), Workflow
Skillsv1.3.1Workflow (state-scoped filtering), Agents
Agent Loops (terminal, max_visits, artifacts, engine.budget)v1.4Workflow (extends WorkflowState and WorkflowConfig.engine)

Next Stepsโ€‹