HKUDS/Vibe-Trading · error · ValueError
at least one goal criterion is required
Error message
at least one goal criterion is required
What it means
replace_goal requires at least one non-blank criterion: it strips each item, drops empties, and raises ValueError('at least one goal criterion is required') if nothing survives. Criteria define how the research goal is judged, so an empty list makes the goal unauditable.
Source
Thrown at agent/src/goal/store.py:302
risk_tier: Risk classification.
token_budget: Optional token budget.
turn_budget: Optional turn budget.
time_budget_seconds: Optional wall-clock budget.
Returns:
The newly active goal.
Raises:
ValueError: If objective or criteria are empty.
"""
session_id = normalize_required_text(session_id, "session_id")
objective = normalize_required_text(objective, "goal objective")
reject_live_execution_objective(objective)
if risk_tier is RiskTier.LIVE_TRADING_OR_EXECUTION:
raise ValueError("live trading or execution goals are not supported")
cleaned_criteria = [item.strip() for item in criteria if item.strip()]
if not cleaned_criteria:
raise ValueError("at least one goal criterion is required")
for criterion in cleaned_criteria:
reject_live_execution_objective(criterion)
budgets = {
"token_budget": token_budget,
"turn_budget": turn_budget,
"time_budget_seconds": time_budget_seconds,
}
for name, value in budgets.items():
if value is not None and value <= 0:
raise ValueError(f"{name} must be positive")
now = _now_iso()
goal_id = _id("goal")
summary = ui_summary.strip() or objective[:80]
current_values = [status.value for status in _CURRENT_STATUSES]
placeholders = ",".join("?" for _ in current_values)
with self._write_transaction():View on GitHub (pinned to 80ffdda44c)
Solutions
- Pass at least one meaningful criterion, e.g. ['Backtest Sharpe ratio > 1 over 2020-2025']
- Validate in the caller: if not [c for c in criteria if c.strip()], prompt the user instead of calling the store
- Whitespace-only entries are silently dropped — make sure your criteria aren't all blanks
- When generating goals from templates, inject a sensible default criterion
Example fix
# before store.replace_goal(session_id="s1", objective=obj, criteria=[]) # after store.replace_goal(session_id="s1", objective=obj, criteria=["Deliver a written research summary with supporting backtest"])
Defensive patterns
Strategy: validation
Validate before calling
cleaned = [c.strip() for c in criteria if c and c.strip()]
if not cleaned:
raise ValueError('please provide at least one success criterion')
store.replace_goal(session_id=sid, objective=obj, criteria=cleaned) Type guard
def has_valid_criteria(criteria: list[str]) -> bool:
return isinstance(criteria, list) and any(isinstance(c, str) and c.strip() for c in criteria) Try / catch
try:
store.replace_goal(session_id=sid, objective=obj, criteria=cs)
except ValueError as e:
if 'at least one goal criterion' in str(e):
cs = cs or ['Deliver a research summary with backtest evidence']
store.replace_goal(session_id=sid, objective=obj, criteria=cs)
else:
raise Prevention
- Make criteria a required field in forms, not optional
- Strip-and-filter blanks before the call; if the list empties, prompt the user
- Provide a sensible default criterion in programmatic goal creation
When it happens
Trigger: Calling replace_goal/update_goal with criteria=[], criteria=[' '], or a list whose entries are all whitespace — e.g. a UI optional field submitted as empty strings, or a caller filtering out items before passing them.
Common situations: Forms where criteria are optional but the API requires >= 1; list comprehensions that strip-and-drop blanks upstream leaving an empty list; programmatic goal creation with placeholder criteria; tests with empty fixtures.
Related errors
- {field_name} cannot be empty
- missing audit row for criterion {criterion.criterion_id}
- invalid alpha_id
- alpha_id not found
- invalid period: {exc}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/8884976ebabbb59f.
Report an issue: GitHub.