You can structure these mailbox payloads as an AST-parsable Markdown document,
effectively creating a "multipart envelope" for natural language. By relying
on strict Markdown boundaries, you allow both a traditional lexical parser (to
build dependency graphs) and an AI (to read context) to process the exact same
message without confusion.
Here is a lightweight format that cleanly separates the rigid from the fluid:
---
from: ENVIRONMENT
refs: [CUSTOMER#Zv82q9, TASK#4fA92b]
---
> [EVENT]
> UPDATE CUSTOMER#Zv82q9 : status = "REJECTED"
> TRIGGER TASK#4fA92b : action = "REVIEW_TERMS"
The customer sounded frustrated on the call. They mentioned the timeline was
too tight and requested a complete review of the delivery schedule before
proceeding.
The Routing Header (YAML Frontmatter)
This provides immediate context before the LLM even begins reading tokens. By
explicitly declaring the routable IDs (refs) up front, the state machine's
internal router knows exactly which local cache histories to retrieve and
inject into the prompt. The AI doesn't have to guess who or what is involved.
The System Block (Blockquotes)
Using standard Markdown blockquotes prefixed with a rigid tag like > [EVENT]
creates an isolated execution zone. A fast, local model (or even a vanilla
JavaScript regex parser) can instantly strip this block out to update the
state machine's local cache or route downstream events, completely ignoring
the narrative fluff.
The Narrative Block (Plain Text)
The unstructured natural language lives entirely outside the blockquotes. When
the state machine needs to reason about the why or update its conceptual
memory, it reads this section. It absorbs the tone ("frustrated") and the
un-instantiated concepts ("delivery schedule") into its volatile memory
without risking corruption to the hard state contained in the [EVENT] block.
This dual-layered approach is highly suited for a multi-model orchestration
pipeline. A tiny, fast local model can act as the edge routersnapping up the
YAML and blockquotes to manage the inventory and cachewhile a more advanced,
computationally expensive model is only invoked to ponder the plain text
narrative when a complex conceptual decision is actually required.