Skip to content
Merged
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
12 changes: 6 additions & 6 deletions src/docker-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ describe('docker-manager', () => {
const result = generateDockerCompose(configWithProxy, mockNetworkConfigWithProxy);
const agent = result.services.agent;
const env = agent.environment as Record<string, string>;
expect(env.OPENAI_BASE_URL).toBe('http://api-proxy:10000');
expect(env.OPENAI_BASE_URL).toBe('http://172.30.0.30:10000');
});

it('should configure HTTP_PROXY and HTTPS_PROXY in api-proxy to route through Squid', () => {
Expand All @@ -1580,16 +1580,16 @@ describe('docker-manager', () => {
const result = generateDockerCompose(configWithProxy, mockNetworkConfigWithProxy);
const agent = result.services.agent;
const env = agent.environment as Record<string, string>;
expect(env.ANTHROPIC_BASE_URL).toBe('http://api-proxy:10001');
expect(env.ANTHROPIC_BASE_URL).toBe('http://172.30.0.30:10001');
});

it('should set both BASE_URL variables when both keys are provided', () => {
const configWithProxy = { ...mockConfig, enableApiProxy: true, openaiApiKey: 'sk-test-openai-key', anthropicApiKey: 'sk-ant-test-key' };
const result = generateDockerCompose(configWithProxy, mockNetworkConfigWithProxy);
const agent = result.services.agent;
const env = agent.environment as Record<string, string>;
expect(env.OPENAI_BASE_URL).toBe('http://api-proxy:10000');
expect(env.ANTHROPIC_BASE_URL).toBe('http://api-proxy:10001');
expect(env.OPENAI_BASE_URL).toBe('http://172.30.0.30:10000');
expect(env.ANTHROPIC_BASE_URL).toBe('http://172.30.0.30:10001');
});

it('should not set OPENAI_BASE_URL in agent when only Anthropic key is provided', () => {
Expand All @@ -1598,7 +1598,7 @@ describe('docker-manager', () => {
const agent = result.services.agent;
const env = agent.environment as Record<string, string>;
expect(env.OPENAI_BASE_URL).toBeUndefined();
expect(env.ANTHROPIC_BASE_URL).toBe('http://api-proxy:10001');
expect(env.ANTHROPIC_BASE_URL).toBe('http://172.30.0.30:10001');
});

it('should not set ANTHROPIC_BASE_URL in agent when only OpenAI key is provided', () => {
Expand All @@ -1607,7 +1607,7 @@ describe('docker-manager', () => {
const agent = result.services.agent;
const env = agent.environment as Record<string, string>;
expect(env.ANTHROPIC_BASE_URL).toBeUndefined();
expect(env.OPENAI_BASE_URL).toBe('http://api-proxy:10000');
expect(env.OPENAI_BASE_URL).toBe('http://172.30.0.30:10000');
});
});
});
Expand Down
9 changes: 5 additions & 4 deletions src/docker-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -967,13 +967,14 @@ export function generateDockerCompose(
environment.AWF_API_PROXY_IP = networkConfig.proxyIp;

// Set environment variables in agent to use the proxy
// Use IP address instead of hostname to avoid DNS resolution issues
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

While using IP addresses fixes the immediate DNS resolution issue, there's a related problem in the iptables setup script. The setup-iptables.sh script (lines 134-148) still uses getent hosts api-proxy to resolve the IP address for NAT rules, which could fail with the same DNS resolution issue. Consider updating that script to use the AWF_API_PROXY_IP environment variable instead, which is already being passed and contains the correct IP address. This would provide a more complete fix and ensure consistency across the entire networking setup.

Copilot uses AI. Check for mistakes.
if (config.openaiApiKey) {
environment.OPENAI_BASE_URL = `http://api-proxy:10000`;
logger.debug('OpenAI API will be proxied through sidecar at http://api-proxy:10000');
environment.OPENAI_BASE_URL = `http://${networkConfig.proxyIp}:10000`;
logger.debug(`OpenAI API will be proxied through sidecar at http://${networkConfig.proxyIp}:10000`);
}
if (config.anthropicApiKey) {
environment.ANTHROPIC_BASE_URL = `http://api-proxy:10001`;
logger.debug('Anthropic API will be proxied through sidecar at http://api-proxy:10001');
environment.ANTHROPIC_BASE_URL = `http://${networkConfig.proxyIp}:10001`;
logger.debug(`Anthropic API will be proxied through sidecar at http://${networkConfig.proxyIp}:10001`);
}

logger.info('API proxy sidecar enabled - API keys will be held securely in sidecar container');
Expand Down
8 changes: 4 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,13 @@ export interface WrapperConfig {
* - Proxies requests to LLM providers
*
* The sidecar exposes two endpoints accessible from the agent container:
* - http://api-proxy:10000 - OpenAI API proxy (for Codex)
* - http://api-proxy:10001 - Anthropic API proxy (for Claude)
* - http://172.30.0.30:10000 - OpenAI API proxy (for Codex)
* - http://172.30.0.30:10001 - Anthropic API proxy (for Claude)
*
* When the corresponding API key is provided, the following environment
* variables are set in the agent container:
* - OPENAI_BASE_URL=http://api-proxy:10000 (set when OPENAI_API_KEY is provided)
* - ANTHROPIC_BASE_URL=http://api-proxy:10001 (set when ANTHROPIC_API_KEY is provided)
* - OPENAI_BASE_URL=http://172.30.0.30:10000 (set when OPENAI_API_KEY is provided)
* - ANTHROPIC_BASE_URL=http://172.30.0.30:10001 (set when ANTHROPIC_API_KEY is provided)
*
* API keys are passed via environment variables:
* - OPENAI_API_KEY - Optional OpenAI API key for Codex
Expand Down
Loading