Skip to content

fix(observability): keep the T3 Code launch mark on Claude Code sessions - #119

Merged
yordis merged 3 commits into
mainfrom
yordis/fix-claude-launched-attribute
Oct 19, 2026
Merged

yordis merged 3 commits into
mainfrom
yordis/fix-claude-launched-attribute

Conversation

@yordis

@yordis yordis commented Oct 19, 2026 •

Copy link
Copy Markdown
Member
  • Claude Code applies the env of its settings files over the environment it was launched with, so anyone who sets OTEL_RESOURCE_ATTRIBUTES there silently loses t3code.launched and their T3 Code sessions vanish from launch-filtered telemetry, while Codex keeps it.
  • The replay tests read the real Claude config directory of whoever runs them, so they broke on any machine with such a settings file.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@cursor

cursor Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes how Claude query env/settings are built from on-disk user config and OTEL attribute strings; mistakes could mis-tag telemetry or alter resource attributes, though behavior is heavily tested and respects explicit opt-out.

Overview
Claude Code replaces the process environment with env from its settings files, which was wiping t3code.launched=true when users set OTEL_RESOURCE_ATTRIBUTES there and made T3-driven sessions disappear from launch-filtered harness telemetry.

This PR adds claudeSettingsLaunchedEnv, which walks Claude settings (local → project → user/config dir), finds the winning OTEL_RESOURCE_ATTRIBUTES, and when needed returns flag settings.env that keeps that value and appends t3code.launched=true. makeClaudeQueryOptions merges that into SDK settings (without touching a string settings path), and the Claude v2 adapter computes it per turn. Shared helpers userLaunchedAttribute / withLaunchedAttribute centralize parsing and opt-out (t3code.launched=false).

Tests cover precedence, relative config dirs, bad JSON, and opt-out; the deterministic test runtime pins HomeDirectory so replay tests no longer depend on the host’s real Claude config. Observability docs note the Claude settings behavior.

Reviewed by Cursor Bugbot for commit c06cd12. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Oct 19, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 943441d. Configure here.

Comment thread apps/server/src/provider/Drivers/ClaudeHome.ts
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1b73c9a8-ac8d-4070-b860-c0ce17e83046
📥 Commits

Reviewing files that changed from the base of the PR and between 943441d and 4870235.

📒 Files selected for processing: 2
  • apps/server/src/provider/Drivers/ClaudeHome.test.ts
  • apps/server/src/provider/Drivers/ClaudeHome.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b183f7e-0675-4430-9853-b6970feffcac
📥 Commits

Reviewing files that changed from the base of the PR and between eb9872b and 943441d.

📒 Files selected for processing: 8
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.ts
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
  • apps/server/src/provider/Drivers/ClaudeHome.test.ts
  • apps/server/src/provider/Drivers/ClaudeHome.ts
  • docs/fork/0031-harness-telemetry-says-t3code-launched-it.md
  • docs/operations/observability.md
  • packages/provider-core/src/server/instanceEnvironment.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The change adds helpers for resolving t3code.launched in Claude settings environments. The runtime adapter passes the resolved environment into query options, and tests and documentation cover the resulting behavior.

Changes: Claude launched telemetry

Layer / File(s) Summary
Launched attribute helpers
packages/provider-core/src/server/instanceEnvironment.ts
Exports helpers to read the configured t3code.launched value and append it when absent. Resource attribute lookup decodes matching values and falls back to raw text if decoding fails.
Claude settings environment resolution
apps/server/src/provider/Drivers/ClaudeHome.ts, apps/server/src/provider/Drivers/ClaudeHome.test.ts
Adds a function that checks project-local and home Claude settings for OTEL_RESOURCE_ATTRIBUTES. It returns an override with the launched attribute when applicable. Tests cover precedence, missing or invalid settings, and opt-out values.
Runtime query settings
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.testkit.ts, docs/fork/0031-harness-telemetry-says-t3code-launched-it.md, docs/operations/observability.md
openQuery passes the resolved settings environment into query options. Object-valued SDK settings merge that environment; string settings remain unchanged. Tests, replay setup, and documentation reflect this behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ClaudeAdapterV2
  participant claudeSettingsLaunchedEnv
  participant ClaudeSettingsFiles
  participant makeClaudeQueryOptions
  ClaudeAdapterV2->>claudeSettingsLaunchedEnv: Resolve environment for runtime working directory
  claudeSettingsLaunchedEnv->>ClaudeSettingsFiles: Read project-local and home settings
  claudeSettingsLaunchedEnv-->>ClaudeAdapterV2: Return launched settings environment when applicable
  ClaudeAdapterV2->>makeClaudeQueryOptions: Pass settings environment
  makeClaudeQueryOptions-->>ClaudeAdapterV2: Return query options with merged object settings
Loading

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 94344

The reported opt-out conflict does not occur on the production query path. The change is mergeable after normal checks.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the problem, but it omits the required Change, Scope and approval, and Verification sections. It also does not describe the implementation, approval or issue context, focused … Add the required headings and content. Describe how the code preserves t3code.launched and isolates replay tests, provide issue or maintainer approval context or explain the small obvious-bug exemption, and document the focused tests or man…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: preserving the T3 Code launch mark in Claude Code sessions.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, but it omits the required Change, Scope and approval, and Verification sections. It also does not describe the implementation, approval or issue context, focused tests, or observed results.

Resolution

Add the required headings and content. Describe how the code preserves t3code.launched and isolates replay tests, provide issue or maintainer approval context or explain the small obvious-bug exemption, and document the focused tests or manual checks with observed results and any limitations.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…de does

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 4.9 KiB 5.0 KiB +23 B (+0.5%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB +23 B (+1.9%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.8 KiB 20.9 KiB +41 B (+0.2%) 29.3 KiB ✅
Codex Live turn messages 1 2 +1 (+100.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB −7 B (−0.1%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −7 B (−0.6%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: eb9872b · PR result: c06cd12 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis merged commit defebfa into main Oct 19, 2026
27 of 28 checks passed
@yordis
yordis deleted the yordis/fix-claude-launched-attribute branch October 19, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant