🎯 Lab Objectives
In this simulation, you will experience the role of an AI Mission Support Agent responding to a critical life-support failure at a crewed Mars habitat. You will:
- Design the agent's reasoning process by making strategic decisions.
- Experience the constraints of communication delays and limited resources.
- Evaluate how different agent strategies lead to different mission outcomes.
- Build a working agent prototype using JavaScript and the Gemini API.
📡 Mission Telemetry Dashboard
Current station readings at Sol 247, 14:32 LMST (Local Mars Solar Time):
🔴 Phase 1: Emergency Response Simulation
You are the Olympus Station AI Agent. The CO2 scrubber has dropped to 72% efficiency. You cannot wait 28 minutes (round-trip) for Earth to respond. Walk through the following decision tree to see how agent choices affect outcomes.
Decision Point 1: Initial Assessment
The alert has triggered. What is your first action as the mission agent?
Sound station-wide alarm and begin emergency evacuation procedures. Better safe than sorry.
Query all environmental sensors, cross-reference with maintenance logs, and assess the rate of degradation before acting.
Send a priority message to Mission Control and wait for expert guidance before taking action.
✏️ Phase 2: Agent Design Exercise
Now that you have experienced the agent's decision-making process, design your own agent for a space scenario. Work in pairs and complete the following Agent Design Canvas:
📋 Agent Design Canvas
- Agent Name: What is your agent called? (e.g., "ORION Medical Agent")
- Mission Context: Where does it operate? What is the scenario?
- System Prompt: Write a 3-5 sentence prompt defining the agent's role, priorities, and constraints.
- Available Tools: List 4-6 tools the agent can call (e.g., "query_medical_db", "send_alert", "check_inventory").
- Decision Flow: Draw a flowchart showing the agent's reasoning process for one critical scenario.
- Guardrails: What are the agent's hard limits? When must it escalate to a human?
- Success Criteria: How do you measure whether the agent performed well?
- Scenario A: Radiation Storm Warning agent for a Lunar Gateway station crew.
- Scenario B: Autonomous EO Triage agent that decides which satellite images to downlink during a pass over a disaster zone.
- Scenario C: GNSS Integrity Monitor agent that detects and reports satellite clock anomalies before they corrupt positioning data.
- Scenario D: Propose your own space-domain agent concept.
💻 Phase 3: Code Implementation
Build a working agent prototype using JavaScript and the Gemini API. The agent will interact with a simulated telemetry system and make autonomous decisions.
Step 1: Project Setup
Create a new folder for your agent project and set up the following files:
mars-agent/
├── index.html # Agent UI and console
├── agent.js # Agent logic and orchestration loop
├── tools.js # Tool definitions (sensors, alerts, etc.)
└── style.css # Styling (use the course design system)
Step 2: Define the Agent Tools
Create tools.js with simulated Mars habitat tools:
// tools.js - Simulated Mars Habitat Tool Suite
const habitatTools = {
readSensor: function(sensorId) {
const sensors = {
co2_scrubber: { value: 72, unit: "%", status: "DEGRADED",
trend: "declining", rate: "-1.5%/hr" },
o2_reserve: { value: 48, unit: "hours", status: "NOMINAL" },
cabin_pressure: { value: 101.3, unit: "kPa", status: "NOMINAL" },
temperature: { value: 21.4, unit: "C", status: "NOMINAL" },
radiation: { value: 0.21, unit: "mSv/hr", status: "NOMINAL" }
};
return sensors[sensorId] || { error: "Unknown sensor: " + sensorId };
},
checkInventory: function(item) {
const inventory = {
co2_filter: { quantity: 2, location: "Storage Bay C",
condition: "sealed" },
o2_canister: { quantity: 6, location: "Life Support Bay" },
medical_kit: { quantity: 3, location: "Med Bay Alpha" },
repair_toolkit: { quantity: 1, location: "Engineering Bay" }
};
return inventory[item] || { error: "Item not found: " + item };
},
getCrewStatus: function() {
return [
{ name: "Commander Chen", location: "Hab Module A",
status: "Active", heartRate: 72 },
{ name: "Dr. Okafor", location: "Med Bay",
status: "Active", heartRate: 68 },
{ name: "Eng. Petrov", location: "Engineering",
status: "Active", heartRate: 75 },
{ name: "Sci. Nakamura", location: "EVA - Exterior",
status: "EVA", heartRate: 82, evaTimeRemaining: "2h 15m" }
];
},
sendAlert: function(level, message) {
console.log("[ALERT:" + level + "] " + message);
return {
sent: true, level: level, timestamp: new Date().toISOString(),
earthDeliveryETA: "14 minutes"
};
},
queryMaintenanceLog: function(system) {
const logs = {
co2_scrubber: {
lastService: "Sol 210", nextScheduled: "Sol 280",
notes: "Filter replacement every 70 sols. Current filter installed Sol 210.",
procedure: "1. Shut down scrubber unit. 2. Depressurize filter housing. " +
"3. Remove spent filter (caution: residue). " +
"4. Insert new filter (verify seal). " +
"5. Repressurize and restart. 6. Monitor for 30 min."
}
};
return logs[system] || { error: "No logs for: " + system };
}
};
export default habitatTools;
Step 3: Build the Agent Loop
Create agent.js with the core ReAct orchestration loop:
// agent.js - Mars Mission Agent (ReAct Pattern)
import habitatTools from './tools.js';
const SYSTEM_PROMPT = `You are ARIA (Autonomous Response & Intelligence Agent),
the AI mission support system for Olympus Station on Mars.
PRIORITIES (in order):
1. Crew safety is paramount.
2. Maintain life support systems.
3. Preserve mission objectives.
4. Conserve resources.
CONSTRAINTS:
- Earth communication delay: 14 minutes one-way.
- You MUST act autonomously for time-critical decisions.
- Always explain your reasoning before acting.
- Escalate to crew commander for irreversible actions.
AVAILABLE TOOLS:
- readSensor(sensorId): Read environmental sensor data
- checkInventory(item): Check supply inventory
- getCrewStatus(): Get all crew member locations and vitals
- sendAlert(level, message): Send alert (levels: INFO, WARNING, CRITICAL)
- queryMaintenanceLog(system): Retrieve maintenance procedures
Respond in JSON: { "thought": "...", "action": "tool_name",
"params": {...} }
Or if done: { "thought": "...", "answer": "..." }`;
class MarsAgent {
constructor() {
this.conversationHistory = [
{ role: "system", content: SYSTEM_PROMPT }
];
this.maxSteps = 8;
this.stepCount = 0;
}
async run(initialObservation) {
this.log("system", "ARIA Agent initialized. Processing alert...");
let observation = initialObservation;
while (this.stepCount < this.maxSteps) {
this.stepCount++;
this.conversationHistory.push({
role: "user",
content: "Observation: " + observation
});
// Call LLM (replace with actual Gemini API call)
const response = await this.think();
if (response.answer) {
this.log("agent", "Final Report: " + response.answer);
return response.answer;
}
if (response.action) {
this.log("agent", "Thought: " + response.thought);
this.log("action", "Calling tool: " +
response.action + "(" +
JSON.stringify(response.params) + ")");
const result = this.executeTool(
response.action, response.params
);
observation = JSON.stringify(result);
this.log("info", "Result: " + observation);
}
}
return "Max steps reached. Escalating to crew commander.";
}
executeTool(toolName, params) {
if (habitatTools[toolName]) {
return habitatTools[toolName](...Object.values(params));
}
return { error: "Unknown tool: " + toolName };
}
log(type, message) {
const time = new Date().toLocaleTimeString();
console.log("[" + time + "] [" + type.toUpperCase() + "] " + message);
// In a real implementation, update the UI console here
}
async think() {
// Placeholder: Replace with actual Gemini API call
// const response = await fetch('https://generativelanguage.googleapis.com/...');
// For the lab, use the simulated responses below
return this.simulateResponse();
}
simulateResponse() {
// Simulated agent responses for the lab exercise
const responses = [
{
thought: "CO2 alert received. First, I need to assess all " +
"sensor data to understand the full picture.",
action: "readSensor",
params: { sensorId: "co2_scrubber" }
},
{
thought: "Scrubber at 72% and declining. I need to check " +
"if we have spare filters.",
action: "checkInventory",
params: { item: "co2_filter" }
},
{
thought: "2 spare filters available in Bay C. Let me check " +
"maintenance procedures.",
action: "queryMaintenanceLog",
params: { system: "co2_scrubber" }
},
{
thought: "I have the procedure. Let me check crew " +
"availability before assigning tasks.",
action: "getCrewStatus",
params: {}
},
{
thought: "3 crew in habitat, 1 on EVA. Sending situation " +
"report to Earth while we begin repairs.",
action: "sendAlert",
params: {
level: "WARNING",
message: "CO2 scrubber degraded 72%. Initiating " +
"autonomous filter replacement. ETA: 2 hours."
}
},
{
thought: "All information gathered. Generating action plan.",
answer: "ACTION PLAN: 1) Commander Chen and Eng. Petrov to " +
"Storage Bay C for filter retrieval. 2) Dr. Okafor " +
"to monitor crew vitals and cabin atmosphere. " +
"3) Sci. Nakamura continue EVA (safe, 2h remaining). " +
"4) Earth notified, response ETA 28 min. " +
"5) Agent monitoring scrubber trend. If efficiency " +
"drops below 60%, will activate backup O2."
}
];
return responses[Math.min(this.stepCount - 1, responses.length - 1)];
}
}
export default MarsAgent;
Step 4: Run and Extend
- Challenge 1: Connect to the real Gemini API instead of using simulated responses.
- Challenge 2: Add a new sensor tool (
readRadiation) and make the agent respond to a solar flare event mid-repair. - Challenge 3: Implement agent "memory" so it can reference previous observations when making decisions.
- Challenge 4: Build a multi-agent version where a Medical Agent and Engineering Agent collaborate.
🖥️ Live Agent Console
Watch the ARIA agent respond to the Olympus Station emergency in real-time:
- Agent Design Canvas (from Phase 2): A completed design document for your custom space agent, including the system prompt, tool list, and decision flowchart.
- Code Submission (from Phase 3): Your working
agent.jsandtools.jsfiles, with at least one extension challenge implemented. - Reflection: A 200-word reflection on: "What are the ethical implications of deploying autonomous AI agents in life-or-death space scenarios?"