vaibhav12332112312 commited on
Commit
4bfe286
·
1 Parent(s): abe4587

fix(env): tolerate malformed predict_engagement scheduled_actions

Browse files

LLM occasionally emits items without required action_type, raising
ValidationError mid-episode. Skip such items, matching draft_review.

Made-with: Cursor

Files changed (1) hide show
  1. server/viraltest_environment.py +4 -1
server/viraltest_environment.py CHANGED
@@ -565,7 +565,10 @@ class ViraltestEnvironment(Environment):
565
  raw_actions = tool.arguments.get("scheduled_actions", [])
566
  predicted_total = 0.0
567
  for sa_dict in raw_actions[:5]:
568
- sa = ScheduledAction(**sa_dict) if isinstance(sa_dict, dict) else sa_dict
 
 
 
569
  if sa.action_type == "post" and sa.content_type:
570
  base = BASE_ENGAGEMENT.get(sa.content_type, 0.3)
571
  reach = REACH_MULT.get(sa.content_type, 1.0)
 
565
  raw_actions = tool.arguments.get("scheduled_actions", [])
566
  predicted_total = 0.0
567
  for sa_dict in raw_actions[:5]:
568
+ try:
569
+ sa = ScheduledAction(**sa_dict) if isinstance(sa_dict, dict) else sa_dict
570
+ except Exception:
571
+ continue
572
  if sa.action_type == "post" and sa.content_type:
573
  base = BASE_ENGAGEMENT.get(sa.content_type, 0.3)
574
  reach = REACH_MULT.get(sa.content_type, 1.0)