Skip to content

Conversation

@dannykopping
Copy link
Collaborator

Closes #135

Introduces a new header (X-AI-Bridge-Actor-Id) which will optionally be sent along with upstream requests with the actor's identity as the value.

Any metadata includes in the context.Actor struct will also be added to the headers in the format X-AI-Bridge-Actor-{Key}={Value}.

When enabled in coder/coder, two new headers will be added:

X-Ai-Bridge-Actor-Id: f2b8590e-693a-4cf7-9e30-36ccd8af3a60
X-Ai-Bridge-Actor-Metadata-Username: admin

Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
@dannykopping dannykopping marked this pull request as ready for review January 23, 2026 09:37
Copy link
Contributor

@ssncferreira ssncferreira left a comment

Choose a reason for hiding this comment

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

Overall LGTM 👍 just some nits around header key/value sanitization. I know most of this is validated on the coder side, but since this is a library might be worth sanitizing or rejecting bad input.


// Add headers for provided metadata.
for k, v := range actor.Metadata {
headers[ActorMetadataHeader(k)] = fmt.Sprintf("%v", v)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we should probably be sanitizing the headers/vallues to make sure they don't have whitespaces or invalid characters

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whitespace is fine in headers (well, not newlines) and I believe net/http takes care of invalid chars.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or did you perhaps mean the header key?

@dannykopping dannykopping merged commit bf1abce into main Jan 26, 2026
1 check passed
@dannykopping dannykopping deleted the dk/upstream-headers branch January 26, 2026 14:53
dannykopping added a commit to coder/coder that referenced this pull request Jan 26, 2026
Also passes along the authenticated username as actor metadata.

Closes coder/aibridge#135
Depends on coder/aibridge#142

**Replace aibridge tag with merge commit once
coder/aibridge#142 lands.**

---------

Signed-off-by: Danny Kopping <danny@coder.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send initiator identity and other configured metadata with upstream requests

2 participants