@@ -299,18 +299,23 @@ def toc_index_extractor(toc, content, model=None):
299299 return _validate_chunk_physical_indices (toc = items , content = content )
300300
301301def toc_transformer (toc_content , model = None ):
302- # TODO after rebase completes — two known gaps vs. main's version, to
303- # resolve deliberately (see PR discussion), not silently:
304- # 1. No continuation/retry logic for truncated completions (main uses
305- # a chat-history "please continue" loop, capped at 5 attempts).
306- # llm_structured already fails fast on finish_reason == "length",
307- # which is a deliberate trade-off, not an oversight.
308- # 2. No equivalent of check_if_toc_transformation_is_complete — main
309- # catches "complete-looking but actually missing sections" output
310- # (finish_reason == "stop" but content silently incomplete), which
311- # Pydantic validation alone cannot catch (a shorter-than-expected
312- # list still validates fine). This gap needs an explicit decision:
313- # port the check, or document and accept it.
302+ # TODO — two known gaps vs. main's version, tracked for follow-up
303+ # (see PR discussion), not silent omissions:
304+ # 1. No continuation/retry for truncated completions. Main uses a
305+ # chat-history "please continue" loop, capped at 5 attempts.
306+ # llm_structured fails fast instead on finish_reason == "length" —
307+ # a deliberate trade-off (Instructor's structured output doesn't
308+ # compose cleanly with resuming a partial JSON response).
309+ # 2. No completeness check yet. Main's check_if_toc_transformation_is_
310+ # complete catches a case schema validation can't: a response that
311+ # validates fine but silently skipped sections (finish_reason ==
312+ # "stop", not truncated, just incomplete). Planned: reuse that
313+ # function unmodified via a Pydantic model_validator on
314+ # TOCTransformation, using Instructor's context= passthrough so
315+ # the validator can access toc_content — this way the completeness
316+ # check participates in Instructor's own retry loop instead of a
317+ # separate hand-rolled one. Not yet implemented; requires
318+ # llm_structured to accept/forward a context param.
314319 print ('start toc_transformer' )
315320 init_prompt = """
316321 You are given a table of contents, You job is to transform the whole table of content into a JSON format included table_of_contents.
0 commit comments