Skip to content

Fix narrative Analyze evidence-envelope truncation (0.250.194) - #1241

Merged
Paul Lizer (paullizer) merged 1 commit into
microsoft:Developmentfrom
paullizer:fix/narrative-analyze-evidence-truncation
Aug 14, 2026
Merged

Fix narrative Analyze evidence-envelope truncation (0.250.194)#1241
Paul Lizer (paullizer) merged 1 commit into
microsoft:Developmentfrom
paullizer:fix/narrative-analyze-evidence-truncation

Conversation

@paullizer

Copy link
Copy Markdown
Contributor

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 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) in functions_mixed_source_orchestration.py 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 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.
  • Fixed a pre-existing namespace gap in test_tabular_analyze_shared_preflight_adapter.py's AST-extraction test harness (missing debug_print/json stubs), surfaced by the new bypass's logging calls.
  • Bumped VERSION to 0.250.194 in config.py.

Validation

  • python -m py_compile clean on all modified files.
  • test_tabular_analyze_shared_preflight_adapter.py: 6/6 passing.
  • Full regression sweep across 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 via git stash).
  • Confirmed against a real production PDF -> XML template population run: every repeating element count (BusinessUnit, LoanCategory, DepositCategory, Exception, Certification) and the full trailing "Reserved optional extension" comment block in the generated XML now match the source template exactly.

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.
@paullizer
Paul Lizer (paullizer) merged commit fade832 into microsoft:Development Aug 14, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant