Skip to content

feat: add Atlas Cloud Chat Completions support - #1131

Open
binyangzhu000-sudo wants to merge 1 commit into
massgen:mainfrom
binyangzhu000-sudo:codex/atlascloud-chatcompletion
Open

feat: add Atlas Cloud Chat Completions support#1131
binyangzhu000-sudo wants to merge 1 commit into
massgen:mainfrom
binyangzhu000-sudo:codex/atlascloud-chatcompletion

Conversation

@binyangzhu000-sudo

@binyangzhu000-sudo binyangzhu000-sudo commented Aug 10, 2026

Copy link
Copy Markdown

Description

Adds Atlas Cloud support to the generic Chat Completions backend by:

  • detecting ATLASCLOUD_API_KEY for https://api.atlascloud.ai/v1
  • identifying Atlas Cloud in provider-specific logging and diagnostics
  • documenting the endpoint and environment variable
  • adding a validated single-agent example configuration

Type of change

  • New feature (feat:) - Non-breaking change which adds functionality

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove the feature works
  • New and existing focused unit tests pass locally

Pre-commit status

All applicable hooks pass. The configured pyupgrade hook crashes under Python 3.14 before inspecting files due to an upstream compatibility error; the same configured pyupgrade --py311-plus check passes under Python 3.13.

How to Test

uv run pytest massgen/tests/test_chat_completions_refactor.py -q
uv run python scripts/validate_all_configs.py
uv build --wheel

A live request through the MassGen-created backend to qwen/qwen3.8-max at the Atlas Cloud endpoint also completed successfully.

Summary by CodeRabbit

  • New Features

    • Added Atlas Cloud as a supported Chat Completions provider.
    • Added automatic API key detection using ATLASCLOUD_API_KEY.
    • Added a ready-to-use single-agent configuration with a Qwen model.
    • Documented Atlas Cloud’s endpoint and account-specific model IDs.
  • Bug Fixes

    • Added clear configuration errors when the Atlas Cloud API key is missing.
  • Tests

    • Added coverage for provider detection, API key resolution, and missing-key errors.

Signed-off-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Atlas 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.

Changes

Atlas Cloud provider support

Layer / File(s) Summary
Provider detection and credential resolution
massgen/backend/chat_completions.py, massgen/cli/backends.py, .env.example, massgen/tests/test_chat_completions_refactor.py
Atlas Cloud URLs now identify the provider. create_backend reads ATLASCLOUD_API_KEY and raises ConfigurationError when the key is absent. Tests cover detection, key resolution, and missing credentials.
Provider documentation and example configuration
docs/source/reference/supported_models.rst, massgen/configs/BACKEND_CONFIGURATION.md, massgen/configs/basic/single/single_atlascloud.yaml
The documentation lists Atlas Cloud, its endpoint, credential variable, and account-specific model IDs. A single-agent Atlas Cloud configuration is added.

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
Loading

Suggested reviewers: ncrispino

🚥 Pre-merge checks | ✅ 6 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Documentation Updated ⚠️ Warning Atlas Cloud appears in reference and config docs, but the new user-facing feature makes no change to docs/source/user_guide/*.rst; the backend guide still omits Atlas Cloud. Update docs/source/user_guide/backends.rst with Atlas Cloud setup, endpoint, ATLASCLOUD_API_KEY, model-ID guidance, and an example command or config.
Capabilities Registry Check ⚠️ Warning Atlas Cloud changes the existing chatcompletion backend, but capabilities.py is unchanged and its registry still lists only the generic custom model; the required test could not run because uv/pyte... Update the chatcompletion capability registry with applicable Atlas Cloud model/provider metadata, then run uv run pytest massgen/tests/test_backend_capabilities.py -v.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required format and clearly identifies the main feature: Atlas Cloud Chat Completions support.
Description check ✅ Passed The description covers the feature, change type, testing commands, pre-commit status, documentation, tests, and live validation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Config Parameter Sync ✅ Passed The new Atlas YAML uses existing keys only; both exclusion methods already derive from BASE_EXCLUDED_CONFIG_PARAMS, and base_url is excluded by the Chat Completions handler.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 007bd85 and 2fee372.

📒 Files selected for processing (7)
  • .env.example
  • docs/source/reference/supported_models.rst
  • massgen/backend/chat_completions.py
  • massgen/cli/backends.py
  • massgen/configs/BACKEND_CONFIGURATION.md
  • massgen/configs/basic/single/single_atlascloud.yaml
  • massgen/tests/test_chat_completions_refactor.py

Comment thread massgen/cli/backends.py
Comment on lines +242 to +250
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",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 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: parse base_url and load ATLASCLOUD_API_KEY only for an approved Atlas Cloud hostname.
  • massgen/backend/chat_completions.py#L1149-L1150: use the same predicate for get_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.

Comment on lines +1 to +8
# 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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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.

Suggested change
# 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

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.

1 participant