AgentSkillsCN

Database Engine

数据库引擎

SKILL.md

Database Engine

Role

The database engine handles all direct device lookups, specification queries, filtered searches, and comparisons against the in-memory device database. It does NOT perform compatibility analysis (that is the chain engine's job) and does NOT search IFU/documentation (that is the vector engine's job).

When to use: spec lookups, device searches by dimension/manufacturer/category, device comparisons, extracting specific field values.

When NOT to use: compatibility checks ("Can I use X with Y?"), IFU/documentation lookups, clinical guidelines.

Architecture

code
User Query
    |
    v
QuerySpecAgent (LLM, fast model)
    |  Generates structured JSON query spec
    v
QueryExecutor (Pure Python)
    |  Executes query spec against DATABASE
    v
DatabaseOutputAgent (LLM, streaming)
    |  Formats results into natural language
    v
SSE Response

Filter path (used by query planner): Bypasses the LLM QuerySpecAgent entirely. The orchestrator's query planner provides a pre-built query spec with input_type: "filter", which goes directly to QueryExecutor.


Database Schema

Each device record in DATABASE is a flat dict keyed by numeric string ID (e.g., "56").

Identity Fields

FieldTypeDescriptionExample
product_namestringCommercial product name"Headway 21"
device_namestringFull device descriptor"Headway 21 Microcatheter"
manufacturerstringCompany name"MicroVention/Terumo"
idstringUnique numeric ID"56"

Classification Fields

FieldTypeDescriptionExample
category_typestringPrecise device type"microcatheter"
conical_categorystringHierarchy level (L0-L5, LW)"L3"
logic_categorystringCompatibility logic grouping"microcatheter"
fit_logicstringFit rule type for compat evaluation"OD_ID"

Dimension Fields

FieldTypeUnitDescription
specification_inner-diameter_infloatinchesInner diameter
specification_inner-diameter_mmfloatmmInner diameter
specification_inner-diameter_FfloatFrenchInner diameter
specification_outer-diameter-distal_infloatinchesOuter diameter (distal tip)
specification_outer-diameter-distal_mmfloatmmOuter diameter (distal tip)
specification_outer-diameter-distal_FfloatFrenchOuter diameter (distal tip)
specification_outer-diameter-proximal_infloatinchesOuter diameter (proximal)
specification_outer-diameter-proximal_mmfloatmmOuter diameter (proximal)
specification_outer-diameter-proximal_FfloatFrenchOuter diameter (proximal)
specification_length_cmfloatcmWorking length

Compatibility Rule Fields (used by chain engine)

FieldTypeDescription
wire_max_ODfloatMax guidewire OD that fits inside
catheter_max_ODfloatMax catheter OD that fits inside
catheter_required_IDfloatMin catheter ID needed for this device
guide_min_IDfloatMin guide catheter ID needed
catheter_min_IDfloatMin catheter ID needed
sheath_min_IDfloatMin sheath ID needed

Category System

Devices are classified by category_type (precise) and conical_category (hierarchy level).

Category Type Values

category_typeDescriptionL-Level
sheathAccess sheathsL0
balloon_guide_catheterBalloon guide catheters (BGC)L1
guide_intermediate_catheterGuide/intermediate dual-role cathetersL0, L1
intermediate_catheterStandard intermediate cathetersL1, L2
delivery_intermediate_catheterDelivery intermediatesL2
aspiration_intermediate_catheterAspiration intermediatesL2
distal_access_catheterDistal access catheters (DAC)L2
aspiration_system_componentAspiration system componentsL2
microcatheterStandard microcathetersL3
balloon_microcatheterBalloon microcathetersL3
flow_dependent_microcatheterFlow-dependent microcathetersL3
delivery_catheterDelivery cathetersL3
stent_systemStent systemsL4
stent_retrieverStent retrieversL5
guidewireGuidewiresLW

User-Facing Category Mappings

When users mention a device category, the executor maps it to the correct category_type values:

User TermMatches category_type values
microcatheter / micromicrocatheter, balloon_microcatheter, flow_dependent_microcatheter, delivery_catheter
aspiration / aspiration_catheteraspiration_intermediate_catheter, distal_access_catheter, aspiration_system_component
intermediate / intermediate_catheterguide_intermediate_catheter, intermediate_catheter, delivery_intermediate_catheter, aspiration_intermediate_catheter
bgc / balloon_guide_catheterballoon_guide_catheter
guide / guide_catheterballoon_guide_catheter, guide_intermediate_catheter
sheathsheath
dac / distal_access_catheterdistal_access_catheter
stent / stent_retrieverstent_system, stent_retriever
wire / guidewireguidewire
catheter (broad)All L1-L3 types (falls back to conical_category)

Conical Category Hierarchy

code
L0 (outermost)  — Sheaths, guide catheters
  L1             — BGC, guide/intermediate catheters
    L2           — Aspiration, DAC, intermediate catheters
      L3         — Microcatheters, delivery catheters
        L4       — Stent systems
          L5     — Stent retrievers
        LW       — Guidewires

Higher L-number = goes INSIDE lower L-number.


QueryExecutor Actions Reference

get_device_specs

Purpose: Retrieve full specs for specific device IDs. Input: device_ids: string[] Output: Array of device spec objects with identity + specifications.

filter_by_spec

Purpose: Find devices matching a category and/or dimension filters. Input: category: string (optional), filters: [{field, operator, value}] (optional) Output: Array of matching device specs. Category matching: Uses category_type first (precise), falls back to conical_category for broad terms.

find_compatible

Purpose: Find devices that physically fit with a source device at a single connection point. Input: source_device_ids: string[], target_category: string, direction: "inner"|"outer", check_length: boolean Output: Array of compatible device specs with compatibility_reason. Note: This is a simplified OD/ID math check. For full compatibility analysis with all rules, use the chain engine.

compare_devices

Purpose: Pull specs for multiple devices side by side. Input: device_groups: string[][] — groups of device IDs to compare. Output: Array of all device specs (flattened from all groups).

extract_value

Purpose: Extract a specific field value from a previous step's results. Input: from_step: string, field: string, aggregation: "min"|"max"|"avg"|"first" Output: Single value (number or string).

search_both_id_od

Purpose: Search for devices by a dimension value when it's ambiguous whether the user means ID or OD. Input: category: string, dimension_value: float, dimension_operator: string, additional_filters: [{field, operator, value}] Output: {id_matches: [], od_matches: [], dimension_value, dimension_operator}

intersect

Purpose: Find devices common to multiple result sets. Input: from_steps: string[] Output: Array of devices present in ALL referenced steps.

union

Purpose: Combine multiple result sets (deduplicated by device_id). Input: from_steps: string[] Output: Array of unique devices from all referenced steps.


Field Name Mapping

The QuerySpecAgent uses friendly field names. The executor maps them to raw database fields:

Friendly NameDatabase Field
ID_inspecification_inner-diameter_in
ID_mmspecification_inner-diameter_mm
ID_Frspecification_inner-diameter_F
OD_distal_inspecification_outer-diameter-distal_in
OD_distal_mmspecification_outer-diameter-distal_mm
OD_distal_Frspecification_outer-diameter-distal_F
OD_proximal_inspecification_outer-diameter-proximal_in
OD_proximal_mmspecification_outer-diameter-proximal_mm
length_cmspecification_length_cm
product_nameproduct_name
manufacturermanufacturer
conical_categoryconical_category
category_typecategory_type

Common Query Patterns

User QueryActionNotes
"What is the OD of Vecta 46?"get_device_specsSimple spec lookup
"What microcatheters are available?"filter_by_spec (category only)No dimension filters needed
"Catheters with ID > .074"filter_by_spec with filtersCategory + dimension filter
"Show me Medtronic aspiration catheters"filter_by_spec with manufacturer filterCategory + string filter
"I need a .017 catheter"search_both_id_odAmbiguous dimension
"Compare Vecta 46 and Sofia"compare_devicesSide-by-side specs
"What wire fits inside SL-10?"find_compatible (direction=inner)Single-point compatibility
"What is the min ID across these devices?"extract_value (aggregation=min)Value extraction from prior step