Introduce Devii agents subsystem with supervisor, policy, and evals
- Add agents package: controller, runner, store, tools, actions, evals, policy - Wire agents into Devii service, session, registry, CLI, and dispatcher - Extend database schema and config for agent persistence - Add news and telegram bridge updates plus landing UI and docs - Cover agents, news, and telegram flows with unit tests
This commit is contained in:
@@ -170,6 +170,55 @@ def test_grade_article_unparseable_returns_none(local_db, monkeypatch):
|
||||
assert grade is None
|
||||
|
||||
|
||||
class FlakyGradeClient(FakeClient_news_service):
|
||||
def __init__(self, failures_before_success):
|
||||
super().__init__([])
|
||||
self.failures_before_success = failures_before_success
|
||||
self.posts = 0
|
||||
|
||||
async def post(self, url, json=None, headers=None, timeout=None):
|
||||
self.posts += 1
|
||||
if self.posts <= self.failures_before_success:
|
||||
return FakeResp_news_service(status=500, text="err")
|
||||
return FakeResp_news_service(
|
||||
json_data={"choices": [{"message": {"content": "8"}}]}
|
||||
)
|
||||
|
||||
|
||||
def test_grade_article_retries_transient_failures(local_db, monkeypatch):
|
||||
from devplacepy.services.news import GRADE_ATTEMPTS
|
||||
|
||||
monkeypatch.setattr(news_mod, "get_setting", _settings_stub())
|
||||
client = FlakyGradeClient(failures_before_success=2)
|
||||
grade = run_async(
|
||||
NewsService()._grade_article(
|
||||
{"title": "FlakyArticle", "description": "d", "content": "c"},
|
||||
AI_URL,
|
||||
"m",
|
||||
client,
|
||||
)
|
||||
)
|
||||
assert grade == 8
|
||||
assert client.posts == 3
|
||||
|
||||
|
||||
def test_grade_article_gives_up_after_max_attempts(local_db, monkeypatch):
|
||||
from devplacepy.services.news import GRADE_ATTEMPTS
|
||||
|
||||
monkeypatch.setattr(news_mod, "get_setting", _settings_stub())
|
||||
client = FlakyGradeClient(failures_before_success=GRADE_ATTEMPTS + 5)
|
||||
grade = run_async(
|
||||
NewsService()._grade_article(
|
||||
{"title": "FlakyArticle", "description": "d", "content": "c"},
|
||||
AI_URL,
|
||||
"m",
|
||||
client,
|
||||
)
|
||||
)
|
||||
assert grade is None
|
||||
assert client.posts == GRADE_ATTEMPTS
|
||||
|
||||
|
||||
def test_run_once_handles_api_failure(local_db, monkeypatch):
|
||||
monkeypatch.setattr(news_mod, "get_setting", _settings_stub())
|
||||
monkeypatch.setattr(base_mod, "get_setting", _settings_stub())
|
||||
|
||||
Reference in New Issue
Block a user