diff --git a/README.md b/README.md index bfe613f..53d74ab 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ The default model is already set to `nvidia_nim/z-ai/glm4.7`. You can change it fcc-claude ``` -`fcc-claude` reads the current configured port and auth token each time it starts, sets the Claude Code environment variables, and then launches the real `claude` command. +`fcc-claude` reads the current configured port and auth token each time it starts, sets the Claude Code environment variables (including a 190k-token `CLAUDE_CODE_AUTO_COMPACT_WINDOW` for auto-compaction), and then launches the real `claude` command. ## Choose A Provider @@ -257,7 +257,7 @@ For terminal use, prefer the installed launcher: fcc-claude ``` -Keep `fcc-server` running while you work. The Admin UI manages proxy config, restarts the server when runtime settings change, and `fcc-claude` reads the current Admin UI-managed port and auth token every time it starts. +Keep `fcc-server` running while you work. The Admin UI manages proxy config, restarts the server when runtime settings change, and `fcc-claude` reads the current Admin UI-managed port and auth token every time it starts. It also sets `CLAUDE_CODE_AUTO_COMPACT_WINDOW` to `190000` for auto-compaction. ### 2. VS Code Extension @@ -267,7 +267,8 @@ Open Settings, search for `claude-code.environmentVariables`, choose **Edit in s "claudeCode.environmentVariables": [ { "name": "ANTHROPIC_BASE_URL", "value": "http://localhost:8082" }, { "name": "ANTHROPIC_AUTH_TOKEN", "value": "freecc" }, - { "name": "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY", "value": "1" } + { "name": "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY", "value": "1" }, + { "name": "CLAUDE_CODE_AUTO_COMPACT_WINDOW", "value": "190000" } ] ``` @@ -286,7 +287,8 @@ Set the environment for `acp.registry.claude-acp`: "env": { "ANTHROPIC_BASE_URL": "http://localhost:8082", "ANTHROPIC_AUTH_TOKEN": "freecc", - "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1" + "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1", + "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "190000" } ``` @@ -411,7 +413,7 @@ Run them in that order before pushing. CI enforces the same checks. - `fcc-server`: starts the proxy with configured host and port. - `fcc-init`: optional advanced scaffold for `~/.fcc/.env`; prefer the **Admin UI** for normal configuration. -- `fcc-claude`: launches Claude Code with the configured local proxy URL, auth token, and model discovery flag. +- `fcc-claude`: launches Claude Code with the configured local proxy URL, auth token, model discovery flag, and a 190k `CLAUDE_CODE_AUTO_COMPACT_WINDOW` for auto-compaction. - `free-claude-code`: compatibility alias for `fcc-server`. ### 5. Extending diff --git a/cli/entrypoints.py b/cli/entrypoints.py index 1782185..2da2ed3 100644 --- a/cli/entrypoints.py +++ b/cli/entrypoints.py @@ -182,6 +182,7 @@ def _claude_child_env( env.pop("ANTHROPIC_API_KEY", None) env["ANTHROPIC_BASE_URL"] = local_proxy_root_url(settings) env["CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"] = "1" + env["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] = "190000" if token := settings.anthropic_auth_token.strip(): env["ANTHROPIC_AUTH_TOKEN"] = token return env diff --git a/cli/session.py b/cli/session.py index a35d19e..fc11f62 100644 --- a/cli/session.py +++ b/cli/session.py @@ -119,6 +119,7 @@ class CLISession: else: env["ANTHROPIC_BASE_URL"] = self.api_url env["CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"] = "1" + env["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] = "190000" env.pop("ANTHROPIC_API_KEY", None) if token := self.auth_token.strip(): env["ANTHROPIC_AUTH_TOKEN"] = token diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index f57c70c..2b3e282 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -533,6 +533,7 @@ class TestCLISession: env = mock_exec.call_args.kwargs["env"] assert env["ANTHROPIC_AUTH_TOKEN"] == "proxy-token" assert env["CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"] == "1" + assert env["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] == "190000" assert "ANTHROPIC_API_KEY" not in env @pytest.mark.asyncio diff --git a/tests/cli/test_entrypoints.py b/tests/cli/test_entrypoints.py index a22692d..fb3ab6a 100644 --- a/tests/cli/test_entrypoints.py +++ b/tests/cli/test_entrypoints.py @@ -306,6 +306,7 @@ def test_claude_child_env_targets_current_proxy_config() -> None: assert env["ANTHROPIC_BASE_URL"] == "http://127.0.0.1:9090" assert env["ANTHROPIC_AUTH_TOKEN"] == "proxy-token" assert env["CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"] == "1" + assert env["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] == "190000" assert "ANTHROPIC_API_KEY" not in env @@ -355,6 +356,7 @@ def test_launch_claude_passes_args_and_child_env( assert child_env["ANTHROPIC_BASE_URL"] == "http://127.0.0.1:9191" assert child_env["ANTHROPIC_AUTH_TOKEN"] == "proxy-token" assert child_env["CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY"] == "1" + assert child_env["CLAUDE_CODE_AUTO_COMPACT_WINDOW"] == "190000" assert child_env["KEEP_ME"] == "yes" register_pid.assert_called_once_with(12345) unregister_pid.assert_called_once_with(12345)