stacklok / stacklok/mecatl

feat(usage): attribute every auxiliary LLM call in canonical token usage

Open
#1,216 0 comments 0 reactions 1 assignee View on GitHub

@jbeda is already working on this.

Since Sep 7, 2026.

Dominant language
Go
Stars
152
Forks
16
Avg merge
14h 48m
Merged PRs (30d)
536

Description

Goal

Audit every model/provider invocation outside the normal agent-run stream and ensure its input/output usage is recorded in the canonical durable Session.tokenUsage ledger under a purpose-specific usage kind and server-selected provider/model attribution.

The session-title generator is the first migrated auxiliary caller (session_title). Other LLM-backed operations may currently discard usage or fold it into the main run incorrectly.

Acceptance criteria

  • Inventory all composition/server/agent auxiliary LLM call sites, including their ownership, lifetime, session association, and current usage handling.
  • For every session-associated call, record usage in a closed, purpose-specific canonical usage kind; preserve Session.Usage, EvResult.Usage, and MaxRunTokens as main-run-only unless an explicitly documented policy says otherwise.
  • For calls that cannot be tied to a session, document the intentional accounting boundary rather than fabricating attribution.
  • Preserve provider neutrality: do not widen port.LLMRequest for accounting or provider-private controls.
  • Add offline coverage for every migrated call and update living architecture/implementation documentation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.