#357Planner Output ParserEasyNLPAgentic AIAsked atOpenAI · Anthropic · Google
Planner Output Parser
Background
A research / planning agent often outputs a numbered list of sub-questions. The downstream agent loop needs a robust parser: handle numbering styles (1., 1), 1:), strip Markdown emphasis, ignore blank lines, trim whitespace.
Problem statement
Implement parse_plan(text). Walk lines of text; for each line matching a numbered-list pattern, extract the content. Return a list[str] of cleaned sub-questions in order.
Input
text- the raw LLM output containing the plan.
Output
list[str]of cleaned sub-questions; empty list if no items match.
Examples
Input: "1. What is X?\n2) How does Y work?\n3: Why Z?"
Output: ["What is X?", "How does Y work?", "Why Z?"]
Constraints
- Accept
N.,N),N:(single digit or multi-digit). - Strip leading/trailing whitespace and Markdown
**bold**/*italic*around the whole item. - Skip lines that don't match the pattern.
Notes
- Why robust parsing. LLMs produce inconsistent formatting; brittle parsers fail silently and the planner returns 0 sub-questions instead of erroring.
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Example: mixed numbering styles parse correctly
- •Reference: markdown bold around the whole item is stripped
- •Sample: multi-digit numbering