Centralize Final Draft Path Logic & Bump Prefix to 7
Consolidated all final draft file resolution into `src/final_draft.py` and bumped the canonical prefix from `6` to `7`. Previously, three agents each had their own inline glob logic to locate the final draft — now they all call shared utility functions.
Changelog - 2026-03-17_01
Centralize Final Draft Path Logic & Bump Prefix to 7
Consolidated all final draft file resolution into src/final_draft.py and bumped the canonical prefix from 6 to 7. Previously, three agents each had their own inline glob logic to locate the final draft — now they all call shared utility functions. Also increased the LangGraph recursion limit to prevent failures on longer pipelines.
Problem Statement
Multiple agents (citation_assembly, citation_validator, validator, main) each had their own copy of the "find the final draft file" glob pattern. When the naming prefix changed (e.g., 4-final-draft.md → 6-*.md), every call site had to be updated manually. This was fragile and led to inconsistencies.
Additionally, the default LangGraph recursion limit (25) was too low for the growing pipeline (28+ nodes), causing failures on runs with conditional retries.
What Changed
Modified: src/final_draft.py
Prefix bumped:
FINAL_DRAFT_PREFIXchanged from"6"to"7"Backward compatibility:
find_final_draft()now falls back to6-*-v*.mdpattern before trying legacy4-final-draft.mdLookup order:
7-*.md→6-*-v*.md→4-final-draft.md
Modified: src/agents/citation_assembly.py
Removed: Inline glob loop searching for
6-*.mdwith fallback directory name constructionAdded: Imports
get_final_draft_path()fromsrc.final_draft— single function call replaces 8 lines
Modified: src/agents/citation_validator.py
Removed: Inline loop over
["6-*.md", "4-final-draft.md"]patternsAdded: Imports
find_final_draft()fromsrc.final_draft— single function call replaces 5 lines
Modified: src/agents/validator.py
Removed: Inline loop over
["6-*.md", "4-final-draft.md"]patternsAdded: Imports
find_final_draft()fromsrc.final_draft— single function call replaces 5 lines
Modified: src/main.py
Removed: Hardcoded
f"6-{safe_name}-{version}.md"path constructionAdded: Imports
get_final_draft_path()andget_final_draft_filename()fromsrc.final_draftFinal draft path and version recording now use canonical utilities
Modified: src/workflow.py
Added:
config={"recursion_limit": 50}toapp.invoke()callPrevents
GraphRecursionErroron pipelines with 28+ nodes and conditional edges
Files Changed
| File | Change |
src/final_draft.py | Prefix 6 → 7, added 6-* fallback in find_final_draft() |
src/agents/citation_assembly.py | Replaced inline glob with get_final_draft_path() import |
src/agents/citation_validator.py | Replaced inline glob with find_final_draft() import |
src/agents/validator.py | Replaced inline glob with find_final_draft() import |
src/main.py | Replaced hardcoded path with get_final_draft_path() / get_final_draft_filename() |
src/workflow.py | Added recursion_limit: 50 to workflow invocation |
Migration Notes
Non-breaking: The fallback chain (
7-*.md→6-*.md→4-final-draft.md) ensures existing output directories are still readable.New runs will produce
7-{Deal}-{Version}.mdas the final draft filename.No workflow graph changes: Agent sequence is unchanged; only the invocation config was updated.