Repository navigation
feat(usage): show Devin token usage from its local session history - #41851
OmarAlex24 wants to merge 1 commit into
Conversation
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.
|
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. |
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) carriesgeneration_model, a timestamp, and input/cache-read/cache-write/output token counts.Change
"devin"toUsageProviderKind.packages/provider-acp-registry/src/server/devinUsage.ts): ascanreader on the ACP Registry driver, modeled on the OpenCode reader.devin, or a localdevincommand.$XDG_DATA_HOME/devin/cli/sessions.db(default~/.local/share) read-only on a reader worker, withbusy_timeout = 100, and pages assistant rows by rowid within the window.claude-opus-5-5-highare priced at their base model. Devin's own SWE and fusion models stay unpriced; no rates were invented.docs/user/usage.mdlists 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:files: nullTests 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: statusok, 314 records, 2 sessions, 0.39 s. The per-model counts match a directsqlite3count of distinct request ids: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
UsageServicerun with a configured Devin instance, and Devin's data location on Windows.Implemented by Claude Opus 5.5 (high) via Devin CLI.