Automating Airline IROPS Re-accommodation with KaibanJS

Irregular operations (IROPS) are high-stakes moments for airlines and passengers. The goal of this article is to show how to structure a practical, multi-agent workflow that detects a disruption and generates viable re-accommodation options with KaibanJS, using clear roles, goals, and task outputs.
KaibanJS is a JavaScript-first framework that empowers developers to build explainable, maintainable multi-agent AI workflows. With core concepts like Agents, Tasks, and Teams, developers can embed domain-specific roles and goals directly into their code, all within familiar JavaScript environments
This post focuses on the parts of the code that deliver the most value. The complete, runnable demo is available in a public playground so you can inspect every detail and run it end to end.
Live demo: Playgorund
What we will build
- A detection step that summarizes a disruption for an affected flight and flags missed connections.
- An option generation step that ranks alternative flights while respecting loyalty, fare class, and preferences.
- A small orchestration layer that binds agents and tasks into a team so the flow is easy to run and extend.
Define agents by role and goal
KaibanJS agents are intentionally designed around domain responsibilities. This keeps code readable and makes behavior easier to reason about.
const realtimeDisruptionDetectionAgent = new Agent({
name: 'Realtime Disruption Detection Agent',
role: 'Flight Monitoring Specialist',
goal: 'Continuously monitor flight status and instantly identify when IROPS occur.',
tools: [ new FlightMonitorTool() ] // tool internals omitted here
});
const intelligentOptionGenerationAgent = new Agent({
name: 'Intelligent Option Generation Agent',
role: 'Network Optimization Specialist',
goal: 'Analyze available inventory considering preferences, loyalty, and constraints.',
tools: [ new InventorySearchTool() ] // tool internals omitted here
});
Why this matters for real cases:
- Roles and goals encode domain intent directly in code.
- Teams can mix specialists and keep boundaries clear as workflows grow.
- The agentic loop encourages incremental reasoning and validation instead of a single pass.
Specify tasks with explicit outputs
Tasks are the contract between product logic and agent behavior. Descriptions and expected outputs act as a checklist the system can satisfy and test.
const detectDisruptionTask = new Task({
title: 'Realtime Disruption Detection',
description: `Monitor flight status for flight {flightNumber} from {origin} to {destination} scheduled for {scheduledDeparture}.
Detect any disruptions and assess impact on passengers. The agent should identify IROPS before passengers become aware of issues.
Focus on connection scenarios where passengers miss their connecting flights due to delays.`,
expectedOutput:
'Detailed disruption report with affected passenger list, connection details, and estimated delay duration.',
agent: realtimeDisruptionDetectionAgent
});
const generateOptimalOptionsTask = new Task({
title: 'Intelligent Option Generation',
description: `Based on the connection disruption detected, search for optimal re-accommodation options for {affectedPassengers} passengers.
Consider factors such as:
- Available seats across the network from connection airport to final destination
- Passenger loyalty status and fare class
- Connection preferences and timing
- Operational constraints and aircraft availability
- Individual passenger preferences and special assistance needs
- Alternative routes and airports if direct flights are not available`,
expectedOutput:
'Ranked list of optimal re-accommodation alternatives with detailed flight information and seat availability.',
agent: intelligentOptionGenerationAgent
});
const reaccommodatePassengersTask = new Task({
title: 'Re-accommodate Passengers',
description: `Using the available flights and passenger preferences, apply re-accommodation logic for missed connections:
- Sort passengers by loyalty status (PLATINUM > GOLD > SILVER)
- Match fare class availability (F for First Class, Y for Economy)
- Assign seats based on preferences (WINDOW/AISLE)
- Handle special assistance requirements
- Distribute passengers optimally across available flights
- Ensure network utilization is maximized
- Consider alternative airports if necessary (e.g., FLL instead of MIA)`,
expectedOutput:
'Complete re-accommodation results for each passenger with new flight and seat assignments, including connection details.',
agent: intelligentOptionGenerationAgent
});
Tip for production-minded readers:
- Use the task description to capture business rules.
- Keep expectedOutput specific enough to be testable.
Orchestrate everything with a team
A team wires agents, tasks, and inputs in one place. You can start simple, then add communication, booking updates, or staff coordination as separate tasks without changing the earlier steps.
const team = new Team({
name: 'IROPS Re-accommodation Team',
agents: [
realtimeDisruptionDetectionAgent,
intelligentOptionGenerationAgent
// you can add communication, booking, and staff agents here
],
tasks: [
detectDisruptionTask,
generateOptimalOptionsTask,
reaccommodatePassengersTask
// then append communication, booking, and staff tasks here
],
inputs: {
flightNumber: 'AA930',
origin: 'GRU',
destination: 'MIA',
scheduledDeparture: '2024-01-15T08:00:00Z',
affectedPassengers: mockPassengers.length
},
env: {
OPENAI_API_KEY: 'YOUR_OPENAI_API_KEY'
}
});
// In your app bootstrap or a small runner:
team.start().then(result => {
console.log('Workflow completed:', result);
});
Design notes:
- Keep inputs minimal and domain focused.
- Treat each added task as a safe extension point, not a fork of the whole flow.
Why KaibanJS fits this scenario
- Clear separation of concerns. Roles and goals align with airline operations like monitoring, optimization, communication, and booking.
- Composable and testable. Tasks define concrete outputs that are easy to verify.
- JavaScript native. Teams run in Node or the browser and integrate smoothly with React or Next.
- Agentic loop that supports iteration and quality checks. You can add validation and refinement loops as tasks without rewriting the whole pipeline.
Resources
- KaibanJS examples and IROPS overview: https://www.kaibanjs.com/examples/multi-agent-airline-reaccommodation
- Open the live Playground to inspect every agent, task, and tool in context: https://www.kaibanjs.com/share/bmJMsiB12jY7CA7MEQza
- Prefer local work. Install the package, create a team, and start the flow. KaibanJS Teams and Core Concepts: https://docs.kaibanjs.com/