Skip to content

[Mixed-source orchestration] Phase 5: Preserve source context across follow-up turns #1060

Description

@paullizer

Parent: #1055

Phase 5 - Conversation Continuity and Selection Semantics

Planning baseline version: 0.250.061

Status: Proposed

Depends on: Phases 1-4 for full behavior

Objective

Make source selection and follow-up behavior predictable across turns without unnecessary reprocessing.

Explicit selections are authoritative. When no current selection exists, conversation history should be used first; previously grounded sources are reauthorized and rerun only when fresh evidence is required.

Current Behavior to Reuse

Conversation metadata already persists last_grounded_document_refs, and Chat already has a history-only sufficiency assessment followed by authorized fallback search.

The remediation should extend that contract to native tabular evidence rather than add a second memory mechanism.

Selection Precedence

  1. Current explicit selection (selection_mode: selected)
  2. Analyze All Documents (selection_mode: all, Analyze only)
  3. History grounding (selection_mode: history)
  4. Relevance candidates (selection_mode: relevance, Chat/Search)

Current explicit selection must never be silently merged with stale prior sources unless the user asks to include both.

Follow-Up Decision Flow

flowchart TD
    A[New prompt] --> B{Current explicit selection?}
    B -- Yes --> C[Resolve and process selected manifest]
    B -- No --> D{History sufficient?}
    D -- Yes --> E[Answer from saved conversation evidence]
    D -- No --> F[Load last grounded refs]
    F --> G[Reauthorize current access and source versions]
    G --> H[Classify sources by native engine]
    H --> I[Run only engines needed for fresh evidence]
    I --> J[Update grounding metadata]
Loading

Scope

1. Extend grounded references

Persist safe document-level fields needed for native routing:

  • document ID
  • scope and scope ID
  • file name/extension
  • source kind
  • source version when available
  • last engine used
  • evidence status

Do not persist raw query results or secret-bearing source descriptors in conversation metadata.

2. History sufficiency

Retain the existing assessment, but include whether the new question requires:

  • no document access
  • narrative retrieval
  • tabular recomputation
  • both engines

Examples requiring tabular recomputation:

  • new filters
  • new grouping/dimensions
  • fresh totals or comparisons
  • a question referring implicitly to the previously used table

Examples that may use history:

  • rephrasing the prior conclusion
  • asking for a shorter summary
  • asking what the previous result means

3. Authorization and source freshness

Before any historical source reuse:

  • revalidate conversation ownership
  • revalidate group membership/public visibility
  • resolve the current source version
  • fail or disclose stale evidence when the source changed

4. Selection UI/backend consistency

Send selection_mode explicitly. Panel visibility must not change source semantics.

Display a compact source-context indicator for the current turn when useful, but do not add instructional clutter to the chat response.

5. All Documents semantics

  • Chat/Search: relevance-bounded
  • Analyze: exhaustive authorized catalog within limits
  • Compare: explicit Source and Targets only

Reject ambiguous all requests for Compare rather than guessing.

Acceptance Criteria

  • A follow-up such as "now break that down by region" reuses and reauthorizes the prior table when no current selection exists.
  • A follow-up answerable from the previous response does not rerun tabular tools.
  • Selecting a new PDF supersedes the previously grounded table.
  • A changed or unauthorized prior source is not reused silently.
  • Current selection semantics are identical whether the panel is open or closed.
  • Analyze All Documents is exhaustive; Chat/Search All Documents is relevance-bounded.
  • Compare without explicit Source/Targets returns a clear validation error.

Tests

  • history-sufficient tabular follow-up
  • fresh tabular calculation follow-up
  • mixed prior grounding requiring both engines
  • explicit selection supersedes history
  • group membership revoked between turns
  • public workspace visibility revoked
  • source version changed between turns
  • no current selection and no grounded refs
  • standard/streaming parity
  • model/agent parity
  • selection panel open/closed parity

Rollout

Use enable_mixed_source_conversation_continuity. Start with explicitly grounded tabular follow-ups, then enable mixed prior-source reruns.

Rollback

Disable native-engine reruns while retaining existing history-only and search fallback behavior.

Exit Gate

Proceed when follow-up turns make deterministic, observable decisions between history reuse and engine rerun, with authorization tests for every scope.

Not in This Phase

  • Long-term semantic memory of raw table results
  • Automatic inclusion of sources older than the latest grounded set
  • Unbounded source catalogs
  • Many-to-many Compare

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status
In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions