HKUDS/Vibe-Trading · error · HTTPException

job {job_id} not found

Error message

job {job_id} not found

What it means

The tool's execute() only accepts five actions: status, lookup, latest, history, universe. Any other action string raises this ValueError immediately. The action also drives whether stock_ids is required (lookup/latest/history) and which handler runs.

Source

Thrown at agent/src/api/alpha_routes.py:578

        _RUNNING_TASKS.add(task)
        task.add_done_callback(_RUNNING_TASKS.discard)
        return {"status": "ok", "job_id": job_id}

    # -----------------------------------------------------------------------
    # GET /alpha/bench/{job_id}/stream
    # -----------------------------------------------------------------------

    @app.get(
        "/alpha/bench/{job_id}/stream",
        dependencies=[Depends(require_event_stream_auth)],
    )
    async def stream_bench(job_id: str, request: Request) -> StreamingResponse:
        """SSE: progress / result / done / error until the job terminates."""
        if not _JOB_ID_RE.fullmatch(job_id or ""):
            raise HTTPException(status_code=400, detail="invalid job_id")
        with _JOBS_LOCK:
            if job_id not in ALPHA_BENCH_JOBS:
                raise HTTPException(status_code=404, detail=f"job {job_id} not found")
        return _job_event_stream(ALPHA_BENCH_JOBS, job_id, request, _result_for_wire)

    # -----------------------------------------------------------------------
    # POST /alpha/compare
    # -----------------------------------------------------------------------

    @app.post(
        "/alpha/compare",
        status_code=202,
        dependencies=[Depends(require_auth)],
    )
    async def kick_off_compare(payload: CompareRequest) -> dict[str, Any]:
        """Queue a background head-to-head comparison and return a job_id."""
        from src.tools.alpha_bench_tool import _parse_period

        try:
            _parse_period(payload.period)
        except ValueError as exc:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Use one of: status, lookup, latest, history, universe exactly (lowercase)
  2. Lowercase and validate before calling: action=raw.strip().lower(); assert action in ALLOWED
  3. If you need a missing capability, extend the tool's action set and schema rather than passing new names

Example fix

# before
execute(action='SEARCH', stock_ids=['2330'])
# after
execute(action='lookup', stock_ids=['2330'])
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED_ACTIONS = {'status','lookup','latest','history','universe'}
action = str(raw_action).strip().lower()
if action not in ALLOWED_ACTIONS:
    raise ValueError(f'unknown action {action!r}; allowed: {sorted(ALLOWED_ACTIONS)}')

Type guard

from typing import Literal
Action = Literal['status','lookup','latest','history','universe']
def is_action(v) -> bool:
    return v in {'status','lookup','latest','history','universe'}

Try / catch

try:
    tool.execute(action=action, **kwargs)
except ValueError as e:
    if 'action must be' in str(e):
        action = 'status'  # safe fallback
        result = tool.execute(action='status')
    else:
        raise

Prevention

When it happens

Trigger: Calling execute(action='quote'), action='search', action='STATUS' (case-sensitive match against the literal set), or a typo like 'histroy'. The membership test is exact-string against the allowed set.

Common situations: LLM tool callers inventing action names not in the tool schema; refactoring that renamed an action without updating callers; case mismatch from uppercase enums; frontend dropdown values drifting from the backend set.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/280ac6dd6aa02e29. Report an issue: GitHub.