Skip to main content

Overview

Context compilers control which messages the LLM sees at each step. By default, ConversationWithCurrentToolTrace includes all conversation messages plus only the current execution’s tool traces. You can swap in a different compiler to change what context the agent reasons over. This example builds a custom compiler that wraps the default one and applies two transformations:
  • Filtering: Truncates long tool results so they don’t overwhelm the context
  • Enrichment: Injects a dynamic system message with execution progress info
The compiler logs what it does at each step, so you can see exactly what the LLM receives. Key concepts:
  • CanCompileMessages: Interface for message compilers
  • ConversationWithCurrentToolTrace: Default — includes conversation + current tool traces
  • Custom compilers can filter, truncate, enrich, or transform the message list

Example