Skip to content

Research Query

POST
/api/agents/research/query

Execute entity-aware research query with strategic insights.

Performs sophisticated research queries that understand entities and their relationships, providing contextual results with strategic analysis.

Process:

  1. Parse query to identify key entities and concepts
  2. Execute semantic search across configured scope
  3. Extract entities from results
  4. Generate strategic insights
  5. Return ranked results with analysis

Args: request: ResearchQueryRequest with query and search parameters.

Returns: ResearchQueryResponse with results, entities, and insights.

Raises: HTTPException 400: Invalid query or parameters. HTTPException 500: Lagan processing error. HTTPException 503: Lagan agent not available.

Example Request: json POST /api/agents/discovery/research/query { "query": "artificial intelligence applications in medicine", "search_scope": "documents", "max_results": 10, "include_entities": true, "include_insights": true, "context": {"project": "medical_ai"} }

Example Response: json { "success": true, "query": "artificial intelligence applications in medicine", "total_results": 10, "results": [...], "entities": [...], "insights": ["AI medical applications show..."], "processing_time_ms": 523 }

ResearchQueryRequest

Request for entity-aware research query.

Initiates a research query with entity extraction, strategic insights, and configurable search scope across documents and web sources.

Fields:

  • query: Research query or question (required, non-empty)
  • search_scope: Scope of search (documents, web, all)
  • max_results: Maximum number of results to return (1-100, default 10)
  • include_entities: Whether to extract entities from results
  • include_insights: Whether to generate strategic insights
  • context: Additional context for query (project, domain, etc.)

Search Scope:

  • documents: Search only local document collections
  • web: Search web sources only
  • all: Search both documents and web sources

Usage: Used to initiate research queries with intelligent result processing.

Integration:

  • ResearchRoutes: Request validation for /research/query endpoint
  • LaganAgent: Research query execution
  • RAG System: Document retrieval
object
query
required
Query

Research query or question

string
>= 1 characters
searchScope
Searchscope

Scope of search (documents, web, all)

string
default: documents
Allowed values: documents web all
maxResults
Maxresults

Maximum number of results to return

integer
default: 10 >= 1 <= 100
includeEntities
Includeentities

Extract and return entities from results

boolean
default: true
includeInsights
Includeinsights

Generate strategic insights from results

boolean
default: true
context
Context

Additional context (project, domain, etc.)

object
key
additional properties
string
sources
Any of:
Array<string>
Allowed values: wikipedia bookmarks feeds

Successful Response

ResearchQueryResponse

Response for research query with results and insights.

Provides comprehensive research results with extracted entities, strategic insights, and performance metrics.

Fields:

  • success: Whether query was successful
  • query: Original query text
  • total_results: Total number of results found
  • results: List of research results ordered by relevance
  • entities: Aggregated entities extracted from all results
  • insights: Strategic insights derived from results
  • processing_time_ms: Total processing time in milliseconds

Usage: Returned by research endpoints after query execution.

Integration:

  • ResearchRoutes: Response model for /research/query endpoint
  • Frontend: Research results display and visualization
object
success
required
Success

Whether query was successful

boolean
query
required
Query

Original query

string
totalResults
required
Totalresults

Total number of results found

integer
results
Results

Research results ordered by relevance

Array<object>
ResearchResult

Single research result item.

Represents an individual result from a research query with content, source, relevance scoring, and extracted entities.

Fields:

  • title: Result title or heading
  • content: Result content or excerpt
  • source: Source URL or document ID
  • relevance_score: Relevance to query (0.0-1.0, higher is more relevant)
  • entities: Entities extracted from this result
  • metadata: Additional metadata (date, author, document type, etc.)

Usage: Used in research query responses to return individual results.

Integration:

  • ResearchQueryResponse: Results list in research responses
  • Frontend: Research results display
object
title
required
Title

Result title or heading

string
content
required
Content

Result content or excerpt

string
source
required
Source

Source URL or document ID

string
relevanceScore
required
Relevancescore

Relevance to query

number
<= 1
entities
Entities

Entities found in result

Array<object>
Entity

Extracted entity from content with type classification and confidence scoring.

Represents a named entity (person, place, organization, concept, etc.) extracted from analyzed content with confidence scoring and contextual information.

Fields:

  • name: Entity name or identifier as extracted from content
  • entity_type: Classification type (person, place, organization, concept, etc.)
  • confidence: Extraction confidence score from 0.0 to 1.0
  • context: Surrounding text context where entity was found

Usage: Used in perception and research responses to return extracted entities.

Integration:

  • WebpagePerceptionResponse: Entity list in perception results
  • ResearchResult: Entities extracted from research results
  • EnrichContentResponse: Additional entities from enrichment
object
name
required
Name

Entity name or identifier

string
entityType
required
Entitytype

Entity type (person, place, concept, etc.)

string
confidence
required
Confidence

Extraction confidence score

number
<= 1
context
Any of:
string
metadata
Metadata

Additional metadata (date, author, etc.)

object
key
additional properties
string
entities
Entities

All entities extracted from results

Array<object>
Entity

Extracted entity from content with type classification and confidence scoring.

Represents a named entity (person, place, organization, concept, etc.) extracted from analyzed content with confidence scoring and contextual information.

Fields:

  • name: Entity name or identifier as extracted from content
  • entity_type: Classification type (person, place, organization, concept, etc.)
  • confidence: Extraction confidence score from 0.0 to 1.0
  • context: Surrounding text context where entity was found

Usage: Used in perception and research responses to return extracted entities.

Integration:

  • WebpagePerceptionResponse: Entity list in perception results
  • ResearchResult: Entities extracted from research results
  • EnrichContentResponse: Additional entities from enrichment
object
name
required
Name

Entity name or identifier

string
entityType
required
Entitytype

Entity type (person, place, concept, etc.)

string
confidence
required
Confidence

Extraction confidence score

number
<= 1
context
Any of:
string
insights
Insights

Strategic insights derived from results

Array<string>
processingTimeMs
required
Processingtimems

Processing time in milliseconds

integer

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object