heartbeat

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Heartbeat Orchestrator

Heartbeat 编排器

The Heartbeat skill acts as the background processor for the Agentic OS. It reads the
.agent/state/tasks.json
queue, identifies pending tasks, routes them to the appropriate skills, and updates the task status upon completion.
Heartbeat技能是Agentic OS的后台处理器。它读取
.agent/state/tasks.json
队列,识别待处理任务,将其路由到对应的技能,并在任务完成后更新状态。

How it works

工作原理

Use the
heartbeat.py
script included in this skill's
scripts/
directory to manage the queue:
  1. Pop Task: Run
    python3 ~/.gemini/skills/heartbeat/scripts/heartbeat.py pop
    (for Gemini/Antigravity) or
    python3 ~/.claude/skills/heartbeat/scripts/heartbeat.py pop
    (for Claude) to get the highest priority pending task and move it to
    in_progress
    .
  2. Execute: Read the task details and use the appropriate skill (e.g.,
    osint
    ,
    deep-research
    ) to fulfill the task.
  3. Resilience & Retry: If a task fails unexpectedly, autonomous agents MUST attempt to retry the task logic up to two times before formally failing.
  4. Complete/Fail: Run
    python3 ~/.gemini/skills/heartbeat/scripts/heartbeat.py complete <task_id> --outcome '{"result": "..."}' --trace-id <id> --decision-log "..."
    or
    python3 ~/.gemini/skills/heartbeat/scripts/heartbeat.py fail <task_id> --reason "..." --trace-id <id>
    (adjust path for Claude) to update the task status. Failing a task automatically logs the failure to
    .agent/state/errors.json
    so the Command Center can track unresolved issues.
使用本技能
scripts/
目录下的
heartbeat.py
脚本管理队列:
  1. 取出任务:运行
    python3 ~/.gemini/skills/heartbeat/scripts/heartbeat.py pop
    (适用于Gemini/Antigravity)或
    python3 ~/.claude/skills/heartbeat/scripts/heartbeat.py pop
    (适用于Claude),获取优先级最高的待处理任务并将其移至
    in_progress
    状态。
  2. 执行任务:读取任务详情,使用对应的技能(如
    osint
    deep-research
    )完成任务。
  3. 弹性与重试:若任务意外失败,自主Agent必须尝试重试任务逻辑最多2次,之后才标记为正式失败。
  4. 完成/失败:运行
    python3 ~/.gemini/skills/heartbeat/scripts/heartbeat.py complete <task_id> --outcome '{"result": "..."}' --trace-id <id> --decision-log "..."
    python3 ~/.gemini/skills/heartbeat/scripts/heartbeat.py fail <task_id> --reason "..." --trace-id <id>
    (Claude需调整路径)来更新任务状态。标记任务失败会自动将失败信息记录到
    .agent/state/errors.json
    ,以便指挥中心追踪未解决问题。

Task Format

任务格式

The
tasks.json
should contain an object with status arrays:
json
{
  "pending": [
    {
      "id": "task-123",
      "priority": "high",
      "description": "Deep research the current state of local LLM orchestration.",
      "assigned_skill": "deep-research",
      "project_id": "claude-skills",
      "agent_id": "antigravity",
      "user_id": "matthias",
      "created_at": "2026-04-25T12:00:00Z",
      "completed_at": null
    }
  ],
  "in_progress": [],
  "completed": [],
  "failed": []
}
Statuses correspond to the array the task resides in.
tasks.json
应包含一个带有状态数组的对象:
json
{
  "pending": [
    {
      "id": "task-123",
      "priority": "high",
      "description": "Deep research the current state of local LLM orchestration.",
      "assigned_skill": "deep-research",
      "project_id": "claude-skills",
      "agent_id": "antigravity",
      "user_id": "matthias",
      "created_at": "2026-04-25T12:00:00Z",
      "completed_at": null
    }
  ],
  "in_progress": [],
  "completed": [],
  "failed": []
}
任务状态由其所在的数组决定。

Execution

执行机制

When invoked (or automatically on agent startup), the Heartbeat should process one task at a time to maintain stability and context length, unless explicitly asked to drain the queue.
当被调用(或Agent启动时自动触发)时,Heartbeat应一次处理一个任务以保持稳定性和上下文长度,除非明确要求清空队列。

Agentic OS Integration

Agentic OS 集成

As a core OS component, this skill MUST log its own execution to
.agent/state/last-run.json
, noting which task was processed and what the outcome was.
作为核心OS组件,本技能必须将自身执行情况记录到
.agent/state/last-run.json
,注明处理的任务及结果。