DBMedic β€” Autonomous PostgreSQL Diagnostic Agent Integration

TRAINING STATUS & CHECKPOINT DISCLAIMER
No fine-tuned model checkpoint exists for DBMedic.
Phase 4 LoRA/SFT distillation was NOT performed due to hardware and token gating blockers (absence of a dedicated CUDA GPU and gated repository access token). All integration code, agent prompts, deterministic diagnostic tools, reward functions, and dataset curation pipelines are fully implemented and verified via unit tests and dry runs, but no weights were altered or uploaded. The target base model is the original, unmodified CohereLabs/tiny-aya-global.


Model Summary

  • Project: DBMedic (Autonomous Database Diagnostic and Self-Healing Agent)
  • Target Base Model: CohereLabs/tiny-aya-global
  • Architecture Family: cohere2 (multilingual decoder-only transformer, ~3.35 billion parameters)
  • Primary Domain: PostgreSQL database performance analysis, slow-query diagnostics, query plan explanation, and index recommendation.
  • Agent Framework: Custom ReAct diagnostic orchestrator with AgentTune (v1.1.4) training integration.
  • Current Artifact State: Architecture, prompt contracts, tool interfaces, and training pipeline specifications only. Zero fine-tuned checkpoint weights are distributed.

Intended Use & Capabilities

DBMedic integrates with language models to serve as a read-only diagnostic assistant for PostgreSQL database administrators and site reliability engineers.

Core Capabilities

  1. Explain Plan Inspection: Parses EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) output to detect sequential scans, cache misses, nested loops, and high-cost operators.
  2. Table & Index Heuristics: Interrogates database catalog tables (pg_stat_user_tables, pg_stat_user_indexes, pg_class) to determine table footprint, live/dead tuple counts, and index usage efficiency.
  3. Structured Diagnostic Output: Synthesizes observations into a validated JSON schema containing root-cause analysis, supporting evidence, confidence score, and remediation advice.
  4. Safety Boundaries: Strictly enforces read-only access. Any remediation SQL (e.g. CREATE INDEX CONCURRENTLY) is classified as requiring explicit, human approval before execution.

Out-of-Scope & Unintended Uses

  • Autonomous DDL Execution: DBMedic MUST NOT execute DDL or data-modifying queries autonomously. All mutation recommendations must pass through human review.
  • Non-PostgreSQL Engines: Heuristics and catalog inspection queries are strictly built for PostgreSQL (v15+). Using this system against MySQL, Oracle, or SQL Server will result in runtime tool failures.
  • Safety Critical Automated Production Systems: Not designed to run without operator supervision on production mission-critical clusters.

Agent Integration & Tool Calling Protocol

The DBMedic agent interacts with the base model via a strict alternating conversational prompt format adhering to Tiny Aya's tokenizer specifications:

<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># Developer Preamble
You are DBMedic, an expert autonomous PostgreSQL database performance diagnostic agent...<|END_OF_TURN_TOKEN|>
<|START_OF_TURN_TOKEN|><|USER_TOKEN|>Orders for customer 4242 are loading slowly. Diagnose the root cause.<|END_OF_TURN_TOKEN|>
<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_RESPONSE|>{"type": "tool_call", "tool": "explain_query", "arguments": {"query": "SELECT * FROM orders WHERE customer_id = 4242"}}<|END_RESPONSE|><|END_OF_TURN_TOKEN|>

Approved Read-Only Diagnostic Tools

The agent runtime exposes exactly eight read-only diagnostic tools:

  1. explain_query: Runs EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) on candidate queries.
  2. get_table_statistics: Retrieves row counts, sequential scan counts, and vacuum stats.
  3. get_table_size: Measures total disk footprint (table, index, toast) via pg_total_relation_size.
  4. get_index_statistics: Analyzes index scan rates and hit ratios.
  5. check_index_exists: Checks existing index coverage on target columns.
  6. get_running_queries: Examines pg_stat_activity for blocking or long-running queries.
  7. get_table_indexes: Lists all index definitions and uniqueness constraints for a table.
  8. get_database_stats: Measures cache hit ratios, transaction commit rates, and deadlock counts.

Training Specification (Phase 4 AgentTune & LoRA SFT)

Although live fine-tuning was blocked in the local environment, the training pipeline is fully specified and configured in the repository:

  • Framework: AgentTune Project.distill LoRA SFT Distillation (trl==1.7.1, peft, agenttune==1.1.4)
  • LoRA Hyperparameters:
    • r: 16
    • lora_alpha: 32
    • lora_dropout: 0.05
    • target_modules: all-linear (excluding lm_head)
    • bias: none
  • Optimization:
    • learning_rate: 2e-4 with cosine scheduler
    • batch_size: 2 per device (gradient accumulation steps: 4)
    • loss_type: nll (token-level -100 completion-only label masking)
    • max_seq_length: 2048
  • Hardware Requirement: Dedicated NVIDIA CUDA GPU with $\ge 8$ GB VRAM for LoRA SFT distillation ($\ge 12$ GB for GRPO rollouts).

Evaluation & Safety Evidence Summary

Evaluation Domain Benchmark File Provenance Result / Status
PostgreSQL Baseline Execution slow_query_baseline.json Live PostgreSQL 17 execution Median: 24.21 ms (Seq Scan)
Post-Remediation Execution slow_query_after_remediation.json Live PostgreSQL 17 execution Median: 1.19 ms (Index Only Scan, 95.09% speedup)
Red-Team Security Evaluation redteam_results.json Simulated adversarial suite 10/10 attacks blocked (0.0% attack success rate)
Base Model Agent Inference baseline_status.json Local environment check Blocked (no GPU / gated token)
Candidate Model Inference final_evaluation_report.json AuditKIT gate Blocked (no fine-tuned checkpoint exists)

Limitations & Risks

  1. Synthetic Environment Bias: Diagnostic heuristics were developed and benchmarked on a synthetic e-commerce schema (10k customers, 50k products, 200k orders). Real production distributions may exhibit query plans influenced by complex joins, partitioning, or non-default PostgreSQL planner constants (random_page_cost, work_mem).
  2. Hallucination Risk: Pre-trained base models without domain SFT may produce hallucinated table names or malformed tool call JSON. The DBMedic deterministic ToolValidator and ResponseParser runtime guardrails reject such actions, preventing execution.
  3. No Automated Recovery Execution: DBMedic does not autonomously execute remediations; human authorization is required for any database modification.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Namish18/dbmedic-model-artifacts

Finetuned
(171)
this model