Skip to content

fix: make research chat and PDF use one canonical report - #178

Merged
iamjr15 merged 1 commit into
mainfrom
fix/canonical-research-response
Aug 5, 2026
Merged

fix: make research chat and PDF use one canonical report#178
iamjr15 merged 1 commit into
mainfrom
fix/canonical-research-response

Conversation

@iamjr15

@iamjr15 iamjr15 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Publishes a successful deep-research tool's validated Markdown directly as assistant text in the same durable Workflow step that publishes its artifact.
  • Treats successful research_deep and research_fanout calls as terminal response producers, so no second model turn can summarize or rewrite the report.
  • Suppresses model pre-tool narration for terminal research calls, making the visible report body and PDF input identical by construction.

Why

Production QA for PR #177 proved that the PDF was complete and valid, but the outer agent ignored its prompt and posted a 1,386-character summary instead of the canonical report. Prompt-only enforcement cannot guarantee content identity. This moves ownership to the durable runtime boundary.

Architecture

The research tool continues to return { artifact, report }, with report already validated against collected citation provenance. The Workflow projects that strict output into both destinations:

  1. artifact becomes the durable deliverable part.
  2. report becomes the assistant text part.
  3. The run completes immediately after the successful tool turn.

Both parts share the deterministic tool:<model-step>:<tool-index> publication receipt, so Workflow replay cannot duplicate either one.

Decisions Made

Decision Choice Alternatives considered Reasoning
Response ownership Durable Workflow publishes canonical report Ask the outer model to copy tool output The production model summarized despite explicit instructions.
Completion Successful research tool is terminal Run another model turn A second turn can rewrite, truncate, or append content.
Progress prose Suppress research-call model text Keep preamble before the report Ensures visible report content and PDF source are the same Markdown.
Failure path Continue agent loop on tool error Treat every research attempt as terminal The model still needs to explain provider or validation failures.
Replay behavior Report and artifact share tool publication Separate non-durable append Existing atomic receipts already guarantee exactly-once transcript publication.

Edge Cases Handled

Scenario Handling
Research tool fails No canonical response is projected; the next model turn explains the error.
Non-terminal search tool runs Existing model loop is unchanged.
Research output shape is invalid Strict schema parsing fails the run rather than publishing divergent content.
Worker/DO replays publication Deterministic event receipt prevents duplicate report or artifact parts.
Model emits a preamble with the tool call It stays in model context but is not published to the user.

How to Review

  1. Review agent-run-research-response-support.ts for terminal-tool classification and strict output projection.
  2. Review agent-run-workflow.ts for suppression, atomic report publication, and terminal completion.
  3. Confirm the agent-worker README and system prompt document the same ownership boundary.

Verification

  • pnpm lint
  • pnpm typecheck
  • pnpm turbo build --force
  • pnpm deadcode
  • pnpm architecture:check
  • pnpm turbo skills:build
  • Direct projection contract: successful report preserved byte-for-byte; failed, non-terminal, and invalid outputs handled as designed.
  • Production evidence before this fix: reload recovery completed one run with one tool and one artifact, but persisted assistant text was a short model summary rather than the PDF's report.

Publish validated research Markdown directly from the durable tool step.

Skip model narration and summary turns so chat and PDF content remain identical.
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
cheatcode Skipped Skipped Aug 5, 2026 1:20pm

@iamjr15
iamjr15 merged commit 56f112e into main Aug 5, 2026
6 checks passed
@iamjr15
iamjr15 deleted the fix/canonical-research-response branch August 5, 2026 13:22
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