Repository navigation
feat(server): agents can name the session owner and message sender - #116
Merged
Merged
Conversation
On a shared dev machine an agent had no reliable way to tell who it was working for, so it fell back to whatever the machine said — git config, a checked-in dotfile — and attributed one contributor's session to another. Provider sessions now spawn with three additive variables read from the durable environment-user directory: BK_IDENTITY_RUNTIME (always t3-code), BK_SESSION_OWNER_EMAIL for the thread owner, and BK_MESSAGE_SENDER_EMAIL for the user who actually sent the message being answered — never the owner by fallback, because an inferred sender is the misattribution this replaces. A missing or unreadable user record leaves the runtime marker alone and the turn proceeds, so "unknown" is expressible and nothing blocks on identity. Because a process reads its environment once at spawn, ProviderCommandReactor fingerprints the identity each live session was started with and restarts on an owner transfer or a new sender, beside the existing credential-actor restart. The markers compose with source-control profiles instead of replacing them: mergeSourceControlEnvironment now scrubs inherited Git and GitHub credentials only when the overlay carries a source-control identity of its own, so machine-identity mode keeps its own GH_TOKEN and still carries the markers. TEC-964 Model: Claude Opus 5 in T3 Code. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The OpenCode adapter refuses to start against an external server whenever execution options carry an environment, because it cannot inject one there. Now that every session carries identity markers in that same field, the guard would have failed every start against an external server. Test the guard on what it actually protects: a source-control identity in the overlay. The markers claim none, so they are simply not delivered to an external server instead of failing the turn. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ctor Proves the wiring, not just the resolver: owner and sender reach the provider execution options, an anonymous turn reports the runtime marker alone, the markers compose with a thread source-control profile, and an owner transfer restarts the session while the sender stays the same. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
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
On a shared dev machine an agent has no reliable way to tell who it is working for. It falls back to whatever the machine says — git config, a checked-in
.env.usersymlinked across worktrees — so one contributor's session gets attributed to another. Linear: TEC-964.Fix
Provider sessions now spawn with three additive environment variables, read from the durable environment-user directory rather than source control:
BK_IDENTITY_RUNTIMEt3-code. Marks the runtime even when nobody could be resolved.BK_SESSION_OWNER_EMAILBK_MESSAGE_SENDER_EMAILThe sender is never manufactured from the owner — an inferred sender is the misattribution this replaces — so an absent variable means "unknown" and the agent can say so. A missing or unreadable user record leaves the runtime marker alone and the turn proceeds; identity never blocks work and never falls back to git.
A provider process reads its environment once at spawn, so
ProviderCommandReactorfingerprints the identity each live session was started with and restarts on an owner transfer or a new sender, beside the existing credential-actor restart.Source-control profile injection is unchanged and composes with the markers:
mergeSourceControlEnvironmentnow scrubs the machine's inherited Git and GitHub credentials only when the overlay carries a source-control identity of its own, so machine-identity mode keeps its ownGH_TOKENwhile still carrying the markers.Shape
Logic lives in the fork-owned
apps/server/src/identity/SessionIdentityEnvironment.ts. The upstream-facing surface is four marked seams: the execution-options resolver inProviderCommandReactor.ts, the adapter-spawn call inProviderService.ts, one optional field onProviderSessionExecutionOptions, and the layer inserver.ts. No provider adapter changed.Tests
vp test run src/identity/SessionIdentityEnvironment.test.ts src/sourceControl/SourceControlExecutionEnvironment.test.ts— 15 passed. Covers owner/sender resolution, sender change, owner transfer, missing and blank user records, and composition in both machine and thread-profile source-control modes.ProviderCommandReactor,ProviderService,OrchestrationReactor,GitManager, andSourceControlProfileServicesuites re-run green (182 tests).Model: Claude Opus 5 in T3 Code.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.