Skip to content

Per-meeting TopicSummary is also context-starved (analyze_topic_summary) #94

@AndreRobitaille

Description

@AndreRobitaille

Background

While executing #93's fix, a second context-starvation bug surfaced: generate_topic_summaries in SummarizeMeetingJob uses Topics::SummaryContextBuilder to feed analyze_topic_summary, and that builder only passes agenda structure (AgendaItem.title + the usually-empty AgendaItem.summary field + packet attachments) — not the MeetingSummary.generation_data["item_details"] content.

This is the same root cause as #93 RC1, but a different job and different prompt. #93 fixed it for analyze_topic_briefing by adding recent_item_details via Topics::RecentItemDetailsBuilder. That fix does NOT touch analyze_topic_summary.

Observable symptom

On topic 513 after the #93 fix deployed:

  • MeetingSummary.generation_data["item_details"] for m94 (2025-08-04 PUC) correctly contains the fake-stickers story: "Staff said fake garbage stickers are still being found, and the hauler is notifying public works and police. They also noted social media chatter about switching away from the sticker system to an automated option…"
  • But ts514 (TopicSummary for topic 513 × meeting 94) says only: "A meeting agenda includes an item titled 'SOLID WASTE UTILITY: UPDATES AND ACTION, AS NEEDED.'"
  • That stale ts514.generation_data flows into GenerateTopicBriefingJob#build_briefing_context as prior_meeting_analyses, polluting the briefing's factual_record with generic entries even though the underlying meeting has specific content.

Root cause

app/services/topics/summary_context_builder.rb:34-88agenda_items_data builds each item as:

{
  id: item.id,
  number: item.number,
  title: item.title,
  summary: item.summary,             # AgendaItem.summary — almost always nil
  recommended_action: item.recommended_action,
  citation: item_citation,
  attachments: doc_attachments       # item-level packet attachments
}

No call to MeetingSummary.generation_data["item_details"]. The per-item minutes content exists but never reaches the per-meeting topic summary prompt.

Proposed fix

Mirror #93's pattern:

  1. Add a helper on Topics::SummaryContextBuilder (or a new service) that, for the meeting bound to the builder, fetches the latest MeetingSummary.generation_data["item_details"] and matches entries to the linked agenda items via Topics::TitleNormalizer.normalize.
  2. Include the matched entries in agenda_items_data output under a new key (e.g. item_details_summary) alongside summary/recommended_action.
  3. Update the analyze_topic_summary prompt template (lib/prompt_template_data.rb) to reference the new field and prefer it over raw packet previews when writing per-meeting factual_record entries.
  4. Re-run SummarizeMeetingJob for affected meetings to regenerate TopicSummary rows with fresh content.
  5. Re-run GenerateTopicBriefingJob for affected topics so the briefing picks up the cleaner prior_meeting_analyses.

Scope

Acceptance

After this fix plus a cascade rerun of SummarizeMeetingJob for topic 513's live meetings (m94, m8, m178):

  • ts514 (m94 × topic 513) factual_record names the fake-stickers story, not "agenda includes an item titled…"
  • Topic 513's briefing factual_record entry for 2025-08-04 references the fake stickers incident
  • Topic 513's briefing factual_record contains no residual "agenda included" boilerplate across meetings where minutes exist

Discovered while working on

Refs #93. Surfaced while diagnosing why topic 513's briefing still had a generic m94 entry after #93 shipped. See the diagnostic output in the #93 PR comments / plan doc for details.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions