{"record":{"id":"564025f55b4ea132","repo":"HKUDS/Vibe-Trading","slug":"no-committed-mandate-for-broker","errorCode":null,"errorMessage":"no committed mandate for {broker}","messagePattern":"no committed mandate for (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"error","filePath":"agent/src/api/live_routes.py","lineNumber":987,"sourceCode":"        if not broker:\n            raise HTTPException(status_code=400, detail=\"broker must not be blank\")\n\n        if not broker_supports_live_runner(broker):\n            raise HTTPException(\n                status_code=400,\n                detail=f\"live runner is not supported for {broker}\",\n            )\n\n        h = _host()\n        tasks = h._runner_tasks\n\n        existing = tasks.get(broker)\n        if existing is not None and not existing.done():\n            return {\"broker\": broker, \"started\": False, \"already_running\": True}\n\n        mandate = h._active_mandate_state(broker)\n        if mandate is None:\n            raise HTTPException(status_code=409, detail=f\"no committed mandate for {broker}\")\n        if mandate.expired:\n            raise HTTPException(status_code=409, detail=f\"mandate for {broker} has expired; re-authorize first\")\n        if halt_flag_set(broker=broker) or halt_flag_set(broker=None):\n            raise HTTPException(status_code=409, detail=\"kill switch is tripped; resume before starting the runner\")\n\n        try:\n            runner = h._build_live_runner(broker)\n        except LiveRunnerUnavailable as exc:\n            raise HTTPException(status_code=503, detail=str(exc)) from exc\n        except Exception as exc:\n            raise HTTPException(status_code=500, detail=f\"could not construct runner: {exc}\") from exc\n\n        task = asyncio.ensure_future(h._drive_runner(runner))\n        tasks[broker] = task\n        task.add_done_callback(\n            lambda t, b=broker: tasks.pop(b, None) if tasks.get(b) is t else None\n        )\n","sourceCodeStart":969,"sourceCodeEnd":1005,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/api/live_routes.py#L969-L1005","documentation":"Returned as HTTP 409 by the live-runner start endpoint when no committed (authorized) trading mandate exists for the broker. Starting a persistent runner requires a prior, committed mandate; the host's _active_mandate_state(broker) returning None means authorization was never completed or was cleared.","triggerScenarios":"POST to start the live runner for a broker before completing the mandate authorization/commit flow; after a mandate was revoked, cleared, or never persisted for that broker.","commonSituations":"Fresh deployment where the operator skipped the authorization step, mandate storage reset (wiped DB/state file), or a new broker added without re-running the mandate commit flow.","solutions":["Complete the mandate authorization + commit flow for the broker first, then retry the start request","Inspect mandate state via the mandate/authorization endpoints to confirm a committed mandate exists for that exact broker key","Check that mandate persistence (state store) is reachable and was not reset between authorize and start","Confirm the broker string matches the one used when the mandate was committed"],"exampleFix":"// before\nPOST /api/live/runner/start {\"broker\": \"alpaca\"}  // 409\n// after\nPOST /api/live/mandate/commit {\"broker\": \"alpaca\", ...}\nPOST /api/live/runner/start {\"broker\": \"alpaca\"}","handlingStrategy":"validation","validationCode":"mandate = get(f'/api/live/mandate/{broker}').json()\nif mandate.get('state') != 'committed':\n    commit_mandate(broker)  # run authorization/commit flow first","typeGuard":null,"tryCatchPattern":"catch 409 with 'no committed mandate'; run the mandate commit flow then retry the start request once","preventionTips":["Make mandate commit a prerequisite step in deployment runbooks before starting runners","Alert when a broker's mandate is missing or cleared"],"tags":["live-trading","authorization","mandate","http-409"],"backgroundTag":"missing-authorization-mandate","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}