-
Notifications
You must be signed in to change notification settings - Fork 0
Adopt NotBlankStr across all models to eliminate redundant whitespace validators #108
Copy link
Copy link
Closed
Labels
prio:highImportant, should be prioritizedImportant, should be prioritizedscope:medium1-3 days of work1-3 days of worktype:refactorCode restructuring, cleanupCode restructuring, cleanup
Milestone
Description
Problem
core/types.py defines NotBlankStr — a validated string type that rejects empty/whitespace-only values:
NotBlankStr = Annotated[str, StringConstraints(min_length=1), AfterValidator(_check_not_whitespace)]But it's only used in providers/models.py. Meanwhile, core/agent.py has 6+ manual @model_validator methods doing the same whitespace check:
@model_validator(mode="after")
def _validate_name_not_blank(self) -> Self:
if not self.name.strip():
raise ValueError("name must not be blank")
return selfThis pattern repeats across AgentIdentity, PersonalityConfig, SkillSet, ModelConfig, MemoryConfig, ToolPermissions, and potentially other models.
Proposed Solution
Replace all str fields with min_length=1 + whitespace rejection with NotBlankStr:
# Before
name: str = Field(min_length=1)
@model_validator(mode="after")
def _validate_name_not_blank(self) -> Self:
...
# After
name: NotBlankStr = Field()
# No validator neededScope
Modules to audit and update:
core/agent.py(AgentIdentity, PersonalityConfig, SkillSet, ModelConfig, etc.)core/task.py(Task)config/schema.py(config models)templates/(template models)budget/(spending summary models — agent_id, department fields)providers/(already partially adopted)tools/base.py(BaseTool.name)
Acceptance Criteria
- All
strfields withmin_length=1that reject whitespace useNotBlankStr - Redundant
_validate_non_blank*/_validate_*_not_blankvalidators removed - Model validators that check other things (e.g., cross-field logic) are preserved
- All existing tests pass (may need minor error message adjustments)
- No net increase in line count
- Verify DESIGN_SPEC.md §3.1 NotBlankStr reference and CLAUDE.md Models convention remain consistent after implementation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
prio:highImportant, should be prioritizedImportant, should be prioritizedscope:medium1-3 days of work1-3 days of worktype:refactorCode restructuring, cleanupCode restructuring, cleanup