Sep02
The integration of artificial intelligence into medicine is shifting from simple data analysis to a dynamic paradigm of agentic systems. These systems empower specialized AI agents to autonomously orchestrate and execute complex workflows, a capability that is particularly impactful in high-stakes fields like oncology. By examining a clinical decision support system designed to handle a breast cancer case, we can observe how this architecture provides a comprehensive and actionable plan that augments, rather than replaces, human expertise.
At its core, this system operates on a multi-agent framework composed of three distinct roles: the Orchestrator, the Executor, and a network of Specialist Agents. The Specialist Agents are a suite of purpose-built tools, implemented as Python functions, that perform atomic clinical tasks. These include retrieving a patient's electronic health record, ordering diagnostic tests such as a CT scan or biopsy, and obtaining their results. This modular design allows the system to dynamically interact with and gather data from a simulated external environment. The complete code is here https://github.com/frank-morales2020/MLxDL/blob/main/AAI_DEEPSEEK_ONCOLOGY.ipyn
The entire process is driven by the Orchestrator Agent, which acts as the central intelligence managing the workflow. It directs the Executor Agent, a component of the code itself, to fulfill its commands by running the corresponding Python functions with the correct arguments. This collaborative structure enables the system to perform a sequence of complex tasks, with each agent contributing its specific expertise to the overall goal.
The narrative of this system unfolds as an iterative cycle of observation and action. The agent successfully handled this complex oncology case by systematically gathering data and synthesizing it into a clinically relevant recommendation. The final output demonstrates a high level of reasoning based on a sequential, multi-step process.
Agentic Workflow Breakdown ️
The agent's decision-making is a direct result of its tool-calling sequence:
Initial Assessment: The process starts with a call to get_patient_ehr
, which retrieves crucial patient information, including a history of breast cancer and a family history of breast and ovarian cancer. This initial step is fundamental for contextualizing the user's query about potential recurrence.
Diagnostic Data Gathering: The agent then orders and retrieves a series of diagnostic tests. It calls get_tumor_marker_results
and finds an elevated CA-125 level. While CA-125 is most often associated with ovarian cancer, its elevated levels can also be a predictive marker for outcomes in breast cancer, especially in advanced tumours.
Initial Staging: Following the concerning tumour marker result, the agent orders a CT scan to check for distant metastasis. The results come back negative, which is a favourable finding in the context of cancer.
Definitive Diagnosis: The agent's final diagnostic step is to order and retrieve a biopsy. This is the most crucial action, as only a biopsy can provide a definitive diagnosis of cancer. The biopsy confirms the recurrence of "invasive ductal carcinoma (IDC), HER2-positive".
Clinical Recommendation Analysis
The final recommendation is a comprehensive synthesis of the gathered data. The agent correctly identifies and processes complex, potentially conflicting information to provide a nuanced plan:
Synthesizing Conflicting Data: The agent effectively resolves the conflict between the elevated tumour marker (suggesting active disease) and the negative CT scan (suggesting no distant spread). It concludes that the elevated marker is concerning for a recurrence not yet visible on imaging and requires further evaluation.
The Significance of HER2-Positive Status: The agent correctly highlights the HER2-positive status of the confirmed carcinoma as a critical finding. HER2 is a protein that can cause cancer cells to grow and spread more rapidly. However, a positive status indicates that the cancer is likely to respond to highly effective targeted therapies that specifically target the HER2 protein. The agent's recommendation to consider "targeted treatment options including HER2-directed therapies" demonstrates its understanding of this key clinical factor.
Comprehensive Plan: The recommendation to have the case reviewed by a multidisciplinary tumour board and to schedule an urgent consultation reflects the standard of care for a complex oncology case. It demonstrates the agent's ability to provide a comprehensive, multifaceted plan that extends beyond a simple diagnosis.
The system's sophisticated behaviour is made possible by its underlying technology: a single, hybrid model from DeepSeek. This model, identified as DeepSeek V3.1, unifies the distinct capabilities of two previous models into a single, highly efficient architecture. DeepSeek V3.1 operates in two modes:
Non-Thinking Mode (deepseek-chat): This fast and efficient mode is used by the Orchestrator to manage the workflow and perform function calls. It is optimized for speed and structured outputs, enabling the system to interact quickly and accurately with its various Specialist Agents.
Thinking Mode (deepseek-reasoner): The more powerful thinking mode is dynamically engaged by the platform when deep reasoning and complex synthesis are required. This mode performs the logical analysis necessary to interpret conflicting data and formulate the final, expert-level diagnosis and treatment plan.
This hybrid design represents a significant advancement, enabling the system to achieve the high accuracy of a reasoning model while maintaining the speed and efficiency of a conversational model. By seamlessly switching between these two modes, the system navigates the complexities of a clinical case, from data collection to final recommendation, within a single, coherent framework.
This system exemplifies a new frontier in AI by demonstrating a dynamic, multi-agent framework capable of sophisticated problem-solving. It is a powerful example of how artificial intelligence can be a valuable collaborator in a high-stakes professional field. By handling the tedious processes of data retrieval and initial synthesis, this technology allows physicians to dedicate more time to direct patient care and complex treatment discussions. As agentic systems continue to evolve, they will become indispensable collaborators, providing physicians with a powerful tool to navigate the ever-increasing complexity of medical science and ultimately leading to more precise, personalized, and effective care.
Keywords: Generative AI, Open Source, Agentic AI