feat: add Atlas Cloud Chat Completions support - #1131
Conversation
Signed-off-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com>
📝 WalkthroughWalkthroughAtlas Cloud is added as a ChatCompletion provider. The change adds URL detection, API-key resolution, configuration errors, documentation, a single-agent configuration, and regression tests. ChangesAtlas Cloud provider support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant BackendConfig
participant create_backend
participant Environment
participant ConfigurationError
BackendConfig->>create_backend: pass atlascloud.ai base URL
create_backend->>Environment: read ATLASCLOUD_API_KEY
Environment-->>create_backend: return API key
create_backend-->>BackendConfig: create configured backend
Environment-->>ConfigurationError: key unavailable
Suggested reviewers: 🚥 Pre-merge checks | ✅ 6 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@massgen/cli/backends.py`:
- Around line 242-250: Replace substring-based Atlas Cloud detection with one
shared URL-host predicate that safely parses the hostname and accepts only the
approved exact host and valid subdomains, excluding userinfo and query-string
tricks. Use this predicate in massgen/cli/backends.py lines 242-250 to decide
whether to load ATLASCLOUD_API_KEY, and in massgen/backend/chat_completions.py
lines 1149-1150 within ChatCompletionsBackend.get_provider_name(); add tests
covering exact-host, subdomain-boundary, userinfo, and query-string cases.
In `@massgen/configs/basic/single/single_atlascloud.yaml`:
- Around line 1-8: The configuration example needs a “What happens” comment
describing the Atlas Cloud request, the textual terminal output, and the
required ATLASCLOUD_API_KEY. Add this comment near the existing invocation
comment in the YAML file, while preserving the current configuration.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: fc314023-eb92-47b6-9bc1-8fa3330b5ccd
📒 Files selected for processing (7)
.env.exampledocs/source/reference/supported_models.rstmassgen/backend/chat_completions.pymassgen/cli/backends.pymassgen/configs/BACKEND_CONFIGURATION.mdmassgen/configs/basic/single/single_atlascloud.yamlmassgen/tests/test_chat_completions_refactor.py
| elif base_url and "atlascloud.ai" in base_url: | ||
| api_key = os.getenv("ATLASCLOUD_API_KEY") | ||
| if not api_key: | ||
| raise ConfigurationError( | ||
| "Atlas Cloud API key not found. Set ATLASCLOUD_API_KEY environment variable.\n" | ||
| "You can add it to a .env file in:\n" | ||
| " - Current directory: .env\n" | ||
| " - Global config: ~/.massgen/.env", | ||
| ) |
There was a problem hiding this comment.
🔒 Security & Privacy | 🔴 Critical | ⚡ Quick win
Validate the Atlas Cloud hostname before selecting the provider or credential.
Both changes use substring matching. A crafted base_url can be classified as Atlas Cloud even when its actual hostname belongs to another party. In massgen/cli/backends.py, that classification loads ATLASCLOUD_API_KEY; ChatCompletionsBackend then uses the same URL for the client. Use one shared URL-host predicate and add tests for exact-host, subdomain-boundary, userinfo, and query-string cases.
massgen/cli/backends.py#L242-L250: parsebase_urland loadATLASCLOUD_API_KEYonly for an approved Atlas Cloud hostname.massgen/backend/chat_completions.py#L1149-L1150: use the same predicate forget_provider_name().
📍 Affects 2 files
massgen/cli/backends.py#L242-L250(this comment)massgen/backend/chat_completions.py#L1149-L1150
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@massgen/cli/backends.py` around lines 242 - 250, Replace substring-based
Atlas Cloud detection with one shared URL-host predicate that safely parses the
hostname and accepts only the approved exact host and valid subdomains,
excluding userinfo and query-string tricks. Use this predicate in
massgen/cli/backends.py lines 242-250 to decide whether to load
ATLASCLOUD_API_KEY, and in massgen/backend/chat_completions.py lines 1149-1150
within ChatCompletionsBackend.get_provider_name(); add tests covering
exact-host, subdomain-boundary, userinfo, and query-string cases.
| # MassGen Atlas Cloud Configuration | ||
| # uv run massgen --automation --config massgen/configs/basic/single/single_atlascloud.yaml "Hello" | ||
| agents: | ||
| - id: "atlascloud_agent" | ||
| backend: | ||
| type: "chatcompletion" | ||
| model: "qwen/qwen3.8-max" | ||
| base_url: "https://api.atlascloud.ai/v1" |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add the required What happens comment.
The file has only an invocation comment. It does not explain the execution flow after MassGen starts. Add a short comment that describes the Atlas Cloud request, the textual terminal output, and the required ATLASCLOUD_API_KEY.
As per path instructions, massgen/configs/**/*.yaml examples must include “What happens” comments explaining execution flow.
Suggested comment
# MassGen Atlas Cloud Configuration
# uv run massgen --automation --config massgen/configs/basic/single/single_atlascloud.yaml "Hello"
+# Requires ATLASCLOUD_API_KEY in the environment.
+# What happens: MassGen sends the prompt to Atlas Cloud through the
+# OpenAI-compatible Chat Completions endpoint and renders the response in
+# the textual terminal UI.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # MassGen Atlas Cloud Configuration | |
| # uv run massgen --automation --config massgen/configs/basic/single/single_atlascloud.yaml "Hello" | |
| agents: | |
| - id: "atlascloud_agent" | |
| backend: | |
| type: "chatcompletion" | |
| model: "qwen/qwen3.8-max" | |
| base_url: "https://api.atlascloud.ai/v1" | |
| # MassGen Atlas Cloud Configuration | |
| # uv run massgen --automation --config massgen/configs/basic/single/single_atlascloud.yaml "Hello" | |
| # Requires ATLASCLOUD_API_KEY in the environment. | |
| # What happens: MassGen sends the prompt to Atlas Cloud through the | |
| # OpenAI-compatible Chat Completions endpoint and renders the response in | |
| # the textual terminal UI. | |
| agents: | |
| - id: "atlascloud_agent" | |
| backend: | |
| type: "chatcompletion" | |
| model: "qwen/qwen3.8-max" | |
| base_url: "https://api.atlascloud.ai/v1" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@massgen/configs/basic/single/single_atlascloud.yaml` around lines 1 - 8, The
configuration example needs a “What happens” comment describing the Atlas Cloud
request, the textual terminal output, and the required ATLASCLOUD_API_KEY. Add
this comment near the existing invocation comment in the YAML file, while
preserving the current configuration.
Source: Path instructions
Description
Adds Atlas Cloud support to the generic Chat Completions backend by:
ATLASCLOUD_API_KEYforhttps://api.atlascloud.ai/v1Type of change
feat:) - Non-breaking change which adds functionalityChecklist
Pre-commit status
All applicable hooks pass. The configured
pyupgradehook crashes under Python 3.14 before inspecting files due to an upstream compatibility error; the same configuredpyupgrade --py311-pluscheck passes under Python 3.13.How to Test
A live request through the MassGen-created backend to
qwen/qwen3.8-maxat the Atlas Cloud endpoint also completed successfully.Summary by CodeRabbit
New Features
ATLASCLOUD_API_KEY.Bug Fixes
Tests