Tech Wiki

[Hermes Agent 실전 08] Hermes Cron과 백그라운드 작업 자동화

반복 작업을 에이전트에 맡기려면 schedule, input, delivery target, 실패 경계를 먼저 고정해야 합니다. Hermes Cron은 이 수명 주기를 관리합니다. background terminal process나 delegated child는 쓰임새가 다릅니다.

  • 현재 chat session이 끝나도 남아야 하는 작업에는 Cron을 씁니다.
  • 처음에는 local delivery와 paused job으로 시작합니다.
  • 한 번 수동 실행하고 출력을 살핀 뒤 schedule을 재개합니다.
  • 에이전트 판단이 필요 없는 수집 단계는 결정적으로 만듭니다.

1. Background 방식을 구분하기

Delegated child는 격리되지만 process-local입니다. parent와 나란히 실행할 수 있으나, 소유 session을 닫거나 Hermes를 재시작하면 취소될 수 있습니다. terminal background process는 끝이 정해진 단일 command에 알맞습니다. Cron은 job definition을 저장하고 Gateway 또는 Desktop scheduler가 나중에 실행하게 합니다.

매일 만드는 보고서, 주기적인 monitoring, 반복 수집에는 Cron을 선택하세요. 현재 parent로 돌아올 병렬 추론에는 delegation이 맞습니다. build나 migration처럼 종료 지점이 뚜렷한 명령에는 background terminal command를 사용합니다.

2. 수집과 판단을 분리하기

예제는 로컬 RSS fixture를 읽고 필수 필드를 검사한 다음, 날짜순으로 정렬해 안정적인 text를 출력합니다. 이 경계를 의도적으로 뒀습니다. script는 데이터를 수집하고 정규화할 수 있습니다. 해석이 필요할 때만 LLM 기반 Cron job이 요약을 맡으면 됩니다.

예제 디렉터리에서 collector를 실행하세요.

python3 collect_news.py fixtures/feed.xml --limit 2

예상 출력은 다음과 같습니다.

Hermes engineering briefing
- 2026-09-19 | Gateway reliability notes | https://example.invalid/gateway
- 2026-09-18 | Cron delivery patterns | https://example.invalid/cron

이 fixture는 public internet에 접속하지 않습니다. local path가 예측 가능하게 동작한 뒤에만 검토된 실제 data source로 바꾸세요.

3. 일시 정지된 local plan 만들기

곧바로 live schedule을 등록하지 말고 plan을 생성합니다.

python3 schedule_plan.py --output cron-plan.json

plan에는 평일 09:00 job의 정확한 argument vector가 들어 있습니다. --deliver local, --paused, --workdir를 설정하고 현재 예제 디렉터리를 absolute path로 해석합니다. work directory를 명시하면 project context와 상대 경로를 예측하기 쉽습니다.

Hermes는 interval, 5-field Cron expression, 상대 one-shot duration, ISO timestamp를 받습니다. 5-field expression은 machine의 local timezone을 사용합니다. host timezone을 짐작하지 말고 hermes cron list가 보여 주는 다음 실행 시각을 확인하세요.

4. 생성하고 한 번 실행하기

검토를 마친 command는 다음 형태입니다.

hermes cron create "0 9 * * 1-5" "Run the local collector and return its output without adding claims." --name engineering-briefing --deliver local --workdir "$PWD" --paused
hermes cron list
hermes cron run <job_id>

--paused는 검토 전에 schedule이 실행되는 일을 막습니다. hermes cron run은 즉시 실행을 요청합니다. 반복 실행을 켜기 전에 local result와 job state를 읽으세요.

Script stdout이 완성된 결과라면 --script--no-agent를 함께 씁니다. 이 mode에서는 Hermes가 model을 건너뛰고, 비어 있지 않은 stdout을 전달합니다. 빈 stdout은 silent tick으로 처리합니다. scheduler 요구 사항에 맞춰 script는 active Hermes home의 scripts directory 아래에 둡니다.

5. 수명 주기 운영하기

수동 실행이 원하는 text를 만들었다면 다음 명령을 사용합니다.

hermes cron resume <job_id>
hermes cron pause <job_id>
hermes cron remove <job_id>

Production input이나 prompt를 바꾸기 전에 pause하세요. history와 definition이 더 필요 없을 때만 job을 제거합니다. 현재 release에서는 hermes cron runs로 execution history를 보고 hermes cron doctor로 health check를 할 수 있습니다.

자동 실행에는 active Gateway 또는 Desktop backend가 필요합니다. 일반 CLI conversation만으로 scheduler ticker가 돌지는 않습니다. Schedule을 조정하는 동안에는 두 번째 failure surface를 피할 수 있는 local delivery가 가장 안전합니다.

6. 실패 경계 테스트하기

Fixture test는 날짜 정렬, 정확한 text output, 잘못된 limit, local-only paused plan을 검사합니다.

python3 -m unittest discover -s tests -v

잘못된 limit는 feed를 열기 전에 실패합니다. 무인 작업에서는 이 순서가 중요합니다. Input, network, delivery system에 손대기 전에 안전하지 않은 parameter를 거부해야 합니다.

실제 feed로 확장할 때는 제한된 network timeout, schema 검사, deduplication, 안정적인 output format을 추가하세요. Monitor script output에 timestamp를 넣으면 모든 tick이 변경된 것으로 보일 수 있습니다.

7. 예제의 한계 알기

이 예제는 local collection과 schedule construction을 증명합니다. Job 생성, Gateway 시작, model 호출, Telegram delivery는 수행하지 않습니다. 이런 작업은 독자의 active profile과 credential에 달려 있습니다.

Local run이 안정된 뒤 Telegram delivery로 옮기세요. 9편에서는 token을 노출하지 않는 Gateway diagnostic을 추가합니다. 마지막 Bot API 교환은 credential이 있는 환경에서 명시적으로 확인합니다.

출처


답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Tech Wiki

Built with WordPress · Learn in public.