Skip to main content

AI Workers: Building and Running Healthcare AI Agents

Overview

Modern healthcare AI isn't just about single models — it's about intelligent orchestration. Think of an AI Worker as your digital healthcare assistant that can read data, make sense of it, act on it, and coordinate with other systems.

In ByteEngine, AI Workers are the heart of your healthcare automation ecosystem.

What Is an AI Worker?

An AI Worker is a programmable, autonomous AI agent that can:

  • Access your FHIR or DICOM servers
  • Use tools (like medical knowledge bases or file storage)
  • Perform reasoning loops
  • Trigger actions through workflows or APIs

They're powered by advanced LLMs (like GPT-4, Claude, and domain-specific medical models) — and can safely interact with health data in compliant, auditable ways.

Analogy

Think of an AI Worker like a hospital resident doctor:

  • It reads the patient's chart (FHIR data)
  • Consults references (Knowledge Base)
  • Thinks through the case (Reasoning)
  • Orders tests or records notes (Actions)
  • Reports results back to the EMR (FHIR Update)

Core Concepts

ConceptDescription
WorkerThe core agent — an autonomous, intelligent process that runs tasks.
SessionContext or memory for the worker — holds messages, history, and task state.
TaskA specific job the worker performs (e.g., analyze lab results).
ToolsExternal connectors the worker can use (e.g., FHIR API, file search, custom endpoints).

How AI Workers Fit In

How AI Workers Fit into ByteEngine

Flow: HealthDataStore (FHIR/DICOM) → patient data → AI Worker → reads and reasons → Session → stores context → Tools → fetch knowledge, query data → Workflow → triggers automation or output

Creating an AI Worker

You can create a worker either via the dashboard or the API.

Using the Dashboard

  1. Go to AI Workers → Create New Worker
  2. Choose a base model (e.g., GPT-4, Claude, MedGemma, or ByteEngine Medical)
  3. Define a name and description (e.g., "CardioAgent — analyzes ECG data and flags arrhythmias")
  4. Select permissions (which FHIR servers, tools, and data it can access)
  5. Save and deploy

Once deployed, your worker gets an API endpoint and can be triggered by sessions, tasks, or workflows.

Visual Placeholder: [Screenshot: "Create Worker" UI showing model selection, permissions, and configuration fields]

Using the API

curl -X POST https://api.engine.boolbyte.com/api/workers \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name": "CardioAgent",
"description": "Analyzes ECG readings and generates diagnostic summaries.",
"defaultModelName": "medgemma-27b",
"instructions": "You are a cardiology AI assistant specialized in ECG analysis and arrhythmia detection.",
"toolConfigs": {
"tools": [
{
"toolName": "fhir_access",
"config": {
"serverId": "my-fhir-dev"
}
}
]
}
}'

Response:

{
"success": true,
"data": {
"id": "worker_2309da",
"name": "CardioAgent",
"description": "Analyzes ECG readings and generates diagnostic summaries.",
"defaultModelName": "medgemma-27b",
"instructions": "You are a cardiology AI assistant specialized in ECG analysis and arrhythmia detection.",
"toolConfigs": {
"tools": [
{
"toolName": "fhir_access",
"config": {
"serverId": "my-fhir-dev"
}
}
]
},
"teamId": "team-123",
"createdAt": "2024-01-15T10:00:00.000Z",
"updatedAt": "2024-01-15T10:00:00.000Z"
}
}

Using JavaScript SDK

import { EngineClient } from '@boolbyte/engine';

const client = new EngineClient({ apiKey: 'YOUR_API_KEY' });

// Create an AI Worker
const worker = await client.worker.createWorker({
name: 'CardioAgent',
description: 'Analyzes ECG readings and generates diagnostic summaries.',
defaultModelName: 'medgemma-27b',
instructions: 'You are a cardiology AI assistant specialized in ECG analysis and arrhythmia detection.',
toolConfigs: {
tools: [
{
toolName: 'fhir_access',
config: {
serverId: 'my-fhir-dev'
}
}
]
}
});

console.log('AI Worker created:', worker.data.id);

Creating a Session

Sessions give your worker memory — they store conversation history, context, and active tasks.

Think of sessions like patient files: each holds messages, notes, and actions related to a single context.

curl -X POST https://api.engine.boolbyte.com/api/sessions \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"workerId": "worker_2309da",
"metadata": {
"context": "ECG report analysis for patient_123"
}
}'

Response:

{
"success": true,
"data": {
"id": "session_3211",
"workerId": "worker_2309da",
"metadata": {
"context": "ECG report analysis for patient_123"
},
"messages": [],
"createdAt": "2024-01-15T09:00:00.000Z",
"updatedAt": "2024-01-15T09:00:00.000Z"
}
}

Adding Messages to a Session

Workers reason over messages. Each message can come from a user, system, or tool.

curl -X POST https://api.engine.boolbyte.com/api/sessions/session_3211/messages \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"role": "user",
"content": "Analyze ECG data for abnormalities."
}'

Running a Task

Tasks are what make workers do something. When you run a task, the worker processes your request using its context, tools, and model.

curl -X POST https://api.engine.boolbyte.com/api/sessions/session_3211/tasks \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"instructions": "Analyze ECG data for patient_123 and create a summary report.",
"model": "medgemma-27b",
"temperature": 0.7
}'

Response:

{
"success": true,
"data": {
"id": "task_444",
"sessionId": "session_3211",
"status": "completed",
"instructions": "Analyze ECG data for patient_123 and create a summary report.",
"model": "medgemma-27b",
"completedAt": "2024-01-15T09:05:00.000Z",
"metadata": [
{
"analysis": "ECG shows normal sinus rhythm with no significant abnormalities detected."
}
],
"createdAt": "2024-01-15T09:00:00.000Z",
"updatedAt": "2024-01-15T09:05:00.000Z"
}
}

You can then poll for results:

GET https://api.engine.boolbyte.com/api/sessions/session_3211/tasks/task_444

Tool Calling

AI Workers use tools to extend their abilities. Tools can be:

  • Built-in (FHIR, file storage, search, knowledge base)
  • Custom (your own APIs, databases, or scripts)
  • External (OpenAI MCP, Hugging Face Hub, or cloud endpoints)

Example — FHIR Tool Usage

When a worker calls the FHIR tool, it can query or update patient data.

{
"toolCall": {
"tool": "fhir_access",
"action": "GET",
"resource": "Patient",
"params": { "name": "John Doe" }
}
}

AI Worker Output:

{
"summary": "Patient John Doe has hypertension. Latest systolic BP: 145 mmHg.",
"recommendation": "Monitor daily and schedule follow-up."
}

A worker can query your uploaded PDFs, research papers, or internal medical documentation via vector search.

{
"toolCall": {
"tool": "knowledge_base",
"action": "search",
"query": "What are standard blood glucose levels for adults?"
}
}

Chaining Workers Together

You can combine multiple AI Workers into a workflow chain — where one worker's output becomes another's input.

Example:

LabWorker → DiagnosisWorker → ReportWorker

# workflow.yaml
name: "Diabetes Detection Workflow"
steps:
- worker: "LabWorker"
input: "@fhir:Observation"
- worker: "DiagnosisWorker"
input: "@LabWorker.output"
- worker: "ReportWorker"
input: "@DiagnosisWorker.output"
output: "@fhir:DiagnosticReport"

This allows complex reasoning pipelines — like full AI-assisted clinical documentation — without manual coordination.

Real-World Use Cases

Use CaseDescription
Clinical SummarizationA worker reads FHIR data and generates visit summaries or discharge notes.
AI DiagnosticsAI workers analyze lab results or imaging data and generate structured reports.
Patient InteractionChatbots powered by AI Workers provide symptom checking or patient education.
Medical Research AssistantsWorkers search through large knowledge bases for literature reviews or insights.
Automation BotsAutomatically detect FHIR events (e.g., new patient created) and trigger actions or alerts.

Security & Compliance in AI Workers

AI Workers inherit ByteEngine's security framework:

  • Sandbox execution
  • Scoped access (RBAC)
  • Data encryption
  • Auditable reasoning logs
  • Configurable data residency for context storage

No PHI leaves the region of origin without explicit consent or pseudonymization.

Monitoring and Logs

You can monitor each worker's performance and data interactions in the dashboard.

UI Placeholder: [Screenshot: Worker Insights UI showing request count, average latency, FHIR interactions, and audit logs]

Summary

FeatureDescription
Autonomous AgentsWorkers that reason, act, and interact with FHIR data
Context MemorySessions retain conversation and workflow history
Secure Tool UseBuilt-in FHIR, file, and search tools
WorkflowsCombine multiple workers into intelligent pipelines
ComplianceFull HIPAA/GDPR coverage

Next Steps

Next Section → Sessions & Tasks — Context and State Management

Learn how ByteEngine Sessions and Tasks help you manage conversational context, chain reasoning, and track long-running AI operations.