{"record":{"id":"66598ed1155e6582","repo":"ZhuLinsen/daily_stock_analysis","slug":"capability-unsupported","errorCode":"capability_unsupported","errorMessage":"Codex Agent requires the Chat interface with progress and stop support","messagePattern":"Codex Agent requires the Chat interface with progress and stop support","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"api/v1/endpoints/agent.py","lineNumber":212,"sourceCode":"        default_strategy_id=payload.default_skill_id,\n    )\n\n@router.post(\"/chat\", response_model=ChatResponse)\nasync def agent_chat(\n    request: ChatRequest,\n    session_service: AgentChatSessionService = Depends(get_agent_chat_session_service),\n):\n    \"\"\"\n    Chat with the AI Agent without progress events.\n\n    Codex Agent callers must use ``/chat/stream``, which provides progress\n    events and request cancellation. The default LiteLLM Agent keeps this\n    endpoint's existing behavior.\n    \"\"\"\n    config = get_config()\n    backend_id = _select_agent_chat_backend(config)\n    if backend_id == \"codex_app_server\":\n        raise HTTPException(\n            status_code=400,\n            detail={\n                \"error\": \"capability_unsupported\",\n                \"message\": \"Codex Agent requires the Chat interface with progress and stop support\",\n            },\n        )\n    \n    session_id = request.session_id or str(uuid.uuid4())\n    \n    try:\n        skill_selection = session_service.resolve_skill_selection(\n            config,\n            session_id,\n            request.effective_skills,\n        )\n        skills = skill_selection.effective_skill_ids\n        selected_skill_ids = skill_selection.selected_skill_ids_update\n        executor = _build_executor(config, skills or None)","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/api/v1/endpoints/agent.py#L194-L230","documentation":"Raised during full account replay (portfolio_service.py:924) when a split_adjustment event has split_ratio <= 0 (null coerces to 0.0). The replay must rescale lot quantities and unit costs (FIFO) or average state; a non-positive ratio is uninterpretable and aborts the snapshot with validation_error.","triggerScenarios":"A corporate_actions row with split_ratio=0, negative, or NULL and action_type='split_adjustment' consumed by _replay_account while computing cost basis; sibling of the quantity-replay check at portfolio_service.py:749, hit on the snapshot path where lots and unit costs are also divided by the ratio.","commonSituations":"Backfills that zero-fill missing split ratios; manual DB corrections; legacy rows created before add_corporate_action enforced split_ratio > 0; reverse-split data entered as a fraction that a rounding step turned into 0.","solutions":["Locate the row: query corporate_actions where action_type='split_adjustment' AND (split_ratio IS NULL OR split_ratio <= 0) and fix or delete it","Use true ratios: 2.0 for a 2-for-1 split, 0.5 for a reverse 1-for-2 split","Re-insert via add_corporate_action to get write-time validation","Guard bulk imports to skip rows with missing ratios and report them instead of writing 0"],"exampleFix":"# before\nsvc.add_corporate_action(account_id=1, symbol=\"AAPL\", action_type=\"split_adjustment\", split_ratio=0, ...)\n# after\nsvc.add_corporate_action(account_id=1, symbol=\"AAPL\", action_type=\"split_adjustment\", split_ratio=4.0, ...)","handlingStrategy":"validation","validationCode":"def split_ratio_ok(ratio):\n    return ratio is not None and ratio > 0","typeGuard":"from numbers import Real\n\ndef is_valid_split_ratio(value: Real | None) -> bool:\n    return value is not None and float(value) > 0.0","tryCatchPattern":"try:\n    svc.get_snapshot(account_id=a)\nexcept ValueError as exc:\n    if \"Invalid split_ratio\" in str(exc):\n        fix_bad_split_rows(a); svc.get_snapshot(account_id=a)\n    else:\n        raise","preventionTips":["Express splits as factors > 0 (2.0 for 2-for-1, 0.5 for reverse)","Write corporate actions only through add_corporate_action","Audit corporate_actions for non-positive ratios after imports"],"tags":["portfolio","validation","split","replay","cost-basis","data-corruption"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}