feat(curator): restrict per-user config to archiving thresholds only
This commit is contained in:
1 parent
0a21d37146
commit
d713f0209d
1 file changed
+15
-14
@@ -2329,14 +2329,14 @@ class CuratorConfigResponse(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class CuratorConfigRequest(BaseModel):
|
class CuratorConfigRequest(BaseModel):
|
||||||
"""Payload for updating skill_evolution overrides.
|
"""Payload for updating per-user skill evolution overrides.
|
||||||
|
|
||||||
All fields are required so the frontend always sends a complete config;
|
Users may only adjust archiving thresholds. All other settings (enabled,
|
||||||
backend writes the entire payload to skill_evolution.json atomically.
|
interval, model, timeouts) are global and controlled via config.yaml.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
enabled: bool = Field(..., description="Whether the agent can create and modify skills under skills/custom.")
|
stale_after_days: int = Field(..., ge=1, description="Days of inactivity before a skill is marked stale.")
|
||||||
curator: CuratorSubConfig
|
archive_after_days: int = Field(..., ge=1, description="Days of inactivity before a stale skill is archived.")
|
||||||
|
|
||||||
|
|
||||||
class CuratorLogRecord(BaseModel):
|
class CuratorLogRecord(BaseModel):
|
||||||
@@ -2386,21 +2386,22 @@ async def get_curator_config(request: Request) -> CuratorConfigResponse:
|
|||||||
|
|
||||||
@router.put("/curator/config", response_model=CuratorConfigResponse, summary="Update Skill Evolution Config")
|
@router.put("/curator/config", response_model=CuratorConfigResponse, summary="Update Skill Evolution Config")
|
||||||
async def update_curator_config(body: CuratorConfigRequest, request: Request) -> CuratorConfigResponse:
|
async def update_curator_config(body: CuratorConfigRequest, request: Request) -> CuratorConfigResponse:
|
||||||
"""Persist per-user overrides to ``users/{user_id}/skill_evolution.json``
|
"""Persist per-user archiving thresholds to ``users/{user_id}/skill_evolution.json``.
|
||||||
and return the effective merged config.
|
|
||||||
|
|
||||||
The payload is validated against the ``SkillEvolutionConfig`` shape; unknown
|
Only ``stale_after_days`` and ``archive_after_days`` are user-editable.
|
||||||
fields are rejected.
|
All other settings (enabled, interval, model, timeouts) are global and
|
||||||
|
read from config.yaml; users cannot override them here.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from deerflow.config.skill_evolution_config import SkillEvolutionConfig
|
|
||||||
from deerflow.config.skill_evolution_runtime import load_skill_evolution_config_for_user, save_user_overrides
|
from deerflow.config.skill_evolution_runtime import load_skill_evolution_config_for_user, save_user_overrides
|
||||||
|
|
||||||
user_id = _current_user_id(request)
|
user_id = _current_user_id(request)
|
||||||
payload = body.model_dump()
|
save_user_overrides(user_id, {
|
||||||
# Round-trip through SkillEvolutionConfig to ensure persisted shape stays valid.
|
"curator": {
|
||||||
SkillEvolutionConfig.model_validate(payload)
|
"stale_after_days": body.stale_after_days,
|
||||||
save_user_overrides(user_id, payload)
|
"archive_after_days": body.archive_after_days,
|
||||||
|
}
|
||||||
|
})
|
||||||
return _build_curator_config_response(load_skill_evolution_config_for_user(user_id))
|
return _build_curator_config_response(load_skill_evolution_config_for_user(user_id))
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
raise
|
raise
|
||||||
|
|||||||
Reference in new issue
Block a user