Skip to main content

Overview

Artaios’s PromptConfig provides sophisticated prompt engineering capabilities through dynamic context control, few-shot examples, and intelligent history management. This enables precise control over what information reaches your LLM.

Core Concepts

Message Ordering

Artaios constructs prompts in an optimal order for LLM attention:
1

System Prompt

Highest attention - Behavioral instructions and role definition
2

Few-Shot Examples

Teaching patterns - Static examples showing desired behavior
3

Conversation History

Dynamic context - Previous messages (configurable)
4

Current User Input

Highest attention - The current task or question
This ordering leverages the primacy and recency effects in LLM attention, placing the most important information at the beginning and end.

PromptConfig Schema

Template Variables

Artaios supports dynamic template variables in your system_prompt using {{ variable }} syntax. Variables are substituted recursively before the prompt is sent to the LLM, enabling powerful dynamic context injection.

Variable Categories

Custom Variables

Dynamic values from the variables system: {{ variables.name }}

Prompt Library

Access stored prompts from database: {{ prompts.name }}

User Input

Current user message content: {{ user_input }}

Conversation History

User-visible message history: {{ history }} / {{ history[N] }}

Full Execution History

Complete trace with internal messages: {{ full_history }}

Structured Outputs

Data from previous agents: {{ agent.output.field }}

Agent Outputs

Non-structured agent responses: {{ agent.output }}

1. Prompt Library Variables

Access reusable prompts stored in the database with automatic user/company scoping. Example:
Prompt Reusability: Store common instructions in the prompt library and reference them across multiple agents. Update once, apply everywhere.
Variables in Prompt Library: You can use template variables inside prompt library prompts! For example, a stored prompt can contain {{ user_input }}, {{ history }}, or even other {{ prompts.* }} references. The system resolves them recursively (up to 10 iterations).Example Prompt Library Entry:
Usage:
This enables powerful prompt composition and reusability!

2. User Input Variable

Access the current user’s message content. Example:

3. Conversation History Variables

Access formatted conversation history (user-visible messages only, excludes internal tool calls).
Important: Structured output from agents is NOT included in history variables. Use {{ agent_name.output.field }} template variables to access structured data.
Example:
Output Format:
Structured Output Exclusion: The history variables only include user-visible text messages. Structured output data from agents with structured_output enabled is excluded from these history arrays and must be accessed via specific template variables.
History vs include_history: You can use {{ history }} template variable for formatted history in your system prompt, or use include_history: true to add messages to the message list. They serve different purposes.

4. Full Execution History Variables

Access complete execution trace including internal messages, tool calls, and tool results. Example:
Output Format:
Full History vs History: {{ full_history }} includes internal messages and tool execution details. Use it for debugging, analysis, or when agents need to understand the complete execution flow.

5. Structured Output Variables

Access structured data from previous agents in multi-agent workflows.
Structured outputs are stored internally under the key "agent_name.output". There is no output_name field — the key is always agent_name.output.
Multi-Agent Example:
Agent Coordination: Structured outputs enable sophisticated multi-agent workflows where downstream agents can access precise, typed data from upstream agents.
Complex types: When a substituted value is a list or dict, it is automatically serialized to JSON in the prompt.

6. Agent Output Variables

Access the last message from a specific agent (non-structured output). Example:

7. Custom Variables

Access variables defined in the system’s variables section. These are populated from user inputs, agent variable_assignments, or defaults. Example:
Variables are the bridge between structured output and prompt substitution. Use variable_assignments on agents to populate variables from structured output, then reference them with {{ variables.name }} in downstream agents. See Variables System for details.

Recursive Variable Substitution

Variables are substituted recursively up to 10 iterations, allowing nested variable references. Example:
Nested Variables: You can reference prompts that contain other variables. The system will resolve them recursively until no more variables remain.

Variable Substitution Timing

Variables are substituted before building provider messages:
  1. Template Resolution: {{ variables }} → actual values
  2. Message Building: System prompt + examples + history + user input
  3. LLM Call: Final messages sent to provider
This ensures that structured outputs from dependencies are available when constructing prompts.

Complete Variable Example

System Prompt

The system prompt defines your agent’s behavior, role, and capabilities.

Basic Example

Advanced System Prompt

Use Markdown formatting in system prompts for better structure. LLMs understand headings, lists, and emphasis.

Few-Shot Examples

Few-shot examples teach your agent desired behavior through concrete examples.

Basic Few-Shot Configuration

Complex Few-Shot Examples

  • input: | def process_data(data): return [x * 2 for x in data if x > 0] output: | Code Quality: Good Strengths:
    • Concise list comprehension
    • Clear filtering logic
    Suggestions:
    • Add type hints: def process_data(data: list[int]) -> list[int]:
    • Add docstring explaining the transformation
Use Case: Long conversations where full context is needed Token Impact: High - all messages included

Exclude All History

Use Case: Stateless operations, classification, single-turn interactions Token Impact: Low - only current message

Sliding Window (Last N Messages)

Use Case: Balance between context and token efficiency Token Impact: Medium - controlled history size
Token Management: Large histories can exceed model context windows. Use sliding windows for long conversations.

History Management Examples

User Input Control

Control whether the current user message is included in the prompt.

Include User Input (Default)

Standard Behavior: Current user question/message is included

Exclude User Input

Use Case:
  • Conversation summarization
  • Automatic analysis without user prompt
  • Background processing tasks
When include_user_input: false, the agent processes only the conversation history without the latest user message. This is useful for automated tasks triggered by system events.

Internal Message Control

Control whether outputs from internal agents (those with streaming_config.show_output_to_user: false) are included in the conversation history sent to the LLM.

Include Internal Messages (Default)

Behavior: Both user-facing messages and internal agent outputs appear in conversation history. Use Case: Agents that need full awareness of the multi-agent workflow state.

Exclude Internal Messages

Behavior: Only messages from agents with show_output_to_user: true and user messages appear in history. Internal agent outputs are filtered out. Use Case: Customer-facing agents that should only see the user conversation, not background processing.
Internal messages are outputs from agents with streaming_config.show_output_to_user: false. These agents run in the background without emitting text to the end user.

Media Handling

Control how images, PDFs, and other media are handled in conversation history.

Strip Media from History

Behavior:
  • Historical messages: Text only, media stripped
  • Current user input: Media always included
Use Case:
  • Reduce token costs (images are expensive)
  • Focus on text-based context
  • Process only the latest image

Include Media in History

Behavior: All media content preserved in history Use Case:
  • Visual conversation continuity
  • Comparing multiple images
  • Document series analysis
Cost Impact: Images consume significant tokens. A single image can use 1,000-2,000 tokens depending on size and model.

Advanced Patterns

Critical: Tool Execution Results (ReAct Agents)

Important for ReAct Agents: Messages with a run_id in their metadata are ALWAYS included in the prompt, regardless of include_history or include_user_input settings. This ensures tool execution results are visible to the agent in reasoning loops.
When a ReAct agent executes tools, the results are tagged with the current run_id. These messages bypass all filtering to ensure the agent can see:
  • Tool call requests
  • Tool execution results
  • Error messages from failed tools
Example Flow:
Why This Matters:
  • Without tool results, ReAct agents can’t complete their reasoning loop
  • Tool results must be visible even if history is limited
  • This is automatic - no configuration needed

Context-Aware Routing

Multi-Stage Processing

Summarization Pipeline

Validation & Best Practices

Automatic Validation

Artaios automatically validates your prompt configuration:
Warning: All components disabled (no system prompt, no examples, no history, no user input)Fix: Enable at least one component
Warning: History enabled but user input disabledBehavior: Only conversation history sent to LLM, not current questionUse Case: Intentional for summarization/analysis
Info: User input enabled but history disabledBehavior: Only current question sent (stateless)Use Case: Classification, single-turn tasks
Error: Missing ‘input’ or ‘output’ in examplesFix: Ensure each example has both fields

Best Practices

System Prompt Design

  • Be specific about role and capabilities
  • Include output format requirements
  • Add constraints and guidelines
  • Use structured formatting (Markdown)

Few-Shot Examples

  • Use 2-5 high-quality examples
  • Cover diverse scenarios
  • Show ideal output format
  • Keep examples concise

History Management

  • Use sliding windows for long conversations
  • Disable for stateless operations
  • Monitor token usage
  • Consider media costs

Token Optimization

  • Strip unnecessary media
  • Limit history length
  • Use concise system prompts
  • Optimize few-shot examples

Complete Example

Troubleshooting

Issue: “PromptConfig has no content”Cause: All components disabled or emptySolution: Enable at least one component (system_prompt, examples, history, or user_input)
Issue: “Example missing ‘input’ or ‘output’ field”Cause: Incorrect example formatSolution: Ensure each example has both input and output keys
Issue: “Context too long” or token limit errorsCause: Too much history or large media filesSolution:
  • Reduce include_history to smaller number
  • Set include_media_in_history: false
  • Shorten system prompt
  • Use fewer few-shot examples
Issue: Agent not following instructionsCause: Conflicting configuration or unclear promptsSolution:
  • Make system prompt more specific
  • Add relevant few-shot examples
  • Check if history is interfering
  • Test with include_history: false first

Performance Tips

1

Start Simple

Begin with basic system prompt and no examples. Add complexity only when needed.
2

Measure Token Usage

Monitor token consumption and optimize based on actual usage patterns.
3

Test Incrementally

Add few-shot examples one at a time and measure impact on quality.
4

Optimize History

Find the minimum history length that maintains quality.
5

Profile Costs

Track costs per agent and optimize expensive ones first.

Quick Reference

Template Variables Cheat Sheet

PromptConfig Settings

Message Ordering

Final prompt structure sent to LLM:
  1. System Message - Behavioral instructions (highest attention)
  2. Few-Shot Examples - Teaching patterns (static)
  3. Separator - Optional section marker
  4. Conversation History - Previous messages (filtered)
  5. Run-ID Messages - Tool results (ALWAYS included)
  6. Current User Input - Latest message (highest attention)

Common Patterns

Variable Substitution Flow

Troubleshooting Quick Fixes

Next Steps

Model Selection

Choose the right models for your use case

Structured Output

Generate structured data with schemas

Agent Capabilities

Explore tools, streaming, and other capabilities

Agent Types

Explore different agent architectures