Skip to content

feat(usage): show Devin token usage from its local session history - #41851

Closed
OmarAlex24 wants to merge 1 commit into
pingdotgg:mainfrom
OmarAlex24:feat/devin-usage
Closed

OmarAlex24 wants to merge 1 commit into
pingdotgg:mainfrom
OmarAlex24:feat/devin-usage

Conversation

@OmarAlex24

Copy link
Copy Markdown
Contributor

Problem

Users who connect Devin through the ACP Registry see none of its token usage on the Usage page, because no usage reader covers Devin. Devin does keep the data locally: every assistant message in its SQLite session store (~/.local/share/devin/cli/sessions.db) carries generation_model, a timestamp, and input/cache-read/cache-write/output token counts.

Change

  • Contract: adds "devin" to UsageProviderKind.
  • Reader (packages/provider-acp-registry/src/server/devinUsage.ts): a scan reader on the ACP Registry driver, modeled on the OpenCode reader.
    • It runs only when a configured instance is Devin: registry agent devin, or a local devin command.
    • It opens $XDG_DATA_HOME/devin/cli/sessions.db (default ~/.local/share) read-only on a reader worker, with busy_timeout = 100, and pages assistant rows by rowid within the window.
    • It maps Devin's exclusive input/cache/output counters. A session branch copies the same inference onto many rows (12,427 assistant rows on a real DB hold 3,199 distinct requests), so records are deduplicated by request id.
    • Effort variants such as claude-opus-5-5-high are priced at their base model. Devin's own SWE and fusion models stay unpriced; no rates were invented.
  • Clients: web and mobile show Devin with its own label and color, and web uses the ACP Registry Devin icon. Limits stay keyed to real drivers, so Devin's entry doesn't recolor or hide limits for other ACP Registry agents.
  • Docs: docs/user/usage.md lists Devin, notes where its usage comes from, and says its SWE models are unpriced.

Scope and approval

This adds a usage source. It has no prior maintainer approval, and related earlier attempts were closed for that reason (#30248, #37342); the open discussion is #37365. I'm submitting it as one focused change that reads data Devin already writes locally, with no new settings, contract fields beyond the provider kind, or network calls. If it still needs approval first, close it and I'll continue in #37365.

Verification

  • New devinUsage.test.ts, with 5 tests on a temp fixture DB, covers:

    • the exact token mapping, with fallbacks to the session model and the row time
    • branch copies collapsed into one record
    • window filtering, including an in-window copy of an older inference
    • user rows and invalid JSON ignored
    • 600 rows read across page boundaries
    • non-Devin instances read nothing
    • a DB shared by two instances counts once
    • a missing DB returns files: null
  • Tests catch breakage: removing the window filter or shrinking the page size makes the main test fail.

  • Read-only run of the reader on a real Devin sessions.db, last 7 days: status ok, 314 records, 2 sessions, 0.39 s. The per-model counts match a direct sqlite3 count of distinct request ids:

    model priced as records input cache read cache write output
    claude-opus-5-5-high claude-opus-5-5 249 12,386 22,299,705 732,643 181,504
    claude-opus-5-5-medium claude-opus-5-5 32 20,199 2,904,722 124,075 15,111
    swe-2-max unpriced 33 86,213 2,485,120 0 28,858
  • vp run check:changed: format, lint, knip, typecheck (40 packages) and React compiler pass. In its test step, 34/34 tests pass in 5 of 6 files. The sixth, a web browser test, could not start because Playwright's Chromium isn't installed on this machine.

  • Not checked: screenshots of the rendered Usage page on web and mobile, a full UsageService run with a configured Devin instance, and Devin's data location on Windows.

Implemented by Claude Opus 5.5 (high) via Devin CLI.

Users who connect Devin through the ACP Registry saw none of its token usage on the Usage page,
because no usage reader knew about Devin's history.

Add "devin" as a usage provider. The ACP Registry driver now has a scan reader that, only when a
configured instance is Devin (registry agent "devin" or a local `devin` command), reads Devin's
SQLite session database (`$XDG_DATA_HOME/devin/cli/sessions.db`, default `~/.local/share`)
read-only on a reader worker. It pages assistant messages by rowid within the window, maps Devin's
exclusive input/cache/output counters, dedupes branch copies by request id, and prices effort
variants such as `claude-opus-5-5-high` at their base model. Web and mobile show Devin with its
own label and color (web uses the ACP Registry Devin icon), and limits stay keyed to real drivers
so Devin's entry does not recolor or hide other ACP Registry agents.

Implemented by Claude Opus 5.5 (high) via Devin CLI.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Nov 24, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for this. T3 Code's ACP Registry support follows the ACP spec: the code every agent shares takes no changes that are specific to one agent, and the special cases already there are not a precedent for more (how providers are integrated).

This adds Devin-only behavior to the generic ACP Registry adapter: it matches Devin's registry ID or executable name and reads its private session database. Historical usage retrieval needs a shared ACP capability rather than a vendor-specific reader in that adapter.

Please propose a provider-neutral usage-history capability upstream in ACP so this can work across agents. The use case and database findings can still inform that proposal, and the existing #37365 discussion preserves the request.

ACP has no shared way to do this yet. The place to propose one is ACP upstream, the Agent Client Protocol project itself, so that every agent can offer it and T3 Code can support it once for all of them.

Closing.

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

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants