33med

title: "Dynamic Tool Selection in AI Swarms"
description: "How 33MED is engineering lean, autonomous LLM swarms to orchestrate native bioinformatics binaries and computational physics pipelines without infrastructure bloat."
date: 2024-05-24
author: "33MED Engineering"
category: "Panoptix Swarm & AI Orchestration"

Dynamic Tool Selection in AI Swarms: Teaching LLMs to Execute Native Binaries

The bottleneck in modern computational biology is no longer intelligence; it is orchestration. While large language models (LLMs) can hypothesize novel molecular targets and binding thermodynamics, their utility hits a wall when trapped within rigid, chat-based interfaces. To build the foundational infrastructure for autonomous biotech and surgical robotics, we must grant AI swarms the agency to interact directly with the physical and simulated world.

At 33MED, we are evolving our ImmuNav prototype into our Phase 1 commercial engine. We are stripping away academic infrastructure bloatβ€”retiring fragile Python orchestration frameworks and heavy message brokers like RabbitMQβ€”in favor of a hyper-performant, highly deterministic Node.js, MongoDB, and React ecosystem.

This is the blueprint for how 33MED is teaching AI swarms to dynamically select tools, write parameters, and autonomously execute native CLI binaries for computational immunology.


🧬 The Core Tool Matrix: 100% Commercial-Safe Execution

To build a scalable B2B SaaS platform, licensing landmines (like AlphaFold 3’s non-commercial restrictions) must be bypassed. Our Node.js backend operates as a deterministic orchestrator, bypassing restricted endpoints and utilizing native child_process execution to fire fully open, commercial-safe alternatives.

Instead of writing complex API wrappers, the swarm dynamically generates payload configurations and executes pre-compiled CLI binaries directly on the host hardware.

Tool Focus Area Licensing Node.js Integration Strategy
Chai-1 / Boltz-1 Multimodal Molecular & Structure Prediction Apache 2.0 / MIT Executed via standalone CLI binaries. The swarm passes dynamically generated JSON/SMILES input payloads.
GROMACS Molecular Dynamics & Binding Thermodynamics GNU LGPL Native gmx commands spawned via Node child_process.spawn() for real-time thread and energy monitoring.
Bioconductor Genomic / Transcriptomic Pathway Mapping Open Source Standalone R scripts executed via Rscript CLI to parse RNA sequence and expression datasets.
Chaste Tissue-Scale Cellular Calcification Modeling BSD License Swarm generates XML payloads mapping cellular parameters, injecting them directly into the compiled C++ binary.
OpenSim CLI Musculoskeletal Joint & Muscle Load Simulation Apache 2.0 Programmatic execution of opensim-cmd to validate physical mechanical stresses at scale.

πŸ—οΈ The Native Node/Mongo Swarm Engine

We have eliminated the need for dedicated message brokers. In a lean, high-throughput environment, MongoDB serves as a highly durable, atomic task queue using standard, indexed queries.

Database Architecture: State & Queueing

Our architecture relies on two foundational collections. agents tracks the parameters and objectives of individual LLM operators, while tasks serves as the lightweight queue connecting agent intent to bare-metal hardware execution.

// Collection: tasks (The Lightweight Queue)
{
  _id: ObjectId("66654b..."),
  agentId: ObjectId("66654a..."),
  tool: "gromacs",
  status: "pending_review", // Follows: pending_review -> queued -> processing -> completed
  payload: {
    inputFiles: ["target_sequence.fasta"],
    md_params: { nsteps: 50000, dt: 0.002, integrator: "md" } // Validated via Zod
  },
  humanSignOff: {
    isApproved: false,
    actionedAt: null
  },
  logs: [], 
  outputMetadata: { pdbId: "1AKI", finalEnergy: -420000 }
}

The Autonomous Background Loop

Running on our Simulation Worker, a lightweight recursive polling loop queries MongoDB for actionable, approved jobs. It respects global pause states and streams standard output (stdout/stderr) from the native binaries directly back into the database for real-time frontend monitoring.

async function processQueue() {
  // 1. Structural Check: Ensure swarm isn't globally paused by human oversight
  const globalStatus = await db.collection('settings').findOne({ key: 'swarm_status' });
  if (globalStatus?.isPaused) {
    setTimeout(processQueue, 5000);
    return;
  }

  // 2. Fetch next executable task atomically (Must be approved & queued)
  const task = await db.collection('tasks').findOneAndUpdate(
    { status: 'queued', 'humanSignOff.isApproved': true },
    { $set: { status: 'processing', startedAt: new Date() } },
    { sort: { createdAt: 1 }, returnDocument: 'after' }
  );

  if (!task) return setTimeout(processQueue, 2000);

  try {
    // 3. Native binary execution via Node Child Processes
    const binaryProcess = child_process.spawn(getToolBinary(task.tool), task.payload.cliArgs);
    
    binaryProcess.stderr.on('data', (data) => {
      db.collection('tasks').updateOne({ _id: task._id }, { $push: { logs: data.toString() } });
    });

    binaryProcess.on('close', async (code) => {
      code === 0 
        ? await handleTaskSuccess(task) 
        : await db.collection('tasks').updateOne({ _id: task._id }, { $set: { status: 'failed' } });
      processQueue(); // Instantly process next job
    });
  } catch (error) {
    // Handle catastrophic binary failure gracefully
    await db.collection('tasks').updateOne({ _id: task._id }, { $set: { status: 'failed', error: error.message } });
    processQueue();
  }
}

πŸ“‘ Automated Data Ingestion & LLM Structuring

Models are only as powerful as their grounding data. Our Data Ingestion Agents operate as automated daemons, continuously harvesting literature and transforming raw text into highly structured graph data.

  1. PubMed Integration (NCBI Entrez): Utilizing a programmatic API key to elevate limits to 10 requests/second, the swarm pulls targeted keyword pairs (e.g., Ankylosing Spondylitis AND syndesmophyte).
  2. arXiv Feed: Ingesting native Atom/XML endpoints for pre-print quantitative biology (q-bio) research.
  3. Gemini Extraction Pipeline: Raw XML blocks are buffered into our Node backend and passed into the Google Gemini SDK. Using strict system prompting, the LLM is forced to return deterministic JSON, extracting molecular targets, binding affinities, and gene expressions, which are instantly inserted into the 33MED knowledge base.

πŸŽ›οΈ Executive Control: The HITL React Dashboard

Autonomy without control is a liability. To ensure our computational immunologists maintain absolute executive authority over the AI swarm, we engineered the ImmuNav Automation Hub via a React frontend.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ IMMUNAV AUTOMATION HUB                                [ SYSTEM STATUS: RUNNING ] β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ [ πŸ›‘ GLOBAL SWARM PAUSE ]   [ πŸ”„ RESUME SYSTEM ]   [ ✍️ EDIT GLOBAL OBJECTIVE ] β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ ACTIVE AGENTS                                                                β”‚
β”‚ πŸ€– Agent_Ingestion_1  β”‚ Status: [ WORKING ]  β”‚ Task: Scraping arXiv q-bio    β”‚
β”‚ πŸ€– Agent_Operator_3   β”‚ Status: [ BLOCKED ]  β”‚ Task: Awaiting Config Approvalβ”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 🚨 AGENT CONFIGURATION APPROVAL GATEWAY                                      β”‚
β”‚ Task ID: #98322  β”‚ Tool Target: GROMACS Molecular Dynamics                    β”‚
β”‚ Target Interaction: Small-molecule inhibitor binding to IL-17 Receptor        β”‚
β”‚                                                                              β”‚
β”‚ [ View Agent-Suggested md_params Payload ]                                   β”‚
β”‚  {                                                                           β”‚
β”‚    "integrator": "md",                                                       β”‚
β”‚    "nsteps": 50000,                                                          β”‚
β”‚    "dt": 0.002                                                               β”‚
β”‚  }                                                                           β”‚
β”‚                                                                              β”‚
β”‚  ✏️ [ Manually Edit JSON Parameters Inline ]                                  β”‚
β”‚  ──────────────────────────────────────────────────────────────────────────  β”‚
β”‚            [ ❌ REJECT CONFIGURATION ]      [ ⚠️ APPROVE & RUN JOB ]          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ§ͺ Safe Iteration: Micro-Dataset Testing Protocols

To rapidly iterate on our infrastructure without exhausting computational resources or burning API quotas, 33MED enforces a strict micro-testing protocol during development:

  1. Sandboxed Data Retrieval: We hardcode low extraction boundaries (&retmax=3 for PubMed; &max_results=3 for arXiv). This verifies scraping logic, regex sanitization, and LLM JSON structuring instantly before opening the floodgates.
  2. Molecular Benchmarking (1AKI): Instead of running heavy human spinal proteins during architecture design, agents target Hen Egg White Lysozyme (PDB ID: 1AKI). This tiny benchmarking structure allows an energy minimization sequence in Chai-1 or GROMACS to complete in under 2 minutesβ€”providing an immediate feedback loop to test stdout parsing and exit codes.
  3. Mechanical Simulation: For OpenSim and Chaste, development relies on single-joint pendulum models and 2D cellular grid templates natively found in their source repositories. This ensures the React dashboard renders thermodynamic charts and handles parameter adjustments perfectly before scaling up to full musculoskeletal rigs.

By stripping away the bloat and forcing LLMs to cleanly interface with proven, native computational biology binaries, 33MED is not just building a chat interface. We are building the operating system for autonomous medicine.