recovered snapshot from suspended aaronjaworski710 (history unavailable)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""Пример: супервизор кодинг-агента (паттерн thruwire/foreman).
|
||||
После каждого шага агента Jev решает: continue / retry / verify / stop."""
|
||||
import sys, os
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from jev_client import decide
|
||||
|
||||
CRITERIA = {
|
||||
'continue': 'Шаг успешен, план выполняется — давай агенту следующий шаг',
|
||||
'retry': 'Шаг упал по исправимой причине (таймаут, синтаксис, flaky-тест) — повтори с корректировкой',
|
||||
'verify': 'Результат неоднозначен — сначала проверь (тесты/линтер/запуск), потом решай',
|
||||
'stop': 'Агент зациклился, исчерпал бюджет или задача не сходится — останови и эскалируй человеку',
|
||||
}
|
||||
|
||||
def supervise(goal: str, step_log: str, attempt: int) -> dict:
|
||||
r = decide(state=f"Agent goal: {goal}\nAttempt #{attempt}\nLatest step log:\n{step_log[-4000:]}",
|
||||
questions={
|
||||
'next': {'type': 'choice', 'instructions': 'What should the supervising layer do next?',
|
||||
'criteria': CRITERIA},
|
||||
'stuck': {'type': 'noul', 'instructions': 'Is the agent stuck in a loop (repeating same failing action)?'},
|
||||
'progress': {'type': 'score', 'instructions': 'Rate overall progress toward the goal',
|
||||
'criteria': ['no progress', 'minor', 'halfway', 'mostly done', 'done']},
|
||||
})
|
||||
a = r['answers']
|
||||
return {'next': a['next']['choice'], 'stuck': a['stuck']['noul'] > 0.5,
|
||||
'progress': a['progress']['score'], 'confidence': a['next'].get('confidence')}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
log = 'ran pytest: 3 failed, 12 passed. Failure: AssertionError in test_parse_config (same as attempt 1 and 2)'
|
||||
print(supervise('починить парсер конфига', log, attempt=3))
|
||||
Reference in New Issue
Block a user