How do I track AI spend per conversation and per work item?
A session is one complete interaction — a support ticket, a JIRA story, a PR, or an agent task. Sessions let you measure cost per conversation and per work item, the metrics that map to business value and sprint reviews.
A Cognocient session is one complete interaction — a support ticket, a JIRA story, a PR, or an agent task run. Pass a unique X-Cost-Session ID on each turn to measure total cost per conversation and map AI spend to the work that generated it.
| Metric | Value | Detail |
|---|---|---|
| Avg session cost | $0.18 | Median across all session types |
| Longest session | 142 calls | Agent workflow, unbounded loop |
| Cost reduction | 34% | After context pruning |
What is a session?
A session is any group of API calls that you associate with a single logical interaction, passed using the X-Cost-Session header. Cognocient sums all calls in a session to give you a single cost figure for that interaction.
Without session tracking, you see five separate API calls with no connection between them. With a session ID, you see a single "support ticket handled" event costing $0.42 — a number you can directly compare to the value of resolving that ticket.
How to tag sessions
X-Cost-Session: sess_7x9a2b (required)
A unique identifier for one logical interaction. Generate a UUID or use your existing conversation/ticket ID. All calls within this ID are grouped into one session cost.
You almost certainly have an ID you can reuse: ticket ID, conversation ID, order ID, document ID. You don't need to generate new UUIDs — use what you already have.
Analysing sessions in the dashboard
The Sessions view shows a table sortable by cost, call count, duration, and waste detected. Click any session to see the full call tree — every API call in order, with model, token count, and cost for each step.
Sort by cost descending — Your most expensive sessions are at the top. These are the ones worth profiling first — a single session costing 10× the median usually reveals a specific architectural problem.
Filter by feature — Compare session costs within the same feature over time. If average session cost for "support-chat" rises 20% week-over-week, something changed — model, prompt, or user behaviour.
Look at the call count distribution — A healthy session has 2–6 calls. Sessions with 20+ calls usually indicate an agent loop that isn't terminating efficiently — a common source of runaway cost in agentic workflows.
Check the waste column — Sessions flagged with waste have at least one of: retry calls, model mismatch, context bloat, or context starvation. Drill in to see exactly which call triggered the flag.
Session cost as a business metric
Session cost is most powerful when mapped to a business outcome. Once you tag sessions consistently, you can calculate:
| Use case | Session = one … | Business metric |
|---|---|---|
| Customer support | Support ticket handled | AI cost per resolved ticket |
| Legal / contracts | Contract drafted or reviewed | AI cost per contract |
| Sales automation | Outbound email sequence | AI cost per deal opened |
| Document processing | Document extracted + classified | AI cost per document |
| Code review | PR review completed | AI cost per PR |
Connect sessions to outcomes in the Outcomes view. Once you define what counts as a successful outcome for a session type, Cognocient tracks cost per successful outcome separately from cost per failed or abandoned session.
Workstream attribution — JIRA stories, PRs, and agent tasks
When you pass a JIRA story key, PR number, or agent task UUID as the session ID, Cognocient recognises the pattern and surfaces it in the Workstreams dashboard — grouped by sprint work item with total cost, call count, and duration.
This answers the question every engineering manager asks at sprint review: "We spent $X on AI — which stories generated that cost?" See Workstream Attribution and the Workstreams Dashboard for the full view.
Next steps: Live Calls · Outcomes · Waste Detection · Workstream Attribution
Related articles