Fix Agents send principal attribution#4604
Merged
Merged
Conversation
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## main #4604 +/- ##
===========================================
- Coverage 58.41% 35.46% -22.96%
===========================================
Files 365 246 -119
Lines 41478 21001 -20477
Branches 11962 7423 -4539
===========================================
- Hits 24228 7447 -16781
+ Misses 17177 13520 -3657
+ Partials 73 34 -39
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Electric Agents Mobile BuildLocal mobile checks ran for commit The EAS Android preview build was skipped because the |
thruflo
approved these changes
Jun 16, 2026
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.
Fixes Electric Agents sends from the CLI and web UI by removing client-supplied legacy
fromattribution. CLI requests now always include a useful defaultElectric-Principalheader (system:cli-<os-username>), so the server can keep deriving sender attribution from the authenticated principal.Root Cause
The Agents send endpoint validates that any request body
fromvalue matches the authenticatedElectric-Principal. Current clients could still send stale/display-level attribution (from: "user"in the UI repro, and the CLI's identity string), which does not match the server principal and produced400 Request from must match Electric-Principal.Approach
frominelectric-ax agents send; the request body now contains onlypayloadand optionaltype.system:cli-<os-username>whenELECTRIC_AGENTS_PRINCIPALis not set.fromvalue; optimistic local rendering still uses the active principal locally, while server writes are attributed by the server.Key Invariants
from, when present, must match the authenticated principal.fromfor normal user sends.Non-goals
from: "user".Trade-offs
I initially considered accepting
from: "user"server-side as a compatibility alias, but that weakens the clarity of the send invariant. Since backwards compatibility is not required here, updating the current clients keeps the contract simpler.Verification
Also ran the changeset checker:
Files changed
.changeset/fix-cli-principal-send.md— patch changeset forelectric-axand@electric-ax/agents-server-ui.packages/electric-ax/src/index.ts— default CLI principal header and nofromfield in sends.packages/electric-ax/test/cli.test.ts— coverage for default CLI principal and send request body.packages/agents-server-ui/src/lib/sendMessage.ts— remove send-body principal resolution andfromposting.Fixes #4602