AgentMark uses a multi-stage transformation pipeline to convert your .prompt.mdx files into model-specific formats while maintaining a unified interface.

Processing Pipeline

1. MDX Processing

Your .prompt.mdx file contains:

  • Frontmatter configuration
  • Message components (<System>, <User>, <Assistant>)
  • Dynamic content (props, components)

2. AST Generation

The Loader class has a method called load that parses your MDX into an Abstract Syntax Tree (AST), which:

  • Validates syntax
  • Processes imports
  • Provides an AST that the SDK can use to generate prompts

3. Transformations

Two transformations occur:

3a. AgentMark Format

Agentmark client compiles the AST into default agentmark format.

  • Standardized message structure
  • Normalized model configuration
  • Evaluates props

3b. Adapter translation

Adapter converts AgentMark format into adapter-specific formats:

  • Message formatting
  • Parameter mapping
  • Tool/function calling adaptations

Implementation Example with Vercel AI SDK adapter

TypeScript
import {
  VercelAIModelRegistry,
  createAgentMarkClient
} from "@agentmark/vercel-ai-v4-adapter";
import { FileLoader } from "@agentmark/agentmark-core";
// use any ai-sdk model provider
import { openai } from "@ai-sdk/openai";

const modelRegistry = new VercelAIModelRegistry();
// register models you want to use
modelRegistry.registerModels(['gpt-4o'], (name: string) => {
  return openai(name);
});

const loader = new FileLoader("./path/to/agentmark");

const agentmark = createAgentMarkClient({
  loader,
  modelRegistry,
});

const run = async () => {
  const examplePrompt = await agentmark.loadTextPrompt("<example>.prompt.mdx");
  const props = { name: "Emily" };
  const vercelInput = await examplePrompt.format({props});
}
run();

Key Benefits

  1. Abstraction: Developers work with a single, unified format
  2. Portability: Prompts can be easily switched between models
  3. Extensibility: New model support via plugin system
  4. Type Safety: Full type-safety support throughout pipeline
  5. Tooling: We can support a rich ecosystem of development tools

Have Questions?

We’re here to help! Choose the best way to reach us: