AgenticOS: Template Interpolation – Accessing Token Data in Inscriptions

Template Interpolation – Variable Substitution Syntax

Template interpolation is how AgetnticOS transitions access and transform token data. Using ${...} syntax, you can reference input token fields, metadata, and build dynamic outputs in Map templates, HTTP bodies, LLM prompts, and more.

Template Interpolation: ${…} Syntax Template “Hello ${input.data.name}!” Result “Hello John!” Input Token Data { “name”: “John”, “age”: 30 }

Access Paths

Templates use hierarchical paths to access token data and metadata:

Template Access Paths User Data (input.data.*) ${input.data.orderId} ${input.data.customer.name} Token Metadata (input._meta.*) ${input._meta.id} ${input._meta.name} Template Example “template”: { “id”: “${input.data.orderId}”, “tokenUuid”: “${input._meta.id}” }

Common Access Patterns

// Access user data fields
"${input.data.orderId}"           // → "ORD-123"
"${input.data.amount}"            // → 99.99
"${input.data.customer.name}"     // → "John" (nested)
"${input.data.items[0].sku}"      // → "SKU-001" (array access)

// Access token metadata
"${input._meta.id}"               // → "uuid-abc-123"
"${input._meta.name}"             // → "order-token-1"
"${input._meta.parentId}"         // → "place-uuid"
"${input._meta.type}"             // → "Leaf"

// Static values (no interpolation)
"status": "processed"             // → "processed"
"version": 2                      // → 2

Usage in Different Transitions

Map Transition Templates

"action": {
  "type": "map",
  "template": {
    "orderId": "${input.data.orderId}",
    "total": "${input.data.amount}",
    "status": "processed",
    "_processedAt": "${now()}",
    "_sourceToken": "${input._meta.id}"
  }
}

HTTP Request Body

"action": {
  "type": "http",
  "method": "POST",
  "url": "https://api.example.com/orders/${input.data.orderId}",
  "headers": {
    "X-Request-Id": "${input._meta.id}"
  },
  "body": {
    "amount": "${input.data.amount}",
    "customer": "${input.data.customerName}"
  }
}

LLM Prompts

"action": {
  "type": "llm",
  "systemPrompt": "You are a helpful assistant.",
  "userPrompt": "Summarize this review: '${input.data.reviewText}' written by ${input.data.author}"
}

Agent Instructions

"action": {
  "type": "agent",
  "nl": "Analyze the file ${input.data.filename} in ${input.data.repository} for security issues"
}

Token Structure Reference

Understanding the token structure is key to correct template paths:

// Token structure returned by ArcQL
{
  "data": {
    "orderId": "ORD-123",
    "amount": 99.99,
    "status": "active",
    "customer": {
      "name": "John",
      "email": "john@example.com"
    }
  },
  "_meta": {
    "id": "7f34a312-8cc2-4a1b-...",
    "name": "order-token-1",
    "parentId": "place-uuid-456",
    "type": "Leaf"
  }
}
Template Variable Reference Variable Source Example Value ${input.data.orderId} User data property “ORD-123” ${input.data.customer.name} Nested property “John” ${input._meta.id} Token UUID “7f34a312-…” ${input._meta.name} Token name “order-token-1” ${input._meta.parentId} Parent place UUID “place-uuid-456”

Why Hierarchical (Not Flattened)

AgetnticOS preserves the hierarchical token structure in templates. This design choice provides:

  • No collision risk – User data can have any property name including name, id, type
  • Explicit structure – Clear separation between user data and system metadata
  • Mirrors ArcQL – Template paths match the actual data structure
  • Supports deep nesting${input.data.address.city} works naturally

Summary

  • Syntax – Use ${...} for interpolation
  • User data – Access via ${input.data.fieldName}
  • Metadata – Access via ${input._meta.id}, ${input._meta.name}
  • Nested access – Use dot notation for deep paths
  • Works in – Map templates, HTTP bodies/URLs, LLM prompts, Agent instructions

Template interpolation is the glue that connects your tokens to transition actions – mastering it unlocks powerful data transformation and routing patterns.

Leave a Reply

Your email address will not be published. Required fields are marked *