Skip to content

Extend agenda token accounting to the auto_research execution path #42

Description

@Protocol-zero-0

Agenda token accounting currently hooks call_llm / _call_provider, and agenda_scope(agenda_id, operation) is only entered on the discovery paths (signal harvest, tier1/tier2 discovery, selection), so ledger rows and token_spent cover the discovery stage only. LLM calls made by execution workers dispatched after agenda_orchestrator hands a selection over to the auto_research path run outside any agenda scope and are not attributed, which undercounts an agenda's real spend once execution starts.

Goal: extend agenda_scope into the execution path so that worker-side LLM calls write agenda_token_ledger rows and bump token_spent exactly like discovery calls do. Budget enforcement should reuse the existing semantics unchanged: check_budget before each provider request, flip to paused_budget on exhaustion, and recovery via raising the budget or the resume endpoint as today. Budgets of 0/NULL/negative stay accounting-only on this path as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions