Skip to content

feat(llc/budget): no public endpoint to provision a per-agent budget #9901

Description

@mrveiss

Discovered during

LLC ship work (#9861) — core-loop e2e test.

Gap

The LLC budget API (autobot-backend/llc/api/budget.py) only ingests (POST /budget/{agent_id}/ingest), reads (GET /budget, GET /budget/{agent_id}), and updates a limit (PUT /budget/{agent_id}/limit) an llc_agent_budgets row. There is no public endpoint to create the initial per-agent budget row.

Impact

  • An agent has no budget until something out-of-band inserts the row; ingest/read against a never-provisioned agent has no row to act on.
  • The e2e test had to seed LLCAgentBudget directly via the session because no endpoint provisions it.

Suggested resolution

Provision the budget row as part of the agent-hire flow (preferred — hire is where an agent gets created), or add an explicit create endpoint. Confirm the intended owner of budget provisioning.

Related: org-chart endpoint (#9861) reports budget_spent/budget_total = 0 for agents with no budget row.

Activity

  1. mrveiss commented on Jun 11, 2026

    @mrveiss
    OwnerAuthor

    Closed — merged to Dev_new_gui via PR #9981 (squash commit 59020282b).

    Criteria met:

    • Hire-time auto-provision: hire_agent creates the llc_agent_budgets row in the same transaction as the agent_org_nodes INSERT (the issue's preferred owner)
    • Explicit POST /budget/{agent_id}: 404 unknown agent, 409 already provisioned, budget_limit validated (>0, fits Numeric(15,6)), company_id derived server-side from the agent's org node
    • Race-safe: savepoint + IntegrityError → idempotent return (concurrent provision can no longer 500 or fail a racing hire)
    • Default limit from LLC_DEFAULT_BUDGET_LIMIT via guarded Decimal parse (malformed value warns + falls back instead of crashing LLC router import)
    • 11/11 tests: 201/409/404, custom limit, idempotency, ingest-after-provision, hire wiring, IntegrityError race path; smoke-test + code-quality + llc-wiring-audit + llc-e2e green (hardened-smoke-test failure is the pre-existing non-required chromadb flake, fix(ci): hardened-smoke-test failing with read-only filesystem error #9663)

    Not in scope (noted in issue): backfilling budget rows for pre-existing agents — org-chart still reports 0/0 for them until a backfill lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions