feat(agents): configurable LLM model + effort per-agent and per-project (ORCH-41) (#36)
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit was merged in pull request #36.
This commit is contained in:
@@ -17,7 +17,7 @@ registry is used so the system works out of the box.
|
||||
|
||||
import json
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from .config import settings
|
||||
|
||||
@@ -30,6 +30,11 @@ class ProjectConfig:
|
||||
repo: str # gitea repo name (== folder under /repos)
|
||||
work_item_prefix: str # ET / ORCH
|
||||
name: str # human-readable label
|
||||
# ORCH-41: optional per-project agent->model / agent->effort overrides parsed
|
||||
# from projects_json. frozen dataclass + mutable default -> field(default_factory=dict)
|
||||
# (a bare {} default raises ValueError). Empty dict = no override (old records work).
|
||||
agent_models: dict = field(default_factory=dict)
|
||||
agent_efforts: dict = field(default_factory=dict)
|
||||
|
||||
|
||||
# Built-in default registry (used when ORCH_PROJECTS_JSON is empty/invalid).
|
||||
@@ -50,6 +55,23 @@ _DEFAULT_PROJECTS = [
|
||||
]
|
||||
|
||||
|
||||
def _coerce_str_map(value, idx, field_name) -> dict:
|
||||
"""ORCH-41: coerce an optional projects_json sub-object into a {str: str} dict.
|
||||
|
||||
Missing / null -> {} (no override). A non-object value is logged and dropped so
|
||||
one malformed entry can never brick the whole registry; non-string keys/values
|
||||
are stringified for safety.
|
||||
"""
|
||||
if value is None:
|
||||
return {}
|
||||
if not isinstance(value, dict):
|
||||
logger.error(
|
||||
f"ORCH_PROJECTS_JSON[{idx}].{field_name} is not an object, ignoring"
|
||||
)
|
||||
return {}
|
||||
return {str(k): str(v) for k, v in value.items()}
|
||||
|
||||
|
||||
def _parse_projects_json(raw: str) -> list[ProjectConfig] | None:
|
||||
"""Parse ORCH_PROJECTS_JSON. Returns None if empty/invalid (-> use default)."""
|
||||
if not raw or not raw.strip():
|
||||
@@ -75,6 +97,8 @@ def _parse_projects_json(raw: str) -> list[ProjectConfig] | None:
|
||||
repo=str(item["repo"]),
|
||||
work_item_prefix=str(item["work_item_prefix"]),
|
||||
name=str(item.get("name", item["repo"])),
|
||||
agent_models=_coerce_str_map(item.get("agent_models"), i, "agent_models"),
|
||||
agent_efforts=_coerce_str_map(item.get("agent_efforts"), i, "agent_efforts"),
|
||||
)
|
||||
)
|
||||
except KeyError as e:
|
||||
|
||||
Reference in New Issue
Block a user