Parses the raw string output from an execution LLM call (per todo item).
The raw string response from the execution LLM.
A promise resolving to an ExecutionOutput object containing:
- thoughts (string, optional): Extracted from
The execution phase generates output that may include:
This method:
The nextStepDecision values guide the TAEF execution:
Parses the raw string output from the planning LLM call.
The raw string response from the planning LLM.
A promise resolving to an object containing:
- title (string, optional): Concise thread title
- intent (string, optional): User's goal summary
- plan (string, optional): Human-readable plan description
- toolCalls (ParsedToolCall[], optional): Parsed tool call requests
- todoList (TodoItem[], optional): List of execution steps
- thoughts (string, optional): Extracted from
The planning phase generates structured output including:
This method:
The fallback section-based parsing looks for labeled sections like: "Title: ...", "Intent: ...", "Plan: ..." using regex patterns.
Parses the raw string output from the synthesis LLM call.
The raw string response from the synthesis LLM.
A promise resolving to the cleaned, final response string.
The synthesis phase generates the final, user-facing response. This method typically just trims the output, as synthesis output is usually freeform text without structured components.
Future enhancements might include:
Default implementation of the IOutputParser interface.
Remarks
This class provides robust parsing capabilities for structured output from LLMs. It is designed to handle variations in LLM output formatting across different providers and models. The parser uses a multi-tier strategy for extracting structured data:
XML Tag Extraction: Extracts content from XML-like tags (e.g.,)
using the XmlMatcher utility. This separates "thoughts" or "reasoning" from
the main structured output.
JSON Extraction: Attempts multiple strategies to find and parse JSON:
json ...or...)Schema Validation: Uses Zod schemas to validate parsed structures:
Fallback Parsing: If JSON extraction fails, attempts to extract information from labeled sections (e.g., "Title: ...", "Intent: ...", "Plan: ...")
The parser is resilient to:
OutputParser
Implements
IOutputParser