Skip to main content

withOutput

Sets the output format guidelines for the agent’s responses. The output format defines how the agent should structure its responses. This can specify formatting patterns, response structure, markdown usage, or any other output conventions the agent should follow. Supports multi-line strings for complex formatting instructions.
withOutput(format: string): this
format
string
required
Output format description or template. Can include examples, numbered steps, markdown formatting requirements, or structural guidelines.
Returns
this
The builder instance for method chaining

Examples

builder.withOutput("Respond in this format:\n1. Summary\n2. Details\n3. Next steps");

withTone

Sets the communication tone and style for the agent. The tone defines how the agent should communicate - its personality, formality level, and interaction style. This helps ensure consistent and appropriate communication for your use case.
withTone(tone: string): this
tone
string
required
Description of the desired communication style. Should specify personality traits, formality level, and interaction patterns. Can include multiple aspects (e.g., “friendly but professional”).
Returns
this
The builder instance for method chaining

Examples

builder.withTone("Be friendly, enthusiastic, and encouraging. Use a conversational tone.");

withFormat

Sets the output format for the generated prompt. This method allows you to choose between different output formats, each optimized for different use cases:
  • markdown: Standard markdown format with headers and formatting (default). Most human-readable, good for debugging and documentation.
  • toon: TOON format (Token-Oriented Object Notation). Optimized for token efficiency, reducing token usage by 30-60% compared to markdown. Uses indentation-based structure and eliminates redundant syntax.
  • compact: Minimal whitespace variant of markdown. Removes excessive whitespace while maintaining markdown structure.
Format selection tips:
  • Start with markdown while authoring or debugging prompts so teammates can read and diff the content easily.
  • Promote to compact in QA/staging when you still want Markdown semantics but need to trim 10–20% of token usage.
  • Switch to toon for production workloads with high traffic or large guardrails/examples where 30–60% token savings meaningfully lower cost.
withFormat(format: PromptFormat): this
format
PromptFormat
required
The desired output format: "markdown", "toon", or "compact"
Returns
this
The builder instance for method chaining

Examples

// Use TOON format for token efficiency (30-60% reduction)
const builder = createPromptBuilder()
  .withIdentity("You are a helpful assistant")
  .withCapabilities(["Answer questions", "Provide help"])
  .withFormat('toon');

const prompt = builder.build(); // Generated in TOON format

Build docs developers (and LLMs) love