ar9avg commited on
Commit
f4110fc
·
1 Parent(s): 8ae8e0b

Fix chat SSE events to match frontend protocol (result+done instead of success)

Browse files
Files changed (1) hide show
  1. backend/api/demo.py +13 -7
backend/api/demo.py CHANGED
@@ -275,21 +275,27 @@ async def execute_query_stream(req: ExecuteQueryRequest):
275
 
276
  if attempt_success:
277
  success = True
 
278
  yield {"data": json.dumps({
279
- "type": "success",
280
  "rows": rows,
281
  "row_count": len(rows),
282
- "sql": generated_sql,
 
 
 
283
  })}
284
  done = True
285
  break
286
 
287
  total_reward = compute_episode_reward(all_step_rewards, success)
288
- yield {"data": json.dumps({
289
- "type": "rl_episode_end",
290
- "total_reward": total_reward,
291
- "success": success,
292
- })}
 
 
293
 
294
  # Record GEPA history
295
  gepa = get_gepa()
 
275
 
276
  if attempt_success:
277
  success = True
278
+ # Emit events matching the frontend's expected protocol
279
  yield {"data": json.dumps({
280
+ "type": "result",
281
  "rows": rows,
282
  "row_count": len(rows),
283
+ })}
284
+ yield {"data": json.dumps({
285
+ "type": "done",
286
+ "attempts": attempt,
287
  })}
288
  done = True
289
  break
290
 
291
  total_reward = compute_episode_reward(all_step_rewards, success)
292
+
293
+ if not success:
294
+ # All attempts exhausted without success
295
+ yield {"data": json.dumps({
296
+ "type": "error",
297
+ "message": "Agent exhausted all repair attempts",
298
+ })}
299
 
300
  # Record GEPA history
301
  gepa = get_gepa()