Fix AttributeError: property 'name' of 'LangChainChatProvider' object has no setter #1553

Closed
opened 2026-04-02 20:58:59 +00:00 by CoreRasurae · 1 comment
Member

Metadata

  • Commit Message: fix(provider): make LangChainChatProvider name and model_id mutable properties
  • Branch: fix/provider-immutable-properties

Background and Context

When running agents build on a plan created through agents tell, an AttributeError occurs: "property 'name' of 'LangChainChatProvider' object has no setter". This indicates a design mismatch between how LangChainChatProvider defines its properties and how PlanService attempts to use them.

Root Cause Analysis

File: src/cleveragents/providers/llm/langchain_chat_provider.py:78-84

The LangChainChatProvider class defines name and model_id as read-only properties:

@property
def name(self) -> str:
    return self._name

@property
def model_id(self) -> str:
    return self._model_id

File: src/cleveragents/application/services/plan_service.py:409-413

However, PlanService._resolve_ai_provider_for_actor() attempts to mutate these properties after object creation:

provider_instance_mutable = cast(Any, provider_instance)
if hasattr(provider_instance_mutable, "name"):
    provider_instance_mutable.name = provider_name  # ← AttributeError here
if hasattr(provider_instance_mutable, "model_id"):
    provider_instance_mutable.model_id = model_name  # ← AttributeError here

Current Behavior

  1. User creates a plan with agents tell -n "name" "description"
  2. User runs agents build
  3. PlanService resolves the AI provider and attempts to set its name and model_id properties
  4. AttributeError is raised because these properties lack setters
  5. The error is wrapped in a 500 INTERNAL server error

Expected Behavior

The provider's name and model_id properties should either:

  1. Be mutable (support property setters), OR
  2. Be set at provider instantiation time (preferred approach per specification-first development)

The system should handle provider name/model resolution without raising AttributeError.

Acceptance Criteria

  • The agents build command completes successfully without AttributeError
  • Provider name and model_id are correctly resolved and applied
  • No regression in existing provider functionality
  • The fix aligns with specification-first development principles (ADR-based architecture decisions)
  • All tests pass including unit, integration, and coverage thresholds

Supporting Information

  • Error Message: AttributeError: property 'name' of 'LangChainChatProvider' object has no setter
  • Error Location: src/cleveragents/application/services/plan_service.py:411 and 413
  • Related Code:
    • src/cleveragents/providers/llm/langchain_chat_provider.py (provider definition)
    • src/cleveragents/application/services/plan_service.py (consumer of provider)
    • src/cleveragents/providers/registry.py (provider factory)
  • CONTRIBUTING.md Reference: Lines 386-398 (Specification-First Development)

Subtasks

  • Analyze provider creation flow in ProviderRegistry.create_ai_provider() to determine where name/model_id should be set
  • Refactor provider instantiation to pass name and model_id at construction time (preferred approach)
  • Update LangChainChatProvider.__init__() to accept optional name/model_id override parameters if needed
  • Remove the post-creation property mutation code from PlanService._resolve_ai_provider_for_actor()
  • Update all provider subclasses (AnthropicChatProvider, GoogleChatProvider, OpenAIChatProvider, OpenRouterChatProvider) if applicable
  • Tests (Behave): Add scenarios for provider name/model_id resolution in plan build workflow
  • Tests (Robot): Add integration test for complete agents tell + agents build workflow
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All CI checks pass (tests, linting, type checking, security scanning, coverage >=97%)
  • The agents build command works end-to-end without AttributeError
## Metadata - **Commit Message**: `fix(provider): make LangChainChatProvider name and model_id mutable properties` - **Branch**: `fix/provider-immutable-properties` ## Background and Context When running `agents build` on a plan created through `agents tell`, an AttributeError occurs: "property 'name' of 'LangChainChatProvider' object has no setter". This indicates a design mismatch between how `LangChainChatProvider` defines its properties and how `PlanService` attempts to use them. ## Root Cause Analysis **File**: `src/cleveragents/providers/llm/langchain_chat_provider.py:78-84` The `LangChainChatProvider` class defines `name` and `model_id` as read-only properties: ```python @property def name(self) -> str: return self._name @property def model_id(self) -> str: return self._model_id ``` **File**: `src/cleveragents/application/services/plan_service.py:409-413` However, `PlanService._resolve_ai_provider_for_actor()` attempts to mutate these properties after object creation: ```python provider_instance_mutable = cast(Any, provider_instance) if hasattr(provider_instance_mutable, "name"): provider_instance_mutable.name = provider_name # ← AttributeError here if hasattr(provider_instance_mutable, "model_id"): provider_instance_mutable.model_id = model_name # ← AttributeError here ``` ## Current Behavior 1. User creates a plan with `agents tell -n "name" "description"` 2. User runs `agents build` 3. `PlanService` resolves the AI provider and attempts to set its `name` and `model_id` properties 4. `AttributeError` is raised because these properties lack setters 5. The error is wrapped in a 500 INTERNAL server error ## Expected Behavior The provider's `name` and `model_id` properties should either: 1. Be mutable (support property setters), OR 2. Be set at provider instantiation time (preferred approach per specification-first development) The system should handle provider name/model resolution without raising AttributeError. ## Acceptance Criteria - [ ] The `agents build` command completes successfully without AttributeError - [ ] Provider name and model_id are correctly resolved and applied - [ ] No regression in existing provider functionality - [ ] The fix aligns with specification-first development principles (ADR-based architecture decisions) - [ ] All tests pass including unit, integration, and coverage thresholds ## Supporting Information - **Error Message**: `AttributeError: property 'name' of 'LangChainChatProvider' object has no setter` - **Error Location**: `src/cleveragents/application/services/plan_service.py:411` and `413` - **Related Code**: - `src/cleveragents/providers/llm/langchain_chat_provider.py` (provider definition) - `src/cleveragents/application/services/plan_service.py` (consumer of provider) - `src/cleveragents/providers/registry.py` (provider factory) - **CONTRIBUTING.md Reference**: Lines 386-398 (Specification-First Development) ## Subtasks - [ ] Analyze provider creation flow in `ProviderRegistry.create_ai_provider()` to determine where name/model_id should be set - [ ] Refactor provider instantiation to pass `name` and `model_id` at construction time (preferred approach) - [ ] Update `LangChainChatProvider.__init__()` to accept optional name/model_id override parameters if needed - [ ] Remove the post-creation property mutation code from `PlanService._resolve_ai_provider_for_actor()` - [ ] Update all provider subclasses (AnthropicChatProvider, GoogleChatProvider, OpenAIChatProvider, OpenRouterChatProvider) if applicable - [ ] Tests (Behave): Add scenarios for provider name/model_id resolution in plan build workflow - [ ] Tests (Robot): Add integration test for complete `agents tell` + `agents build` workflow - [ ] Verify coverage >=97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All CI checks pass (tests, linting, type checking, security scanning, coverage >=97%) - The `agents build` command works end-to-end without AttributeError
CoreRasurae added this to the v3.2.0 milestone 2026-04-02 21:05:46 +00:00
Owner

Closing — work completed in PR #1558 (merged). The PR made LangChainChatProvider name and model_id properties settable, resolving the AttributeError during agents build.


Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

Closing — work completed in PR #1558 (merged). The PR made `LangChainChatProvider` name and model_id properties settable, resolving the AttributeError during `agents build`. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#1553
No description provided.