Skip to main content

Prompt Fixes

Modify system prompts and add examples.

Held for the beta

This feature is built. It is not available in this release. It has no release date. This page describes it as designed.

Prompt fixes modify the system prompt or add few-shot examples.

Use Cases

  • Add clarifying instructions
  • Include few-shot examples
  • Adjust tone or style
  • Add constraints
  • Fix format instructions

Configuration

{
  "fix_id": "fix-prompt-001",
  "fix_type": "prompt",
  "config": {
    "modification_type": "append",
    "target": "system",
    "content": "Always respond in valid JSON format."
  }
}

Config Keys

KeyTypeDescription
modification_typestringOne of "prepend", "append", "replace", "few_shot"
targetstringMessage role to modify (e.g., "system")
contentstringText to prepend, append, or use as replacement
patternstringRegex pattern to match (for "replace" mode)
examplesarrayList of example objects (for "few_shot" mode)

Modification Types

Append

Add text to an existing message by role:

{
  "modification_type": "append",
  "target": "system",
  "content": "Important: Cite sources for all claims."
}

Prepend

Add text at the start of a message by role:

{
  "modification_type": "prepend",
  "target": "system",
  "content": "You are a careful, accurate assistant."
}

Replace

Replace a regex pattern across all messages:

{
  "modification_type": "replace",
  "pattern": "\\{\\{FORMAT_INSTRUCTIONS\\}\\}",
  "content": "Output must be valid JSON with keys: result, confidence"
}

Few-Shot

Add example messages after the system message:

{
  "modification_type": "few_shot",
  "examples": [
    {
      "user": "What's 2+2?",
      "assistant": "{\"result\": 4, \"confidence\": 1.0}"
    },
    {
      "user": "What's the capital of France?",
      "assistant": "{\"result\": \"Paris\", \"confidence\": 0.99}"
    }
  ]
}

Targeting

A fix applies by its error_code — an exact code, or a pattern ending in * that matches by prefix:

{
  "error_code": "OUTPUT.FORMAT.*"
}

A fix record can also carry an agent_id, but the SDK does not receive it, so it does not limit where the fix applies.

Common Fixes

JSON Output

{
  "modification_type": "append",
  "target": "system",
  "content": "\n\nYou MUST respond with valid JSON only. No markdown, no explanation."
}

Reduce Hallucination

{
  "modification_type": "append",
  "target": "system",
  "content": "\n\nOnly use information from the provided context. If you don't know, say so."
}

Add Structure

{
  "modification_type": "append",
  "target": "system",
  "content": "\n\nStructure your response as:\n1. Summary\n2. Details\n3. Next steps"
}

Next Steps