ToolFlow: Deterministic Agent Orchestration via Collision-Free Dataflow Graphs — Application to On-Device Agentic Radiology with MedGemma-4B

Read full text
Authors: EMMANUEL URAMAH
Cited by: 0

Abstract

Current agentic AI architectures couple planning with execution, requiring large language models (LLMs) to simultaneously reason about what to do and how to do it. This coupling renders small models unreliable for multi-step workflows, as planning hallucinations compound with chain length. We introduce ToolFlow, a declarative agent architecture that decouples orchestration from semantic reasoning through three components: a stateful context cache, a collision-free tool registry enforcing the invariant I(τ) ∩ O(τ) = ∅, and a deterministic flow engine that resolves minimal execution paths via backward depth-first search over the resulting directed acyclic graph (DAG). ToolFlow reduces the LLM's role to value extraction and goal identification while graph traversal handles all combinatorial planning. We implement ToolFlow in the nanoathens SDK and validate it through the Gemma Co-Radiologist, an on-device radiology agent orchestrating 16 specialized tools across chest X-ray, CT head, and CT abdomen modalities using MedGemma-4B (4 billion parameters). On a precision oncology benchmark (27 tools, 10 queries), ToolFlow achieves F1 = 0.952 with perfect precision and 8/10 exact matches, compared to F1 = 0.569 for ReAct on the same model. On CheXpert validation, the Co-Radiologist achieves an 80.0% proficiency index on rare pathology cases, outperforming vanilla MedGemma by 3.9 points. A deep research extension produces 35–50 page medical literature reports within 8192-token context limits, demonstrating that architectural design can overcome small model constraints without cloud infrastructure.

Fields of Study & Subjects

Artificial Intelligence in Healthcare and Education AI-based Problem Solving and Planning Multimodal Machine Learning Applications

Publication details

Journal / source
Zenodo (CERN European Organization for Nuclear Research)
Publication date
26 February 2026
Language
EN