Interface PromptEngineResult

Comprehensive result object returned by prompt construction, containing the formatted prompt, metadata, issues encountered, and optimization information. PromptEngineResult

interface PromptEngineResult {
    prompt: FormattedPrompt;
    formattedToolSchemas?: any[];
    estimatedTokenCount?: number;
    tokenCount?: number;
    issues?: {
        type: "error" | "warning" | "info";
        code: string;
        message: string;
        details?: unknown;
        suggestion?: string;
        component?: string;
    }[];
    wasTruncatedOrSummarized: boolean;
    modificationDetails?: {
        originalEstimatedTokenCount?: number;
        truncatedComponents?: string[];
        summarizedComponents?: string[];
        removedComponents?: string[];
        addedContextualElementIds?: string[];
    };
    metadata: {
        constructionTimeMs: number;
        selectedContextualElementIds: string[];
        templateUsed: string;
        totalSystemPromptsApplied: number;
        historyMessagesIncluded: number;
        ragContextTokensUsed?: number;
        [key: string]: unknown;
    };
    cacheKey?: string;
}

Properties

The final formatted prompt ready for LLM consumption.

formattedToolSchemas?: any[]

Formatted tool schemas compatible with the target model's API, if tools are used. The structure of any[] depends on ModelTargetInfo.toolSupport.format.

estimatedTokenCount?: number

Estimated token count of the constructed prompt before precise provider counting.

tokenCount?: number

Precise token count, if available from a tokenizer or after construction.

issues?: {
    type: "error" | "warning" | "info";
    code: string;
    message: string;
    details?: unknown;
    suggestion?: string;
    component?: string;
}[]

Any issues (errors, warnings, info) encountered during prompt construction.

Type declaration

  • type: "error" | "warning" | "info"
  • code: string
  • message: string
  • Optional details?: unknown
  • Optional suggestion?: string
  • Optional component?: string
wasTruncatedOrSummarized: boolean

Indicates if content was truncated or summarized to fit token limits.

modificationDetails?: {
    originalEstimatedTokenCount?: number;
    truncatedComponents?: string[];
    summarizedComponents?: string[];
    removedComponents?: string[];
    addedContextualElementIds?: string[];
}

Details about modifications made during construction (e.g., which components were truncated).

Type declaration

  • Optional originalEstimatedTokenCount?: number
  • Optional truncatedComponents?: string[]
  • Optional summarizedComponents?: string[]
  • Optional removedComponents?: string[]
  • Optional addedContextualElementIds?: string[]
metadata: {
    constructionTimeMs: number;
    selectedContextualElementIds: string[];
    templateUsed: string;
    totalSystemPromptsApplied: number;
    historyMessagesIncluded: number;
    ragContextTokensUsed?: number;
    [key: string]: unknown;
}

Performance metrics and metadata related to the prompt construction process.

Type declaration

  • [key: string]: unknown
  • constructionTimeMs: number
  • selectedContextualElementIds: string[]
  • templateUsed: string
  • totalSystemPromptsApplied: number
  • historyMessagesIncluded: number
  • Optional ragContextTokensUsed?: number
cacheKey?: string

An optional cache key if the result was retrieved from or stored in a cache.