feat(agent): forward ai_session_id run-state key to gateway properties - #4011
Closed
sortafreel wants to merge 1 commit into
Closed
feat(agent): forward ai_session_id run-state key to gateway properties#4011sortafreel wants to merge 1 commit into
sortafreel wants to merge 1 commit into
Conversation
Products that stash ai_session_id in run state (ReviewHog stamps one per review turn) get it lifted onto their runs' $ai_generation events, grouping a logical operation's generations. Transported unreserved — $-keys are stripped at gateway header boundaries — and promoted to the native $ai_session_id by the llm-gateway at capture. Null-safe: runs without the state key emit no header. Generated-By: PostHog Code Task-Id: 77db6432-21d6-400a-ad79-7ce81def58cf
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
2 tasks
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Run generations reach the gateway with task-level attribution only (
task_id,ai_stage, …) — there's no key grouping the generations of one logical operation. ReviewHog now stashesai_session_idin run state (one per review turn, PostHog/posthog#75592), but the agent-server doesn't forward it.Changes
Forward the
ai_session_idrun-state key into the gateway properties inconfigureEnvironment, next toai_stage. Transported unreserved —$-keys are stripped at gateway header boundaries — and promoted to the native$ai_session_idby the llm-gateway at capture. Null-safe: runs without the state key emit no header, so merge order with the companion PR is free.How did you test this?
Extended the
configureEnvironmenttests: both the header-record (codex) and header-lines (Claude) paths now assert the forwardedx-posthog-property-ai_session_id. Authored in a sandboxed environment — typecheck and test run via CI.Automatic notifications
Created with PostHog Code