← Muhammad Hasheem Iftikhar
Thesis · Joint MICCAI 2027 submission planned

Enhancing mAIstro

Making Small Language Models Reliable in Multi-Agent Medical AI Workflows

Muhammad Hasheem Iftikhar, Ali Soban, ImadUddin Muhammad

FAST-NUCES Karachi · supervised by Ms. Alina Arshad · in collaboration with the original mAIstro authors Dr. Eleftherios Tzanis and Dr. Michail E. Klontzas

The enhanced mAIstro two-tier architecture
The enhanced mAIstro architecture. A Master Router Agent delegates tasks through structured JSON, and specialized sub-agents run each task through a four-stage optimization pipeline built for small models.
10–18% → 91%task success on small local models
+81 ptsMistral 7B
+73 ptsLlama 3.1 8B
~4×faster segmentation on a CPU

Abstract

mAIstro is an open-source multi-agent framework that runs exploratory data analysis, radiomic feature extraction, medical image segmentation and classification from natural-language requests. It succeeds on every task with frontier models such as GPT-4o and Claude Sonnet 3.7, but cloud-hosted models conflict with data-sovereignty rules (HIPAA/GDPR), cost a lot and add latency. When moved to locally deployable small language models such as Llama 3.1 8B or Mistral 7B, task success drops to 10 to 18%, leaving resource-constrained clinics without agentic AI.

We close this gap by targeting the root causes of small-model failure in agentic pipelines: a decoupled architecture of 13+ specialized agents; JSON-driven tool execution with schema-constrained configuration in place of fragile code generation; a four-stage optimization pipeline of context pruning, enforced chain-of-thought, constrained decoding with dynamic schema validation and parameter sanitization; agentic RAG with dynamic schema slimming over a 10,000+ line tool library; and CPU-optimized tool defaults. The result is a fully offline, privacy-preserving pipeline that reaches 91% task success across four open models on modest hardware.

The problem

Built for frontier models, broken on small ones

The original system routes every request through one Master Agent and eight sub-agents that generate Python code. Small models overflow the context, lose the thread of reasoning, invent tools and write code that does not run.

The original mAIstro architecture
The original mAIstro. A single Master Agent coordinates eight specialized sub-agents for end-to-end medical AI workflows.

Method

Engineering reliability back in

01 · Decoupled agents

13+ agents with training and inference split apart, so no agent faces an oversized tool set that invites routing hallucinations.

02 · JSON tool execution

Schema-constrained tool calls replace generated Python, removing syntax errors and invented libraries.

03 · Four-stage pipeline

Context pruning, enforced reasoning, constrained decoding and parameter sanitization, each fixing one failure mode.

04 · Agentic RAG

FAISS retrieval with schema slimming returns only the tool documentation a step needs.

05 · CPU-aware tools

CPU-optimized defaults for PyCaret, TotalSegmentator and nnU-Net run without a GPU.

Fully offline

No patient data leaves the machine, and no cloud infrastructure is needed.

Four-stage SLM optimization pipeline
The four-stage optimization pipeline. Each stage addresses one failure mode: context overflow, reasoning fragmentation, syntactic hallucination and execution fragility. Invalid tool calls at stage 3 are sent back to stage 2 for self-correction.
Decoupled multi-agent architecture
Decoupled agents. Training and inference live in separate agents, which prevents tool-routing hallucinations.
Schema slimming and agentic RAG
Schema slimming and agentic RAG. Compact tool schemas plus on-demand documentation keep the context window from saturating.

Results

Four open models, one level of reliability

Each model was evaluated on 11 task categories, against the original paper's baseline.

ModelParamsBaselineOptimizedChange
Mistral 7B7B10%91%+81
Llama 3.1 8B8B18%91%+73
Mistral 3.1 24B24B36%91%+55
Llama 4 Scout17B91%91%0

Task success rate in percent; change in percentage points. Every model passes 10 of 11 task categories after optimization.

Task success rate, baseline versus optimized
Task success, baseline vs. optimized. Every model converges to 91%.
Improvement over baseline per model
Improvement over baseline. The smallest models gain the most.

Runs on consumer hardware

ComponentUnoptimizedOptimized
TotalSegmentator~45 min / scan~10 min / scan
PyCaret trainingUnboundedUnder 10 min, budget-capped
PyTorch trainingVariableEarly stopping at convergence
Prompt sizeBaseline15–30% smaller

Measured on a standard CPU with no GPU.

System

No programming required

The optimized mAIstro interface during a live run
The optimized mAIstro interface. Users choose the small-model backend and target agent, describe the task in plain language, and watch reasoning traces and execution logs in real time.

The original mAIstro authors, Dr. Michail E. Klontzas and Dr. Eleftherios Tzanis, held planning meetings with our team and are independently evaluating this system ahead of a joint MICCAI 2027 submission.

More research