A six-node LangGraph agent in Python that rewrites text into a target style and then grades its own work. It analyses the source style, retrieves a matching style guide from Pinecone, plans the rewrite, converts, retrieves a fact-checking protocol, and grades the result against the original, the plan and the protocol. A failing grade routes the draft back to the converter with the feedback attached.
Six nodes, wired as an explicit state graph, each doing one job. The style analyser classifies the source's tone, complexity, format and vocabulary. A retrieval step pulls the matching style guide out of a vector store. A planner emits a step-by-step rewrite plan instead of handing the whole task to one generation. The converter rewrites against that plan. A second retrieval step fetches the fact-checking protocol. And a quality controller grades the output against the original, the plan and the protocol at once.
The outputs are structured, not parsed out of prose: analysis, plan and grade are Pydantic models. The grade carries approve or revise, feedback naming what is wrong, and a score from one to ten. A revise follows a conditional edge back to the converter with the feedback attached, which makes the graph cyclic — the property that lets it notice a dropped number a single-pass rewrite never would.
The fact-checking protocol names exactly what a style rewrite breaks most: proper nouns, numbers, statistics and monetary values, dates and times, and the core meaning of the original.