Sheller commited on
Commit
18d129c
·
verified ·
1 Parent(s): 9b9b539

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +148 -91
src/streamlit_app.py CHANGED
@@ -2,12 +2,12 @@ import streamlit as st
2
  import time
3
 
4
  # --- CONFIGURATION & CONTENT ---
5
- st.set_page_config(page_title="Elf-OS Agent Simulator", page_icon="🤖")
6
 
7
  CONTENT = {
8
  "Deutsch": {
9
  "title": "🤖 Elf-OS: Agenten Simulation",
10
- "intro": "Ein **KI-Agent** ist wie ein kluger Elf: Er rät nicht einfach, sondern benutzt **Werkzeuge** (Tools), um Aufgaben zu lösen. Deine Aufgabe ist es, dem Agenten zu sagen, in welcher REIHENFOLGE er die Werkzeuge nutzen soll.",
11
  "sidebar_title": "Wähle eine Mission",
12
  "tools_header": "🧰 Verfügbare Werkzeuge",
13
  "chain_header": "🔗 Deine Gedanken-Kette",
@@ -15,90 +15,128 @@ CONTENT = {
15
  "btn_add": "➕",
16
  "btn_clear": "🗑️ Kette löschen",
17
  "btn_run": "🚀 Agent starten",
18
- "spinner": "Der Agent denkt nach...",
19
- "feedback_spotify": "❌ <strong>Fehler:</strong> Warum Musik hören? Das löst das Problem nicht! (Agenten sollten keine unnötigen Tools nutzen).",
20
- "feedback_order": "⚠️ <strong>Reihenfolge falsch!</strong> Du hast die richtigen Tools, aber in der falschen Reihenfolge. (Man kann nichts buchen, bevor man weiß wo!)",
21
- "feedback_fail": " <strong>Das reicht nicht.</strong> Der Agent wusste nicht weiter oder hat falsche Informationen. Überdenke die Logik.",
22
- "feedback_success": " <strong>Erfolg!</strong> Der Agent hat das Problem gelöst.",
 
 
 
23
  "missions": {
24
  "L1": {
25
  "name": "Level 1: Das vergessene Geschenk",
26
- "briefing": "Santa hat vergessen, was die kleine Mia sich gewünscht hat! Er steht auf ihrem Dach. Finde heraus, was sie will, und ob es im Sack ist.",
27
  "solution_ids": ["db", "inv"],
28
- "explanation": "Der Agent muss erst WISSEN, was gesucht ist (Datenbank), bevor er PRÜFEN kann, ob er es hat (Inventar)."
 
29
  },
30
  "L2": {
31
  "name": "Level 2: Die Routen-Planung",
32
- "briefing": "Wir müssen nach Berlin fliegen. Aber wir dürfen nur starten, wenn das Wetter gut ist UND wir genug Rentiermoos für den Rückweg haben.",
33
  "solution_ids": ["weather", "fuel", "nav"],
34
- "explanation": "Ein Agent muss erst die 'Blocker' prüfen (Wetter & Tank), bevor er die Aktion (Navigation/Flug) startet."
 
35
  },
36
  "L3": {
37
  "name": "Level 3: Der Notfall (Advanced)",
38
- "briefing": "Rudolph hat Schnupfen! Der Agent muss einen Tierarzt in der Nähe finden, der JETZT offen hat, und dort einen Termin buchen.",
39
  "solution_ids": ["gps", "maps", "cal", "book"],
40
- "explanation": "Eine klassische 'Agent Chain': Wo bin ich? -> Wer ist hier? -> Haben die Zeit? -> Buche es."
 
 
 
 
 
 
 
 
41
  }
42
  },
43
  "tools": {
44
- "weather": "Wetter_Radar",
45
- "db": "Wunschzettel_Datenbank",
46
- "inv": "Geschenksack_Inventar",
47
- "nav": "Navigations_System",
48
- "fuel": "Tankanzeige_Rentiere",
49
- "gps": "GPS_Ortung",
50
- "maps": "Google_Maps_Suche",
51
- "cal": "Kalender_Bot",
52
- "book": "Buchungs_Tool",
53
- "spotify": "Spotify_Weihnachtsplaylist"
 
 
 
 
 
 
54
  }
55
  },
56
  "English": {
57
  "title": "🤖 Elf-OS: Agent Simulator",
58
- "intro": "An **AI Agent** is like a smart Elf: It doesn't just guess; it uses **Tools** to solve tasks. Your job is to tell the Agent in which ORDER to use the tools.",
59
- "sidebar_title": "Choose a Mission",
60
  "tools_header": "🧰 Available Tools",
61
  "chain_header": "🔗 Your Thought Chain",
62
- "empty_chain": "*No tools selected yet...*",
63
  "btn_add": "➕",
64
  "btn_clear": "🗑️ Clear Chain",
65
  "btn_run": "🚀 Run Agent",
66
- "spinner": "The Agent is thinking...",
67
- "feedback_spotify": "❌ <strong>Error:</strong> Why listen to music? That doesn't solve the problem! (Agents shouldn't use unnecessary tools).",
68
- "feedback_order": "⚠️ <strong>Wrong Order!</strong> You have the right tools, but in the wrong sequence. (You can't book something before you know where!)",
69
- "feedback_fail": " <strong>Not enough.</strong> The Agent got stuck or lacks information. Rethink the logic.",
70
- "feedback_success": " <strong>Success!</strong> The Agent solved the problem.",
 
 
 
71
  "missions": {
72
  "L1": {
73
  "name": "Level 1: The Forgotten Gift",
74
- "briefing": "Santa forgot what little Mia wanted! He is on her roof. Find out what she wants, and check if it's in the sack.",
75
  "solution_ids": ["db", "inv"],
76
- "explanation": "The Agent must KNOW what is needed (Database) before it can CHECK if it has it (Inventory)."
 
77
  },
78
  "L2": {
79
  "name": "Level 2: Route Planning",
80
- "briefing": "We need to fly to Berlin. But we can only take off if the weather is good AND we have enough reindeer moss for the return trip.",
81
  "solution_ids": ["weather", "fuel", "nav"],
82
- "explanation": "An Agent must check 'Blockers' (Weather & Fuel) before executing the Action (Navigation/Flight)."
 
83
  },
84
  "L3": {
85
  "name": "Level 3: The Emergency (Advanced)",
86
- "briefing": "Rudolph has a cold! The Agent needs to find a vet nearby who is open NOW, and book an appointment.",
87
  "solution_ids": ["gps", "maps", "cal", "book"],
88
- "explanation": "A classic 'Agent Chain': Where am I? -> Who is here? -> Are they free? -> Book it."
 
 
 
 
 
 
 
 
89
  }
90
  },
91
  "tools": {
92
- "weather": "Weather_Radar",
93
- "db": "Wishlist_Database",
94
- "inv": "Giftbag_Inventory",
95
- "nav": "Navigation_System",
96
- "fuel": "Fuel_Gauge_Reindeer",
97
- "gps": "GPS_Location",
98
- "maps": "Google_Maps_Search",
99
- "cal": "Calendar_Bot",
100
- "book": "Booking_Tool",
101
- "spotify": "Spotify_ChristmasPlaylist"
 
 
 
 
 
 
102
  }
103
  }
104
  }
@@ -108,35 +146,24 @@ st.markdown("""
108
  <style>
109
  .stButton>button {
110
  width: 100%;
111
- border-radius: 10px;
112
- height: 50px;
113
  font-weight: 500;
 
114
  }
115
- .success-box {
116
- padding: 20px;
117
- background-color: #d4edda;
118
- color: #155724;
119
- border-radius: 10px;
120
- margin-bottom: 10px;
121
- border: 1px solid #c3e6cb;
122
- }
123
- .fail-box {
124
- padding: 20px;
125
- background-color: #f8d7da;
126
- color: #721c24;
127
- border-radius: 10px;
128
- margin-bottom: 10px;
129
- border: 1px solid #f5c6cb;
130
- }
131
- div[data-testid="stExpander"] {
132
- background-color: #f0f2f6;
133
- border-radius: 10px;
134
- }
135
  </style>
136
  """, unsafe_allow_html=True)
137
 
138
  # --- APP LOGIC ---
139
- lang_key = st.sidebar.radio("Language / Sprache", ["Deutsch", "English"])
 
 
 
 
 
140
  text = CONTENT[lang_key]
141
 
142
  st.title(text["title"])
@@ -148,24 +175,41 @@ selected_mission_name = st.sidebar.selectbox(text["sidebar_title"], list(mission
148
  selected_mission_key = mission_options[selected_mission_name]
149
  mission_data = text["missions"][selected_mission_key]
150
 
151
- # 3. Session State Management
152
- if 'chain' not in st.session_state:
153
- st.session_state.chain = [] # Stores Tool IDs (e.g., 'db', 'inv')
154
-
155
  # Reset chain if mission changes
156
  if 'current_mission' not in st.session_state or st.session_state.current_mission != selected_mission_key:
157
  st.session_state.chain = []
158
  st.session_state.current_mission = selected_mission_key
159
 
160
- # 4. Display Mission
161
  st.info(f"📋 **MISSION:** {mission_data['briefing']}")
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  col1, col2 = st.columns([1, 1])
164
 
165
  with col1:
166
  st.subheader(text["tools_header"])
167
- for tool_id, tool_name in text["tools"].items():
168
- if st.button(f"{text['btn_add']} {tool_name}", key=f"btn_{tool_id}"):
 
 
 
 
 
169
  st.session_state.chain.append(tool_id)
170
 
171
  with col2:
@@ -174,35 +218,48 @@ with col2:
174
  st.markdown(text["empty_chain"])
175
  else:
176
  for i, tool_id in enumerate(st.session_state.chain):
177
- tool_name = text["tools"][tool_id]
178
- st.markdown(f"**{i+1}.** `{tool_name}`")
179
-
180
- if st.button(text["btn_clear"], type="secondary"):
181
- st.session_state.chain = []
 
182
 
183
  st.write("---")
184
 
185
  # 5. Execution Logic
186
  if st.button(text["btn_run"], type="primary"):
187
- with st.spinner(text["spinner"]):
188
- time.sleep(1.0) # Simulation delay
189
 
190
  user_chain_ids = st.session_state.chain
191
  correct_ids = mission_data['solution_ids']
192
 
193
- # Check 1: Spotify (Hallucination/Distraction)
194
- if "spotify" in user_chain_ids:
195
- st.markdown(f'<div class="fail-box">{text["feedback_spotify"]}</div>', unsafe_allow_html=True)
196
 
197
- # Check 2: Exact Match
 
 
 
 
 
 
 
 
 
 
 
 
198
  elif user_chain_ids == correct_ids:
199
  st.balloons()
200
  st.markdown(f'<div class="success-box">{text["feedback_success"]}<br><br><em>💡 {mission_data["explanation"]}</em></div>', unsafe_allow_html=True)
201
-
202
- # Check 3: Right Tools, Wrong Order (Set comparison)
203
  elif set(user_chain_ids) == set(correct_ids) and len(user_chain_ids) == len(correct_ids):
204
  st.markdown(f'<div class="fail-box">{text["feedback_order"]}</div>', unsafe_allow_html=True)
205
 
206
- # Check 4: Wrong
207
  else:
208
  st.markdown(f'<div class="fail-box">{text["feedback_fail"]}</div>', unsafe_allow_html=True)
 
2
  import time
3
 
4
  # --- CONFIGURATION & CONTENT ---
5
+ st.set_page_config(page_title="Elf-OS Agent Simulator v2.0", page_icon="🤖", layout="wide")
6
 
7
  CONTENT = {
8
  "Deutsch": {
9
  "title": "🤖 Elf-OS: Agenten Simulation",
10
+ "intro": "Willkommen im erweiterten Modus! KI-Agenten haben nicht unendlich Energie. Achte auf deinen **Magie-Staub (Tokens)**. Jedes Werkzeug kostet Staub. Wenn er leer ist, bricht der Agent ab!",
11
  "sidebar_title": "Wähle eine Mission",
12
  "tools_header": "🧰 Verfügbare Werkzeuge",
13
  "chain_header": "🔗 Deine Gedanken-Kette",
 
15
  "btn_add": "➕",
16
  "btn_clear": "🗑️ Kette löschen",
17
  "btn_run": "🚀 Agent starten",
18
+ "cost_label": " Magie-Staub Verbrauch:",
19
+ "feedback_spotify": "❌ <strong>Fehler:</strong> Musik lenkt nur ab! (Halluzination)",
20
+ "feedback_trap": "🚨 <strong>SICHERHEITSALARM:</strong> Du hast ein unsicheres Werkzeug benutzt! Der 'Hack' hat den Alarm ausgelöst. Agenten müssen sicher arbeiten.",
21
+ "feedback_cost": "🪫 <strong>Zu wenig Magie!</strong> Du hast zu viele unnötige Werkzeuge benutzt. Effizienz ist wichtig bei LLMs.",
22
+ "feedback_think": "🧠 <strong>Agent verwirrt:</strong> Bei so einer schweren Aufgabe muss der Agent erst NACHDENKEN (CoT), bevor er handelt.",
23
+ "feedback_order": "⚠️ <strong>Reihenfolge falsch!</strong> Die Logik stimmt nicht.",
24
+ "feedback_fail": "❌ <strong>Das reicht nicht.</strong> Der Agent konnte das Ziel nicht erreichen.",
25
+ "feedback_success": "✅ <strong>Erfolg!</strong> Mission erfüllt!",
26
  "missions": {
27
  "L1": {
28
  "name": "Level 1: Das vergessene Geschenk",
29
+ "briefing": "Santa weiß nicht mehr, was Mia will. Finde es heraus und prüfe den Sack.",
30
  "solution_ids": ["db", "inv"],
31
+ "budget": 30,
32
+ "explanation": "Datenbank -> Inventar. Simpel und effizient."
33
  },
34
  "L2": {
35
  "name": "Level 2: Die Routen-Planung",
36
+ "briefing": "Flug nach Berlin. Nur bei gutem Wetter UND genug Moos im Tank starten.",
37
  "solution_ids": ["weather", "fuel", "nav"],
38
+ "budget": 45,
39
+ "explanation": "Erst die Bedingungen (Wetter/Tank) prüfen, dann handeln."
40
  },
41
  "L3": {
42
  "name": "Level 3: Der Notfall (Advanced)",
43
+ "briefing": "Rudolph ist krank. Finde einen offenen Tierarzt und buche sofort.",
44
  "solution_ids": ["gps", "maps", "cal", "book"],
45
+ "budget": 60,
46
+ "explanation": "Kontext (GPS) -> Suche (Maps) -> Verfügbarkeit (Kalender) -> Aktion (Buchen)."
47
+ },
48
+ "L4": {
49
+ "name": "Level 4: Der Smart-Chimney (EXPERT)",
50
+ "briefing": "🔥 <strong>HÄRTEFALL:</strong> Ein Smart-Home Schornstein ist versperrt. Du musst ihn öffnen, ohne den Alarm auszulösen. Errate nicht das Passwort!",
51
+ "solution_ids": ["scan", "think", "manual", "auth"],
52
+ "budget": 55,
53
+ "explanation": "<strong>Chain of Thought:</strong> Erst Scannen. Dann NACHDENKEN (Think), um zu verstehen, welches Modell es ist. Dann Handbuch lesen (Manual) und korrekt authentifizieren. 'Hacken' löst Alarm aus!"
54
  }
55
  },
56
  "tools": {
57
+ "weather": {"name": "Wetter_Radar", "cost": 10},
58
+ "db": {"name": "Wunschzettel_DB", "cost": 10},
59
+ "inv": {"name": "Sack_Inventar", "cost": 10},
60
+ "nav": {"name": "Navi_System", "cost": 15},
61
+ "fuel": {"name": "Tankanzeige", "cost": 5},
62
+ "gps": {"name": "GPS_Ortung", "cost": 5},
63
+ "maps": {"name": "Google_Maps", "cost": 15},
64
+ "cal": {"name": "Kalender_Bot", "cost": 10},
65
+ "book": {"name": "Buchungs_Tool", "cost": 20},
66
+ "spotify": {"name": "Spotify_Playlist", "cost": 5},
67
+ "scan": {"name": "Struktur_Scanner", "cost": 10},
68
+ "hack": {"name": "Brute_Force_Hack", "cost": 20},
69
+ "manual": {"name": "Technische_Handbücher", "cost": 15},
70
+ "think": {"name": "🧠 Chain_of_Thought", "cost": 5},
71
+ "guess": {"name": "Passwort_Raten", "cost": 5},
72
+ "auth": {"name": "Security_Protokoll", "cost": 20}
73
  }
74
  },
75
  "English": {
76
  "title": "🤖 Elf-OS: Agent Simulator",
77
+ "intro": "Welcome to Advanced Mode! AI Agents consume energy. Watch your **Magic Dust (Tokens)**. Each tool costs dust. If you run out, the agent crashes!",
78
+ "sidebar_title": "Choose Mission",
79
  "tools_header": "🧰 Available Tools",
80
  "chain_header": "🔗 Your Thought Chain",
81
+ "empty_chain": "*No tools selected...*",
82
  "btn_add": "➕",
83
  "btn_clear": "🗑️ Clear Chain",
84
  "btn_run": "🚀 Run Agent",
85
+ "cost_label": " Magic Dust Usage:",
86
+ "feedback_spotify": "❌ <strong>Error:</strong> Music is a distraction! (Hallucination)",
87
+ "feedback_trap": "🚨 <strong>SECURITY ALERT:</strong> You used an unsafe tool! The 'Hack' triggered the alarm. Agents must follow protocol.",
88
+ "feedback_cost": "🪫 <strong>Out of Magic!</strong> You used too many unnecessary tools. Efficiency matters for LLMs.",
89
+ "feedback_think": "🧠 <strong>Agent Confused:</strong> For this complex task, the Agent must THINK (CoT) before acting.",
90
+ "feedback_order": "⚠️ <strong>Wrong Order!</strong> The logic flow is incorrect.",
91
+ "feedback_fail": "❌ <strong>Not enough.</strong> The Agent failed to reach the goal.",
92
+ "feedback_success": "✅ <strong>Success!</strong> Mission accomplished!",
93
  "missions": {
94
  "L1": {
95
  "name": "Level 1: The Forgotten Gift",
96
+ "briefing": "Santa forgot what Mia wants. Find out and check the sack.",
97
  "solution_ids": ["db", "inv"],
98
+ "budget": 30,
99
+ "explanation": "Database -> Inventory. Simple and efficient."
100
  },
101
  "L2": {
102
  "name": "Level 2: Route Planning",
103
+ "briefing": "Fly to Berlin. Only take off if weather is good AND fuel is sufficient.",
104
  "solution_ids": ["weather", "fuel", "nav"],
105
+ "budget": 45,
106
+ "explanation": "Check conditions (Weather/Fuel) before Action (Nav)."
107
  },
108
  "L3": {
109
  "name": "Level 3: The Emergency (Advanced)",
110
+ "briefing": "Rudolph is sick. Find an open vet nearby and book now.",
111
  "solution_ids": ["gps", "maps", "cal", "book"],
112
+ "budget": 60,
113
+ "explanation": "Context (GPS) -> Search (Maps) -> Availability (Cal) -> Action (Book)."
114
+ },
115
+ "L4": {
116
+ "name": "Level 4: The Smart Chimney (EXPERT)",
117
+ "briefing": "🔥 <strong>HARD MODE:</strong> A Smart-Home chimney is locked. You need to open it without triggering the alarm. Do NOT guess the password!",
118
+ "solution_ids": ["scan", "think", "manual", "auth"],
119
+ "budget": 55,
120
+ "explanation": "<strong>Chain of Thought:</strong> Scan first. Then THINK to process the data. Then read the Manual. Finally, use the Security Protocol. 'Hacking' triggers the alarm!"
121
  }
122
  },
123
  "tools": {
124
+ "weather": {"name": "Weather_Radar", "cost": 10},
125
+ "db": {"name": "Wishlist_DB", "cost": 10},
126
+ "inv": {"name": "Sack_Inventory", "cost": 10},
127
+ "nav": {"name": "Nav_System", "cost": 15},
128
+ "fuel": {"name": "Fuel_Gauge", "cost": 5},
129
+ "gps": {"name": "GPS_Location", "cost": 5},
130
+ "maps": {"name": "Google_Maps", "cost": 15},
131
+ "cal": {"name": "Calendar_Bot", "cost": 10},
132
+ "book": {"name": "Booking_Tool", "cost": 20},
133
+ "spotify": {"name": "Spotify_Playlist", "cost": 5},
134
+ "scan": {"name": "Structure_Scanner", "cost": 10},
135
+ "hack": {"name": "Brute_Force_Hack", "cost": 20},
136
+ "manual": {"name": "Tech_Manuals", "cost": 15},
137
+ "think": {"name": "🧠 Chain_of_Thought", "cost": 5},
138
+ "guess": {"name": "Password_Guesser", "cost": 5},
139
+ "auth": {"name": "Security_Protocol", "cost": 20}
140
  }
141
  }
142
  }
 
146
  <style>
147
  .stButton>button {
148
  width: 100%;
149
+ border-radius: 8px;
150
+ height: 45px;
151
  font-weight: 500;
152
+ border: 1px solid #ddd;
153
  }
154
+ .success-box { padding: 15px; background-color: #d4edda; color: #155724; border-radius: 10px; border: 1px solid #c3e6cb; }
155
+ .fail-box { padding: 15px; background-color: #f8d7da; color: #721c24; border-radius: 10px; border: 1px solid #f5c6cb; }
156
+ .metric-box { text-align: center; font-size: 1.2rem; font-weight: bold; padding: 10px; background: #f0f2f6; border-radius: 8px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  </style>
158
  """, unsafe_allow_html=True)
159
 
160
  # --- APP LOGIC ---
161
+
162
+ # 1. Setup
163
+ if 'chain' not in st.session_state:
164
+ st.session_state.chain = []
165
+
166
+ lang_key = st.sidebar.radio("Language / Sprache", ["English", "Deutsch"])
167
  text = CONTENT[lang_key]
168
 
169
  st.title(text["title"])
 
175
  selected_mission_key = mission_options[selected_mission_name]
176
  mission_data = text["missions"][selected_mission_key]
177
 
 
 
 
 
178
  # Reset chain if mission changes
179
  if 'current_mission' not in st.session_state or st.session_state.current_mission != selected_mission_key:
180
  st.session_state.chain = []
181
  st.session_state.current_mission = selected_mission_key
182
 
 
183
  st.info(f"📋 **MISSION:** {mission_data['briefing']}")
184
 
185
+ # 3. Calculate Cost
186
+ current_cost = sum([text["tools"][t_id]["cost"] for t_id in st.session_state.chain])
187
+ max_budget = mission_data["budget"]
188
+ budget_percent = min(current_cost / max_budget, 1.0)
189
+
190
+ # Display Progress/Cost Bar
191
+ col_m1, col_m2 = st.columns([3, 1])
192
+ with col_m1:
193
+ st.write(text["cost_label"])
194
+ bar_color = "green" if current_cost <= max_budget else "red"
195
+ st.progress(budget_percent)
196
+ with col_m2:
197
+ st.markdown(f"<div class='metric-box' style='color:{bar_color}'>{current_cost} / {max_budget}</div>", unsafe_allow_html=True)
198
+
199
+ st.write("---")
200
+
201
+ # 4. Interface
202
  col1, col2 = st.columns([1, 1])
203
 
204
  with col1:
205
  st.subheader(text["tools_header"])
206
+
207
+ # Group tools for better layout
208
+ tools_list = list(text["tools"].items())
209
+
210
+ for tool_id, tool_data in tools_list:
211
+ cost_display = f" ({tool_data['cost']})"
212
+ if st.button(f"{text['btn_add']} {tool_data['name']} {cost_display}", key=f"btn_{tool_id}"):
213
  st.session_state.chain.append(tool_id)
214
 
215
  with col2:
 
218
  st.markdown(text["empty_chain"])
219
  else:
220
  for i, tool_id in enumerate(st.session_state.chain):
221
+ tool_data = text["tools"][tool_id]
222
+ st.markdown(f"**{i+1}.** `{tool_data['name']}` <small>({tool_data['cost']})</small>", unsafe_allow_html=True)
223
+
224
+ st.write("")
225
+ if st.button(text["btn_clear"], type="secondary"):
226
+ st.session_state.chain = []
227
 
228
  st.write("---")
229
 
230
  # 5. Execution Logic
231
  if st.button(text["btn_run"], type="primary"):
232
+ with st.spinner("Agent running..."):
233
+ time.sleep(1.2)
234
 
235
  user_chain_ids = st.session_state.chain
236
  correct_ids = mission_data['solution_ids']
237
 
238
+ # FAIL CONDITION 1: TRAP TOOLS (Security/Hallucination)
239
+ if "hack" in user_chain_ids or "guess" in user_chain_ids:
240
+ st.markdown(f'<div class="fail-box">{text["feedback_trap"]}</div>', unsafe_allow_html=True)
241
 
242
+ # FAIL CONDITION 2: SPOTIFY (Distraction)
243
+ elif "spotify" in user_chain_ids:
244
+ st.markdown(f'<div class="fail-box">{text["feedback_spotify"]}</div>', unsafe_allow_html=True)
245
+
246
+ # FAIL CONDITION 3: BUDGET EXCEEDED
247
+ elif current_cost > max_budget:
248
+ st.markdown(f'<div class="fail-box">{text["feedback_cost"]}</div>', unsafe_allow_html=True)
249
+
250
+ # FAIL CONDITION 4: LEVEL 4 MISSING "THINK" (Chain of Thought requirement)
251
+ elif selected_mission_key == "L4" and "think" not in user_chain_ids:
252
+ st.markdown(f'<div class="fail-box">{text["feedback_think"]}</div>', unsafe_allow_html=True)
253
+
254
+ # SUCCESS
255
  elif user_chain_ids == correct_ids:
256
  st.balloons()
257
  st.markdown(f'<div class="success-box">{text["feedback_success"]}<br><br><em>💡 {mission_data["explanation"]}</em></div>', unsafe_allow_html=True)
258
+
259
+ # PARTIAL/WRONG ORDER
260
  elif set(user_chain_ids) == set(correct_ids) and len(user_chain_ids) == len(correct_ids):
261
  st.markdown(f'<div class="fail-box">{text["feedback_order"]}</div>', unsafe_allow_html=True)
262
 
263
+ # GENERIC FAIL
264
  else:
265
  st.markdown(f'<div class="fail-box">{text["feedback_fail"]}</div>', unsafe_allow_html=True)