Fix narrative Analyze evidence-envelope truncation (0.250.194) - #1241
Merged
Paul Lizer (paullizer) merged 1 commit intoAug 14, 2026
Conversation
Root cause: pure-narrative Analyze requests (PDF -> XML/JSON template population, no tabular sources) were routed through the mixed-source evidence-envelope + collective-reduction hop. That hop exists to combine narrative and tabular evidence into one bounded payload, but its per-source summary cap discarded most of run_document_analysis's own already-synthesized output before the final reply was ever produced. Fixes: - _execute_mixed_source_analyze_workflow now bypasses the evidence envelope/collective-reduction path entirely when there are narrative sources, a completed narrative_result, and no tabular sources - returning run_document_analysis's full-fidelity result directly. mixed_source_manifest is preserved on the returned dict so the existing reauthorization security check still runs unchanged. - Raised EVIDENCE_SUMMARY_MAX_BYTES (4096 -> 16384) and MIXED_SOURCE_HANDOFF_MAX_BYTES (49152 -> 131072) as a secondary safety margin for remaining mixed-source (narrative + tabular) runs that still go through the envelope/handoff path. - Added char-count diagnostic logging across the window analysis, per-document reduction, and global reduction stages in run_document_analysis, plus around evidence envelope/handoff sizing in the mixed-source workflow, to make any future truncation easier to pinpoint from logs alone. Also fixes a pre-existing namespace gap in test_tabular_analyze_shared_preflight_adapter.py's AST-extraction harness (missing debug_print/json stubs) surfaced by the new bypass's logging calls. Validated: all data elements (BusinessUnit/LoanCategory/DepositCategory/ Exception/Certification counts and the full "Reserved optional extension" comment block) now match the source XML template exactly, confirmed against a real production PDF+XML population run.
Paul Lizer (paullizer)
merged commit Aug 14, 2026
fade832
into
microsoft:Development
11 of 12 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Analyze producing truncated/incomplete output when populating an XML/JSON template from a PDF (narrative-only Analyze), while the equivalent Search-based workflow worked correctly.
Root cause
Pure-narrative Analyze requests (no tabular sources) were routed through the mixed-source evidence-envelope + collective-reduction hop. That mechanism exists to combine narrative and tabular evidence into one size-bounded payload for the LLM, but its per-source summary cap discarded most of
run_document_analysis's own already-synthesized output before the final reply was produced - even when there was nothing to combine it with.Changes
_execute_mixed_source_analyze_workflow(functions_workflow_runner.py) now bypasses the evidence-envelope/collective-reduction path entirely when there are narrative sources, a completednarrative_result, and no tabular sources - returningrun_document_analysis's full-fidelity result directly.mixed_source_manifestis preserved on the returned dict so the existing reauthorization security check still runs unchanged.EVIDENCE_SUMMARY_MAX_BYTES(4096 -> 16384) andMIXED_SOURCE_HANDOFF_MAX_BYTES(49152 -> 131072) infunctions_mixed_source_orchestration.pyas a secondary safety margin for remaining mixed-source (narrative + tabular) runs that still go through the envelope/handoff path.functions_document_analysis.py, plus around evidence envelope/handoff sizing in the mixed-source workflow, to make any future truncation easier to pinpoint from logs alone.test_tabular_analyze_shared_preflight_adapter.py's AST-extraction test harness (missingdebug_print/jsonstubs), surfaced by the new bypass's logging calls.VERSIONto0.250.194inconfig.py.Validation
python -m py_compileclean on all modified files.test_tabular_analyze_shared_preflight_adapter.py: 6/6 passing.test_mixed_source_manifest_contracts.py,test_mixed_source_chat_search_consistency.py,test_mixed_source_hardening.py,test_mixed_source_deferred_composition_phase5.py,test_tabular_phase7_lifecycle_coverage.py,test_mixed_source_analyze_workflow.py,test_document_analysis_lossless_artifacts.py- no new regressions (one pre-existing, unrelated failure confirmed viagit stash).BusinessUnit,LoanCategory,DepositCategory,Exception,Certification) and the full trailing "Reserved optional extension" comment block in the generated XML now match the source template exactly.