Skip to content

Add agentic retrieval response fields to RetrievalQueryResponse #81

Description

@EricNGOntos

Summary

The Knowhere retrieval API has been updated (knowhere#57) with a slimmed response contract and a new per-request useAgentic toggle. The Node SDK needs to sync its types accordingly.

Changes Required

1. New Request Parameter: useAgentic

Add useAgentic?: boolean to client.retrieval.query():

const response = await client.retrieval.query({
  namespace: 'support-center',
  query: 'How do I reset Bluetooth pairing?',
  useAgentic: true,   // force agentic mode
  // useAgentic: false  // force legacy 3-channel RRF
  // omit useAgentic    // use server default
});

console.log(response.answerText);  // LLM-generated answer
console.log(response.referencedChunks);  // cited evidence
Value Behavior
true Force agentic retrieval (LLM navigation + answer synthesis)
false Force legacy retrieval (3-channel RRF only)
undefined / omitted Use server default (RETRIEVAL_AGENTIC_ENABLED env var)

2. New Response Fields

Add two optional fields to the retrieval response interface:

Field Type Description
answerText string | null LLM-generated natural-language answer (agentic mode only)
referencedChunks Array<object> | null Cited evidence chunks with assetUrl (agentic mode only)

3. New Request Parameter: dataType

Add dataType?: number (1-6) for chunk type filtering:

Value Filter
1 All types (default)
2 Text only
3 Image only
4 Table only
5 Text + Image
6 Text + Table

4. Removed (do NOT add)

  • enableDecomposition — removed from API, was deprecated
  • plan, steps, finalStrategyUsed, walletSnapshot, plannerSnapshot, evidenceText — removed from response, internal debug fields

Final API Contract (as of knowhere#57)

Request:

interface RetrievalQueryRequest {
  namespace?: string;
  query: string;
  topK?: number;                    // default 10
  useAgentic?: boolean;             // NEW
  dataType?: number;                // 1-6, default 1
  excludeDocumentIds?: string[];
  excludeSections?: ExcludeSection[];
  signalPaths?: string[];
  filterMode?: 'delete' | 'keep';
  channels?: ('path' | 'content' | 'term')[];
  channelWeights?: Record<string, number>;
  rerank?: boolean;
  threshold?: number;
  internalRecallK?: number;
}

Response:

interface RetrievalQueryResponse {
  namespace: string;
  query: string;
  routerUsed: string;
  answerText: string | null;            // NEW - agentic LLM answer
  referencedChunks: Array<object>;      // NEW - cited evidence
  results: Array<RetrievalResult>;      // legacy chunk results
}

Acceptance Criteria

  • useAgentic parameter supported in client.retrieval.query()
  • dataType parameter supported
  • Response interface includes answerText and referencedChunks
  • At least one example shows useAgentic: true with response.answerText
  • Existing tests pass (all new fields are optional)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions