Skip to content

Instantly share code, notes, and snippets.

@decagondev
Last active April 29, 2025 15:56
Show Gist options
  • Save decagondev/e312e72a7042f500a3b5c46e4e2a9f80 to your computer and use it in GitHub Desktop.
Save decagondev/e312e72a7042f500a3b5c46e4e2a9f80 to your computer and use it in GitHub Desktop.

Product Requirements Document (PRD)

Project Title

AI-Powered Iterative Report Writer using LangGraph


Objective

Develop an AI system using LangGraph that automates the process of writing a report, providing feedback on the report, and rewriting it iteratively for a user-defined number of times (n). The graph will consist of modular LangGraph nodes that interact to write, critique, and improve the report in a stateful, traceable workflow.


Goals

  • Generate a complete, readable initial report based on a user prompt.
  • Provide feedback on the report using a feedback agent.
  • Rewrite the report incorporating feedback.
  • Repeat the feedback and rewriting loop for n iterations.
  • Track all versions and changes across iterations.
  • Export the final report and optionally include all iterations.

Scope

In Scope

  • LangGraph node design and implementation
  • State tracking across multiple iterations
  • Prompt engineering for quality report writing and feedback
  • CLI or Web interface for providing prompts and reading output

Out of Scope

  • Deep style learning from user examples (initial version)
  • UI design beyond basic CLI or lightweight front-end (e.g. React minimal)

User Stories

  1. As a user, I want to input a report topic so that the AI can start the writing process.
  2. As a user, I want to define how many times the report should be improved.
  3. As a user, I want to review all versions of the report, including feedback.
  4. As a user, I want to download the final improved report and optionally the full iteration history.

System Architecture

Components

  1. Prompt Input Node

    • Accepts user input (topic, iteration count).
    • Initializes the LangGraph state.
  2. Report Generator Node

    • Uses LLM to produce a report from the initial prompt or previous version.
  3. Feedback Node

    • Uses LLM to analyze and critique the current version of the report.
    • Identifies weaknesses, clarity issues, structure, grammar, and tone.
  4. Rewrite Node

    • Incorporates the feedback into the report.
    • Returns a new version.
  5. Iteration Control Node

    • Checks if the max iteration count has been reached.
    • If not, loops back to the Feedback Node.
  6. Export Node

    • Collects the final report (and optionally all iterations).
    • Outputs JSON, Markdown, or plain text.

LangGraph State Schema

interface ReportState {
  topic: string;
  currentIteration: number;
  maxIterations: number;
  versions: Array<{ report: string; feedback: string; }>;
  finalReport: string;
}

Acceptance Criteria

  • ✅ User can input a topic and desired number of iterations.
  • ✅ LangGraph processes at least n iterations correctly.
  • ✅ Each report version is accompanied by feedback.
  • ✅ Final output is saved in chosen format.
  • ✅ System handles errors and loops with stability.

Milestones

  1. MVP Prototype (v0.1)
    • Input → Report → Feedback → Rewrite loop for 3 iterations
  2. Iteration Engine (v0.2)
    • Full n iteration control, logging, and traceability
  3. Output Enhancements (v0.3)
    • Export formats, improved feedback accuracy
  4. Interface Layer (v0.4)
    • CLI or lightweight web interface for user interaction

Future Enhancements

  • Style customization (e.g. academic, casual, technical)
  • Integration with document editors (Google Docs, MS Word)
  • Multi-agent critique (grammar, clarity, originality agents)
  • Version comparison tools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment