Skip to content

feat: add AI Bridge Proxy support to copilot module#725

Open
ssncferreira wants to merge 4 commits intossncf/feat-aibridge-proxy-modulefrom
ssncf/feat-copilot-aibridge-proxy
Open

feat: add AI Bridge Proxy support to copilot module#725
ssncferreira wants to merge 4 commits intossncf/feat-aibridge-proxy-modulefrom
ssncf/feat-copilot-aibridge-proxy

Conversation

@ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented Feb 12, 2026

Description

Add AI Bridge Proxy support to the copilot module. When enabled, the module configures proxy environment variables (HTTPS_PROXY, NODE_EXTRA_CA_CERTS) scoped to the copilot process tree (agentapi and copilot), routing Copilot traffic through AI Bridge Proxy without affecting other workspace traffic.

GitHub authentication is still required, the proxy authenticates with AI Bridge using the Coder session token but does not replace GitHub authentication.

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/coder-labs/modules/copilot
New version: v0.4.0
Breaking change: [ ] Yes [x] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Related Issues

Depends on: #721
Related to: coder/internal#1187

Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ssncferreira ssncferreira force-pushed the ssncf/feat-aibridge-proxy-module branch from 6fe9982 to 89718e0 Compare February 12, 2026 12:43
@ssncferreira ssncferreira force-pushed the ssncf/feat-copilot-aibridge-proxy branch 3 times, most recently from 610f44b to 7fd6d4a Compare February 12, 2026 13:06
@ssncferreira ssncferreira force-pushed the ssncf/feat-aibridge-proxy-module branch from 89718e0 to b4d4d04 Compare February 12, 2026 13:06
@ssncferreira ssncferreira force-pushed the ssncf/feat-copilot-aibridge-proxy branch 3 times, most recently from 2f3edbf to 25171fc Compare February 12, 2026 13:29
# These are inherited by the agentapi/copilot process below,
# but do not affect other workspace processes, avoiding routing
# unnecessary traffic through the proxy.
export HTTPS_PROXY="$ARG_AIBRIDGE_PROXY_AUTH_URL"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Testing with HTTP_PROXY revealed a bug in AI Bridge Proxy (coder/internal#1351), where plain HTTP requests are always rejected with 407. This caused issues with agentapi, which makes HTTP requests to Coder endpoints that were being routed through the proxy. After thinking this through, we should probably recommend only setting HTTPS_PROXY since we only need to intercept requests to AI providers, which all use https. Not setting HTTP_PROXY means http traffic goes direct without passing through the proxy. However, since these two env variables are generally set together, it should still work with the AI Bridge Proxy.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25171fc73e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

default = false

validation {
condition = !var.enable_aibridge_proxy || length(var.aibridge_proxy_auth_url) > 0

Choose a reason for hiding this comment

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

P1 Badge Raise required Terraform version for this validation

This validation references another input (var.aibridge_proxy_auth_url) from inside the enable_aibridge_proxy variable block, which requires Terraform 1.9+ for cross-variable validation expressions. The module still declares required_version = ">= 1.0", so consumers on Terraform 1.0–1.8 will fail during configuration loading/plan even if enable_aibridge_proxy is left at its default. Please either bump required_version to >= 1.9 or move this check to a resource precondition that works with older versions.

Useful? React with 👍 / 👎.

variable "aibridge_proxy_auth_url" {
type = string
description = "AI Bridge Proxy URL with authentication. Use the proxy_auth_url output from the aibridge-proxy module."
default = ""
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
default = ""
default = null

variable "aibridge_proxy_cert_path" {
type = string
description = "Path to the AI Bridge Proxy CA certificate. Use the cert_path output from the aibridge-proxy module."
default = ""
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
default = ""
default = null

Comment on lines +172 to +189
```tf
module "aibridge-proxy" {
source = "registry.coder.com/coder/aibridge-proxy/coder"
version = "1.0.0"
agent_id = coder_agent.main.id
proxy_url = "https://aiproxy.example.com"
}

module "copilot" {
source = "registry.coder.com/coder-labs/copilot/coder"
version = "0.4.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/projects"
enable_aibridge_proxy = true
aibridge_proxy_auth_url = module.aibridge-proxy.proxy_auth_url
aibridge_proxy_cert_path = module.aibridge-proxy.cert_path
}
```
Copy link
Member

Choose a reason for hiding this comment

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

How do we ensure that prxy is ready configured before the Copilot module starts up the Copilot CLI?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good point. I tried setting this up with commits:

And seems to be working. But probably still needs more testing.

@ssncferreira ssncferreira force-pushed the ssncf/feat-copilot-aibridge-proxy branch from bf49c26 to 93e107d Compare February 13, 2026 13:41
@ssncferreira ssncferreira force-pushed the ssncf/feat-copilot-aibridge-proxy branch from e0d1fe4 to a9e60bd Compare February 13, 2026 13:48
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.

2 participants