Skip to content

feat(cases): attribute notes to the originating AI session - #304

Merged
maximelb merged 1 commit into
masterfrom
feat/ai-cost-session-id
Jun 19, 2026
Merged

maximelb merged 1 commit into
masterfrom
feat/ai-cost-session-id

Conversation

@maximelb

Copy link
Copy Markdown
Contributor

Why

Part of the AI cost-tracking initiative. To attribute a case's AI cost to the session that produced the work, a note written by an AI agent must carry its ai_session_id.

What

cases.add_note() gains an optional ai_session_id, defaulting to the LC_AI_SESSION_ID environment variable (set by the ai-sessions runner). So notes an agent writes are attributed automatically — no caller change needed. Explicit arg overrides the env; with neither set, behavior is unchanged.

Unit tests cover explicit / from-env / override / unset.

Linked PRs

  • web-app-frontend#3894 — consumer (case-anchored savings)
  • ext-cases#58 — persists ai_session_id on the note event metadata
  • ai-sessions — sets LC_AI_SESSION_ID on the agent process

🤖 Generated with Claude Code

cases.add_note() gains an optional ai_session_id, defaulting to the
LC_AI_SESSION_ID environment variable (set by the ai-sessions runner). So a
note an AI agent writes into a case is automatically linked to its session,
letting the case's AI cost be summed downstream. Explicit arg overrides the
env; absent both, behavior is unchanged. Unit tests cover explicit/env/
override/unset.

Part of the AI cost-tracking initiative (web-app-frontend #3894; ext-cases
persists ai_session_id in the note event metadata).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014onzsCbKCevowbod9BK2rx
@maximelb
maximelb requested a review from a team June 19, 2026 23:36
@maximelb
maximelb marked this pull request as ready for review June 19, 2026 23:36
@maximelb
maximelb merged commit 9f0ffca into master Jun 19, 2026
7 checks passed
@maximelb
maximelb deleted the feat/ai-cost-session-id branch June 19, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants