Skip to content

Comments

fix: use ANTHROPIC_DEFAULT_OPUS_MODEL env var for model selection#58

Merged
leonvanzyl merged 1 commit intoAutoForgeAI:masterfrom
simfor99:fix/env-model-override
Jan 15, 2026
Merged

fix: use ANTHROPIC_DEFAULT_OPUS_MODEL env var for model selection#58
leonvanzyl merged 1 commit intoAutoForgeAI:masterfrom
simfor99:fix/env-model-override

Conversation

@simfor99
Copy link
Contributor

@simfor99 simfor99 commented Jan 13, 2026

Summary

  • Fixed hardcoded model in chat session services that ignored ANTHROPIC_DEFAULT_OPUS_MODEL environment variable
  • Now reads model from env var with fallback to default claude-opus-4-5-20251101
  • Enables alternative API providers (e.g., GLM via z.ai, synthetic.new) to work correctly

Changes

Modified 3 files to read model from environment:

  • server/services/expand_chat_session.py
  • server/services/spec_chat_session.py
  • server/services/assistant_chat_session.py

Problem

The model was hardcoded to "claude-opus-4-5-20251101", causing API errors when using alternative providers that don't support Claude model names.

Example error from Issue #51:

API Error: 400 {"error":"Your model name should start with an hf: prefix..."}

Solution

# Before
model="claude-opus-4-5-20251101",

# After
model = os.getenv("ANTHROPIC_DEFAULT_OPUS_MODEL", "claude-opus-4-5-20251101")

Test plan

  • Verified fix applies to all three chat session services
  • Test with alternative API provider (GLM/z.ai)
  • Test default behavior (no env var set)

Fixes #51

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated chat session services to support dynamic AI model configuration through environment variables, enabling different model variants to be used without code changes.

✏️ Tip: You can customize this high-level summary in your review settings.

The model was hardcoded to "claude-opus-4-5-20251101" in chat session
services, ignoring the ANTHROPIC_DEFAULT_OPUS_MODEL environment variable.

This caused issues when using alternative API providers (e.g., GLM via z.ai)
that don't support Claude model names.

Fixes AutoForgeAI#51

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

Three chat session services are updated to dynamically read the Claude model name from the ANTHROPIC_DEFAULT_OPUS_MODEL environment variable instead of hardcoding it, enabling runtime model selection and support for alternative API backends.

Changes

Cohort / File(s) Summary
Dynamic Model Configuration
server/services/assistant_chat_session.py, server/services/expand_chat_session.py, server/services/spec_chat_session.py
Each file now reads ANTHROPIC_DEFAULT_OPUS_MODEL from environment (defaults to "claude-opus-4-5-20251101") and passes the resolved model name to ClaudeSDKClient instead of using hardcoded model strings. Enables alternative API model selection without code changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Three services hop in sync,
Reading models from the .env brink,
No more hardcoded names in sight,
Alternative APIs now run just right!
Environment variables make things tight! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses issue #51 by implementing environment variable support for ANTHROPIC_DEFAULT_OPUS_MODEL in three service files, but does not implement ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL environment variables mentioned in the issue. Complete the fix by also implementing ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL environment variables in all relevant service files to fully resolve issue #51.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: using ANTHROPIC_DEFAULT_OPUS_MODEL environment variable for dynamic model selection instead of hardcoded values across three service files.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing environment variable support for model selection across three chat session service files, with no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
server/services/assistant_chat_session.py (1)

158-164: Consider updating the docstring to reflect configurable model.

The class docstring mentions "Uses Claude Opus 4.5" but the model is now configurable via ANTHROPIC_DEFAULT_OPUS_MODEL. Consider generalizing this to avoid confusion.

📝 Suggested docstring update
 class AssistantChatSession:
     """
     Manages a read-only assistant conversation for a project.

-    Uses Claude Opus 4.5 with only read-only tools enabled.
+    Uses Claude (model configurable via ANTHROPIC_DEFAULT_OPUS_MODEL) with only read-only tools enabled.
     Persists conversation history to SQLite.
     """
📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07c2010 and bc7970f.

📒 Files selected for processing (3)
  • server/services/assistant_chat_session.py
  • server/services/expand_chat_session.py
  • server/services/spec_chat_session.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use SQLite with SQLAlchemy ORM for database access and feature management

Files:

  • server/services/spec_chat_session.py
  • server/services/assistant_chat_session.py
  • server/services/expand_chat_session.py
🧠 Learnings (1)
📚 Learning: 2026-01-10T08:23:04.012Z
Learnt from: CR
Repo: leonvanzyl/autocoder PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-10T08:23:04.012Z
Learning: Applies to *.py : Python backend should use the ClaudeSDKClient configuration in client.py with security hooks and MCP servers

Applied to files:

  • server/services/spec_chat_session.py
  • server/services/expand_chat_session.py
🔇 Additional comments (3)
server/services/expand_chat_session.py (1)

170-178: LGTM! Environment-driven model selection implemented correctly.

The change correctly reads the model from ANTHROPIC_DEFAULT_OPUS_MODEL with an appropriate fallback. The comment helpfully explains the rationale for alternative API support.

server/services/spec_chat_session.py (1)

172-179: LGTM! Consistent with the pattern used in other chat sessions.

The implementation correctly mirrors the approach in expand_chat_session.py, ensuring uniform behavior across all chat session services.

server/services/assistant_chat_session.py (1)

258-265: LGTM! Environment-driven model selection implemented correctly.

The change is consistent with the other chat session services and correctly enables alternative API backend support.


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

@leonvanzyl leonvanzyl merged commit 2216657 into AutoForgeAI:master Jan 15, 2026
1 check passed
@leonvanzyl
Copy link
Collaborator

Thank you

pRizz added a commit to pRizz/autocoder that referenced this pull request Jan 21, 2026
…t project

- Verified GET /api/projects/nonexistent returns HTTP 404
- Error response is clear with PROJECT_NOT_FOUND code
- No sensitive information leaked in error response
- Also verified Kanban board performance with 144 features (0.1ms scroll time)
- Screenshots captured for verification

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
rudiheydra added a commit to rudiheydra/AutoBuildr that referenced this pull request Jan 27, 2026
Feature AutoForgeAI#58: Budget Derivation from Task Complexity - VERIFIED

- All 110 unit tests pass
- All 9 verification steps pass
- No regressions in related tests (Feature AutoForgeAI#57)
- Progress: 77/103 features passing (74.8%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CoreAspectStu pushed a commit to CoreAspectStu/autocoder-custom that referenced this pull request Feb 9, 2026
fix: use ANTHROPIC_DEFAULT_OPUS_MODEL env var for model selection
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.

Incomplete: feat: add GLM/alternative API support via environment variables

2 participants