Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-15432-broker-no-proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Agents now bypass the hive proxy for the host of `OMP_AUTH_BROKER_URL` (added to `NO_PROXY`), so a credential broker on a private address such as the Docker bridge gateway is no longer refused by the plain-forward guard and the agent CLI no longer exits on start ([#15432](https://github.com/hivecommons/hive/issues/15432)).
1 change: 1 addition & 0 deletions src/crux/agent/coverage_boost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func TestAgentEnvPairs_NonInference_NoProxyLoopback(t *testing.T) {
Config: config.AgentConfig{Backend: "claude", Model: "sonnet"},
}

t.Setenv("OMP_AUTH_BROKER_URL", "")
count := 0
for _, p := range m.agentEnvPairs(ap) {
if p.Key == "NO_PROXY" {
Expand Down
23 changes: 22 additions & 1 deletion src/crux/agent/manager_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package agent
import (
"encoding/json"
"fmt"
"net/url"
"os"
"os/exec"
"path/filepath"
Expand All @@ -16,6 +17,23 @@ import (
"github.com/hivecommons/hive/crux/jev"
)

// agentNoProxy returns the NO_PROXY value handed to agents: loopback plus the
// host of OMP_AUTH_BROKER_URL, and only that host. An unset, unparsable or
// host-less URL adds nothing, so every other private address stays behind the
// proxy's destination guard.
func agentNoProxy() string {
const loopback = "127.0.0.1,localhost,::1"
u, err := url.Parse(strings.TrimSpace(os.Getenv("OMP_AUTH_BROKER_URL")))
if err != nil {
return loopback
}
host := u.Hostname()
if host == "" || strings.ContainsAny(host, ", \t") {
return loopback
}
return loopback + "," + host
}

func (m *Manager) buildBootstrapPrompt(agent *AgentProcess) string {
// No boot prompt — the governor's first eval cycle (10s after startup)
// kicks all due agents via BuildKickMessages with fully substituted
Expand Down Expand Up @@ -253,7 +271,10 @@ func (m *Manager) agentEnvPairs(agent *AgentProcess) []agentEnvPair {
vars = append(vars, agentEnvPair{"HTTP_PROXY", proxyURL, false})
// Loopback must never traverse the hive proxy for any backend: an agent
// polling a local dev server would otherwise get proxy-side dial errors (#14076).
vars = append(vars, agentEnvPair{"NO_PROXY", "127.0.0.1,localhost,::1", false})
// The credential broker (OMP_AUTH_BROKER_URL) usually sits on a private
// address the proxy's plain-forward guard refuses, so its host bypasses
// the proxy too (#15432).
vars = append(vars, agentEnvPair{"NO_PROXY", agentNoProxy(), false})
vars = append(vars, agentEnvPair{"HIVE_PROXY_AGENT", agent.Name, false})
vars = append(vars, agentEnvPair{"GIT_TERMINAL_PROMPT", "0", false})
vars = append(vars, agentEnvPair{"NODE_EXTRA_CA_CERTS", proxyCACertPath, false})
Expand Down
26 changes: 26 additions & 0 deletions src/crux/agent/manager_env_noproxy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package agent

import "testing"

func TestAgentNoProxy(t *testing.T) {
const loop = "127.0.0.1,localhost,::1"
cases := []struct {
name, url, want string
}{
{"unset", "", loop},
{"ipv4 with port", "http://172.18.0.1:18765/v1/snapshot", loop + ",172.18.0.1"},
{"hostname", "http://broker.internal:8080", loop + ",broker.internal"},
{"ipv6 literal", "http://[fd00::1]:18765", loop + ",fd00::1"},
{"invalid", "http://[::1", loop},
{"no host", "/just/a/path", loop},
{"opaque", "mailto:x@y", loop},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("OMP_AUTH_BROKER_URL", tc.url)
if got := agentNoProxy(); got != tc.want {
t.Errorf("agentNoProxy() = %q, want %q", got, tc.want)
}
})
}
}
Loading