Skip to main content

Attribution

Every telemetry event carries a session_id. The Costpilot Agent hook posts a report for that session on every prompt and again when the turn ends. The server stores the reports and attributes each model call when it is ingested. Five things are derived from that.

Issue​

The hook reports the issue from the git branch on every prompt. Each model call gets the issue reported by the latest prompt before it, once, when it is ingested; a call timestamped before any report of its session is counted towards the session's first turn. A pipeline passes issue_id as a resource attribute instead, which always wins.

On a branch without an issue key the hook reports the branch name (cut to 20 characters plus … when longer). That is kept as the branch dimension but counts as No issue. What counts as a key is decided by the project patterns, the instance's default issue key pattern in the Admin Area, and the keys known to the tracker mirror. The built-in default is

[A-Z][A-Z0-9]+-\d+(?:\.\d+)*

which recognises Jira-style keys (PROJ-123) and dotted story ids (US-02.001).

Turn​

Each prompt the hook reports is one turn: a developer's prompt and all the model calls that follow until the next prompt. Every call is counted towards the latest turn before it, by the developer machine's clock when the agent sent the report, so machine and server may disagree about the time.

When the tool reports the end of a turn on another branch than it started on ("create a branch and implement …"), the turn and everything recorded for it move to the branch it ended on. A pipeline run, where no hook runs, counts as one turn. A person's calls without a reported prompt (sessions outside a git repository, data from before reports were stored) belong to no turn and stay out of per-turn figures.

Project​

Derived at query time, never stored: from the issue key when it matches a project's issue key pattern (the whole key must match), else from the repository. The issue key wins when the two disagree; usage that matches neither is shown as No project. Editing a pattern or a project's repositories therefore re-attributes past cost too. See Projects.

Actor​

A person at a coding tool (human) or a named pipeline agent (agent, via the costpilot.agent resource attribute). The agent name wins over a user identity on the same usage; usage with neither is shown as No actor. See Agents in CI pipelines.

Time​

Cost counts when the model call happened, not when the issue was created or closed, and days are UTC days. With a date range set, every figure covers that range only.

Which sessions does the hook see?​

ToolSession idHook events (prompt, turn end)
Claude Codesession.idUserPromptSubmit, Stop
Gemini CLIsession.idBeforeAgent, AfterAgent
Codex CLIconversation.idUserPromptSubmit, Stop
Cursorconversation_idbeforeSubmitPrompt, stop

Cursor exposes no token counts, so only the mapping arrives. Token usage for Cursor would have to come from the Cursor Admin API, which carries user and day but no conversation id; that integration does not exist yet.