Skip to content

Agent spend and agent work per engineer, across every coding agent #188

Opensyntaqx opened this feature

Build what g1t needs so a team can see agent spend and agent work per engineer, across every coding agent it uses, as well as or better than the products that already sell this. The research is done, and this item is the plan to build from it.

Read first

  • docs/research/agent-spend-per-engineer.md (committed 2026-10-18). It covers:
    • what each agent exposes (OTel, admin APIs, local files, hooks), with sources;
    • what LinearB, Jellyfish, DX, Swarmia, Faros, Span, Weave, Waydev, Exceeds, Opsera, Cursor's and Copilot's dashboards and RadiantOps show, and what they charge;
    • the privacy model;
    • the ranked plan, each step with its exact endpoint, telemetry field or file.
  • apps/docs/src/content/docs/guides/home.md: Home after #167 (Ask first, Your move beside Live, This week day by day, then Since you were here).

Where things stand (2026-10-18)

  • Spend comes from three places:
    • g1t's metered agent runs (billing usage).
    • Claude Code sessions. plugins/claude-code/hooks/g1t.mjs reads the transcript's message.usage and sends g1t session heartbeat --usage-json (CLI 0.4.1, plugin 0.3.1). The work service prices the usage with crates/contracts/src/model_prices.rs, which has only Anthropic list prices, and stores sessions.usage and sessions.cost_usd.
    • Provider cost reports (services/billing/src/provider_costs.rs), which cover the whole organization and are never per user.
  • Codex now has hooks: SessionStart, Stop, SubagentStop and SessionEnd, each carrying transcript_path and model. plugins/codex uses none of them.
  • Home's Live panel shows each live session's cost so far, but there's no per-person spend view anywhere. Members see each other's sessions.cost_usd, while prompts stay with their author (services/work/src/coordination/shown.rs).
  • In a one-person, direct-push workspace like flagon-io, most findings never show. See the table in the report's "Where g1t stands".

The plan, in order

Open a work item for each step as you start it (g1t work claim --title "…"), linked to this one, with one pull request per step.

  1. Check that session cost arrives. Every session recorded on 2026-10-18, subagents included, came back from coordination with cost_usd: null after it ended. For a real session and its subagents, compare sessions.usage and cost_usd with their transcripts. Find out whether the coordination payload leaves cost out, or whether usage from SubagentStop / SessionEnd never arrives. Fix whatever is wrong before anything else.

  2. Spend for direct pushes and solo workspaces.

    • quarterSpend in apps/web/app/lib/signals.ts drops sessions that aren't tied to a pull request. Group them by the work item their push closed (pushed.rs trailer_session), and otherwise by repository.
    • Allow a single group when the workspace has one person.

    1b. Findings for one person, each measured against your own last four weeks:

    • spend that never landed;
    • cost per landed change;
    • cache efficiency, from sessions.usage;
    • the week's most expensive session and what it produced.

    Scale the rework and gone-quiet thresholds to the workspace's volume.

  3. A "Your spend" view and spend by person, with the report's privacy model:

    • everyone sees their own spend in full;
    • no leaderboards;
    • a workspace setting spend_visibility: owners (the default), members or nobody;
    • no rollup that covers fewer than 3 people.

    Build the work service query over sessions, with session_links and session_touches, plus a -/spend route and g1t spend.

  4. Codex cost.

    • Add plugins/codex/hooks.json.
    • Read info.total_token_usage from the last event_msg token_count in transcript_path (.jsonl and .jsonl.zst).
    • Add OpenAI list prices to model_prices.rs.
    • Mark ChatGPT-plan sessions (rate_limits.plan_type) as an estimate.
  5. Check each person's spend against the provider.

    • Anthropic: GET /v1/organizations/usage_report/claude_code (per actor email, per day, estimated_cost per model).
    • OpenAI: /v1/organization/costs?group_by=user_id.
    • Add an actor column to provider_costs, matched to verified emails.
    • Home and -/spend say how much of a person's spend g1t saw.
  6. Cursor. Use hooks.json (sessionStart, stop, sessionEnd, which carry conversation_id, user_email and model). Cursor's hooks carry no tokens, so cost comes from the Admin API: POST /teams/filtered-usage-events joined on conversationId, and POST /teams/spend.

  7. An OTLP/HTTP receiver (/v1/logs, /v1/metrics) for Claude Code, Codex, Cursor's server-side export, Copilot and Gemini, with a managed-settings snippet in the docs for each. Drop prompt and response content by default.

  8. Gemini CLI and Copilot CLI hooks.

  9. Credit cloud agents' work to whoever started it: Copilot's Agent-Logs-Url trailer, Cursor Agent's co-author, Devin's pull_requests[].

  10. Amp and Devin Desktop spend from their APIs.

Before you build step 2 or later, check the report's sources for anything that changed since 2026-10-18, because vendor APIs here move monthly.

Related: #187 (agent setup and AI as its own layer) and #203 (work gets recorded in every harness).


How to work on this repository

  • Claim this item before you start (g1t work claim <number>), and add G1t-Session: $G1T_SESSION to every commit.
  • Other sessions share the main checkout: work in a worktree of your own and stage only your own files.
  • Pushing to main deploys production, and pushes to main and release tags are the owner's. Land the work through a pull request on this item, or commit locally and hand the owner the exact git -C <path> push ….
  • Shipped means on main and deployed. Check it live with real data and look at the rendered pages: a status code doesn't show it works.
  • Docs ship in the same change as the feature (guides, reference, llms.txt), to a high standard.
  • User-facing text never names other products or compares g1t to them. Internal notes and code comments may.

Repositories

Suggested

Repositories it may also need, and why.

  • hello8 work items with the same labels landed there; 1 work item with like titles landed there.
  • automation-lab2 work items with the same labels landed there.

Nobody has worked on this yet

Point your own agent at flagon-io#188.

Discussion

syntaqxmoved this from Triage to Now·

Sign in to comment.