A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
remove bundled orchestration heartbeat skill (#523)
kt3797e8170799
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.mdindex c5f6ca12d0..00bf398afa 100644--- a/packages/coding-agent/CHANGELOG.md+++ b/packages/coding-agent/CHANGELOG.md@@ -2,6 +2,7 @@## [Unreleased]+- Removed the bundled orchestration heartbeat skill from the model system prompt.- Fixed feature hints crowding queued messages and side questions by placing them below the recap and hiding them while messages are queued ([ENG-4741](https://linear.app/primeintellect/issue/ENG-4741/recap-queuefollow-upmessage-hint-looks-cluttered)).- Fixed `/btw` truncating long answers by rendering side questions in the scrollable transcript.- Changed selection cursors from `→` to `›` across model selectors, scoped-models, and the theme default for consistency with tree and user-message selectors.diff --git a/packages/coding-agent/skills/orchestration-heartbeat/SKILL.md b/packages/coding-agent/skills/orchestration-heartbeat/SKILL.mddeleted file mode 100644index 41b3846b63..0000000000--- a/packages/coding-agent/skills/orchestration-heartbeat/SKILL.md+++ /dev/null@@ -1,41 +0,0 @@-----name: orchestration-heartbeat-description: Initialize or refresh an internal orchestrator heartbeat that observes active Prime Agent sessions, summarizes progress and blockers, and recommends next actions or messages.------# Orchestration Heartbeat--Use this skill from an orchestrator session to create or refresh a recurring-internal heartbeat for supervising multiple active Prime Agent sessions.--The heartbeat is an RLM heartbeat, not the user's visible `/heartbeat`. It-cannot read, replace, pause, resume, or clear the user-level heartbeat.--Call directly from IPython:--```python-await orchestration_heartbeat.initialize()-await orchestration_heartbeat.initialize(interval="10m", focus="EmulatorBench and AutoEnv")-```--## API--- `await orchestration_heartbeat.initialize(interval="5m", label="orchestrator",- focus=None, require_user_approval=True)` creates or updates the labeled- orchestrator heartbeat for the current session.-- `await orchestration_heartbeat.ensure(...)` is an alias for `initialize`.-- `orchestration_heartbeat.build_instruction(...)` returns the prompt text- without creating or updating a heartbeat.--## Heartbeat Behavior--Each recurring orchestration heartbeat should:--- Inspect active sessions with `agent_observe`.-- Summarize each relevant session as `active`, `waiting`, `blocked`, `error`,- or `completed`.-- Include current progress and explicit blockers.-- Recommend the next action and, when useful, draft a target message.-- Ask for user approval before sending cross-session messages unless the user- has already approved that specific messaging policy.-- Keep the update compact and operational instead of dumping logs.diff --git a/packages/coding-agent/skills/orchestration-heartbeat/pyproject.toml b/packages/coding-agent/skills/orchestration-heartbeat/pyproject.tomldeleted file mode 100644index 78d516c462..0000000000--- a/packages/coding-agent/skills/orchestration-heartbeat/pyproject.toml+++ /dev/null@@ -1,13 +0,0 @@-[project]-name = "orchestration-heartbeat"-version = "0.1.0"-description = "Prime Agent orchestration heartbeat skill"-requires-python = ">=3.10"-dependencies = ["agent-observe", "rlm-heartbeat"]--[build-system]-requires = ["hatchling"]-build-backend = "hatchling.build"--[tool.hatch.build.targets.wheel]-packages = ["src/orchestration_heartbeat"]diff --git a/packages/coding-agent/skills/orchestration-heartbeat/src/orchestration_heartbeat/__init__.py b/packages/coding-agent/skills/orchestration-heartbeat/src/orchestration_heartbeat/__init__.pydeleted file mode 100644index b58e485413..0000000000--- a/packages/coding-agent/skills/orchestration-heartbeat/src/orchestration_heartbeat/__init__.py+++ /dev/null@@ -1,206 +0,0 @@-"""Prime Agent orchestration heartbeat skill.--This skill composes the bundled agent_observe and rlm_heartbeat skills. It-creates or refreshes one internal heartbeat for the current orchestrator-session; it never touches the user's visible /heartbeat.-"""--from __future__ import annotations--from typing import Any--import agent_observe-import rlm_heartbeat--DEFAULT_INTERVAL = "5m"-DEFAULT_LABEL = "orchestrator"---def _first_value(agent: dict[str, Any], *keys: str) -> Any:- for key in keys:- value = agent.get(key)- if value is not None:- return value- return None---def _safe_field(value: Any) -> str | None:- if value is None:- return None- text = str(value)- sanitized = "".join(" " if ord(char) < 32 or ord(char) == 127 else char for char in text)- sanitized = " ".join(sanitized.split())- return sanitized or None---def _session_label(agent: dict[str, Any]) -> str:- name = _safe_field(_first_value(agent, "sessionName", "name"))- session_id = _safe_field(_first_value(agent, "sessionId", "session_id"))- active_session_id = _safe_field(_first_value(agent, "activeSessionId", "active_session_id"))- cwd = _safe_field(agent.get("cwd"))- status = _safe_field(agent.get("status"))- streaming = _safe_field(_first_value(agent, "isStreaming", "streaming"))- pending = _safe_field(_first_value(agent, "pendingMessageCount", "pending_message_count"))- parts = [- f"name={name}" if name else None,- f"session_id={session_id}" if session_id else None,- f"active_session_id={active_session_id}" if active_session_id else None,- f"cwd={cwd}" if cwd else None,- f"status={status}" if status else None,- f"streaming={streaming}" if streaming is not None else None,- f"pending_messages={pending}" if pending is not None else None,- ]- return "- " + ", ".join(part for part in parts if part)---def _format_sessions(agents: list[dict[str, Any]]) -> str:- if not agents:- return "- No other active sessions were visible when this heartbeat was initialized."- return "\n".join(_session_label(agent) for agent in agents)---def _same_session(left: dict[str, Any], right: dict[str, Any]) -> bool:- for keys in (- ("activeSessionId", "active_session_id"),- ("sessionId", "session_id"),- ):- left_value = _first_value(left, *keys)- right_value = _first_value(right, *keys)- if left_value is not None and right_value is not None and left_value == right_value:- return True- return False---def _other_agents(roster: dict[str, Any]) -> list[dict[str, Any]]:- agents = roster.get("agents", [])- if not isinstance(agents, list):- return []- current = roster.get("current")- if not isinstance(current, dict):- return agents- return [agent for agent in agents if not _same_session(agent, current)]---def _normalize_interval_expression(value: str) -> str:- normalized = " ".join(value.strip().lower().split())- if normalized.startswith("every "):- return normalized[6:].strip()- return normalized---def _interval_matches_schedule(interval: str, schedule: Any) -> bool:- if not isinstance(schedule, dict):- return False- expression = schedule.get("expression")- if not isinstance(expression, str):- return False- return _normalize_interval_expression(expression) == _normalize_interval_expression(interval)---def build_instruction(- sessions: list[dict[str, Any]] | None = None,- focus: str | None = None,- require_user_approval: bool = True,-) -> str:- """Build the recurring orchestration heartbeat instruction."""- if sessions is not None and not isinstance(sessions, list):- raise TypeError(f"sessions must be list or None, got {type(sessions).__name__}")- if focus is not None and not isinstance(focus, str):- raise TypeError(f"focus must be str or None, got {type(focus).__name__}")- if not isinstance(require_user_approval, bool):- raise TypeError(- f"require_user_approval must be bool, got {type(require_user_approval).__name__}"- )-- session_block = _format_sessions(sessions or [])- focus_line = f"\nCurrent focus: {focus.strip()}\n" if focus and focus.strip() else ""- approval_rule = (- "Do not send cross-session messages until the user approves the specific target and message, "- "unless the user has already granted an explicit messaging policy for this run."- if require_user_approval- else "You may send cross-session messages when they are clearly necessary and within the user's policy."- )-- return f"""Orchestration heartbeat.--Use agent_observe to inspect active Prime Agent sessions. For each relevant session, summarize:-- state: active, waiting, blocked, error, or completed-- current progress-- explicit blockers, separating task blockers from auth/tooling/infrastructure blockers-- recommended next action--If a session needs intervention, recommend the exact action and draft the target message. {approval_rule}--Keep the update compact and operational. Prefer session-by-session status over log detail. If a session's status is ambiguous, say what evidence is missing and what to inspect next.-{focus_line}-Sessions visible when this heartbeat was initialized or refreshed:-{session_block}--Before finalizing the heartbeat update, check whether new active sessions appeared since initialization and include them in the summary."""---async def initialize(- interval: str = DEFAULT_INTERVAL,- label: str = DEFAULT_LABEL,- focus: str | None = None,- require_user_approval: bool = True,-) -> dict[str, Any]:- """Create or update this session's internal orchestrator heartbeat."""- if not isinstance(interval, str):- raise TypeError(f"interval must be str, got {type(interval).__name__}")- if not isinstance(label, str):- raise TypeError(f"label must be str, got {type(label).__name__}")-- roster = await agent_observe.list_agents()- agents = _other_agents(roster)- instruction = build_instruction(- sessions=agents,- focus=focus,- require_user_approval=require_user_approval,- )- existing = await rlm_heartbeat.list(include_inactive=False)- for heartbeat in existing.get("heartbeats", []):- if heartbeat.get("label") == label:- update_args: dict[str, Any] = {- "instruction": instruction,- "label": label,- }- if heartbeat.get("status") == "paused":- update_args["status"] = "resume"- if not _interval_matches_schedule(interval, heartbeat.get("schedule")):- update_args["interval"] = interval- updated = await rlm_heartbeat.update(heartbeat["id"], **update_args)- updated_heartbeat = updated.get("heartbeat")- if updated_heartbeat is None:- raise RuntimeError(- f"RLM heartbeat {heartbeat['id']} disappeared before it could be updated"- )- return {- "action": "updated",- "heartbeat": updated_heartbeat,- "sessions": agents,- "instruction": instruction,- }-- created = await rlm_heartbeat.create(instruction, interval=interval, label=label)- return {- "action": "created",- "heartbeat": created.get("heartbeat"),- "sessions": agents,- "instruction": instruction,- }---async def ensure(- interval: str = DEFAULT_INTERVAL,- label: str = DEFAULT_LABEL,- focus: str | None = None,- require_user_approval: bool = True,-) -> dict[str, Any]:- """Alias for initialize()."""- return await initialize(- interval=interval,- label=label,- focus=focus,- require_user_approval=require_user_approval,- )diff --git a/packages/coding-agent/test/agent-session-services.test.ts b/packages/coding-agent/test/agent-session-services.test.tsindex 3b1cc0b4ea..8a292bb987 100644--- a/packages/coding-agent/test/agent-session-services.test.ts+++ b/packages/coding-agent/test/agent-session-services.test.ts@@ -4,14 +4,9 @@ import { join } from "node:path";import { registerFauxProvider } from "@earendil-works/pi-ai";import { afterEach, describe, expect, it } from "vitest";import { AGENT_MESSAGE_SKILL_NAME, type AgentSessionMessageController } from "../src/core/agent-messages.js";-import {- AGENT_OBSERVE_SKILL_NAME,- type AgentObserveController,- ORCHESTRATION_HEARTBEAT_SKILL_NAME,-} from "../src/core/agent-observe.js";+import { AGENT_OBSERVE_SKILL_NAME, type AgentObserveController } from "../src/core/agent-observe.js";import { createAgentSessionFromServices, createAgentSessionServices } from "../src/core/agent-session-services.js";import { AuthStorage } from "../src/core/auth-storage.js";-import type { AgentRlmHeartbeatController } from "../src/core/cron-jobs.js";import { SessionManager } from "../src/core/session-manager.js";import { createSyntheticSourceInfo } from "../src/core/source-info.js";@@ -161,7 +156,6 @@ describe("createAgentSessionFromServices", () => {try {expect(visibleSkillNames(withoutControllers)).not.toContain(AGENT_MESSAGE_SKILL_NAME);expect(visibleSkillNames(withoutControllers)).not.toContain(AGENT_OBSERVE_SKILL_NAME);- expect(visibleSkillNames(withoutControllers)).not.toContain(ORCHESTRATION_HEARTBEAT_SKILL_NAME);} finally {withoutControllers.dispose();}@@ -190,27 +184,13 @@ describe("createAgentSessionFromServices", () => {throw new Error("not used");},};- const rlmHeartbeatController: AgentRlmHeartbeatController = {- listRlmHeartbeats: () => [],- createRlmHeartbeat: () => {- throw new Error("not used");- },- updateRlmHeartbeat: () => {- throw new Error("not used");- },- deleteRlmHeartbeat: () => {- throw new Error("not used");- },- };const withControllers = await createSession({services,sessionManager: SessionManager.create(tempDir, join(tempDir, "sessions-with")),agentObserveController,- rlmHeartbeatController,});try {expect(visibleSkillNames(withControllers)).toContain(AGENT_OBSERVE_SKILL_NAME);- expect(visibleSkillNames(withControllers)).toContain(ORCHESTRATION_HEARTBEAT_SKILL_NAME);expect(visibleSkillNames(withControllers)).not.toContain(AGENT_MESSAGE_SKILL_NAME);} finally {withControllers.dispose();diff --git a/packages/coding-agent/test/builtin-skills.test.ts b/packages/coding-agent/test/builtin-skills.test.tsindex 2e4d6c00ab..44eddc6884 100644--- a/packages/coding-agent/test/builtin-skills.test.ts+++ b/packages/coding-agent/test/builtin-skills.test.ts@@ -254,15 +254,10 @@ describe("builtin skills", () => {expect(rlmHeartbeat?.kind === "python" && rlmHeartbeat.python.importName).toBe("rlm_heartbeat");});- it("loads the bundled orchestration heartbeat skill as a python skill", () => {+ it("does not ship orchestration heartbeat as a built-in skill", () => {const { skills } = loadSkillsFromDir({ dir: getBundledSkillsDir(), source: "builtin" });- const orchestrationHeartbeat = skills.find((s) => s.name === "orchestration-heartbeat");- expect(orchestrationHeartbeat).toBeDefined();- expect(orchestrationHeartbeat?.kind).toBe("python");- expect(orchestrationHeartbeat?.kind === "python" && orchestrationHeartbeat.python.importName).toBe(- "orchestration_heartbeat",- );+ expect(skills.map((skill) => skill.name)).not.toContain("orchestration-heartbeat");});it("ships the edit skill as a python skill importable as `edit`", () => {diff --git a/packages/coding-agent/test/kernel-orchestration-heartbeat-skill.test.ts b/packages/coding-agent/test/kernel-orchestration-heartbeat-skill.test.tsdeleted file mode 100644index 308538117d..0000000000--- a/packages/coding-agent/test/kernel-orchestration-heartbeat-skill.test.ts+++ /dev/null@@ -1,260 +0,0 @@-import { mkdirSync, rmSync } from "node:fs";-import { tmpdir } from "node:os";-import { join } from "node:path";-import { afterEach, beforeEach, describe, expect, it } from "vitest";-import { getBundledSkillsDir } from "../src/config.js";-import type { PythonSkillRuntimeInfo } from "../src/core/skills.js";-import { IpythonKernelProvisioner } from "../src/core/tools/ipython.js";--function bundledPythonSkill(name: string, importName: string): PythonSkillRuntimeInfo {- const packagePath = join(getBundledSkillsDir(), name);- return {- name,- importName,- packagePath,- pyprojectPath: join(packagePath, "pyproject.toml"),- };-}--describe("orchestration heartbeat skill over bundled host bridges", () => {- let tempDir: string;- let provisioner: IpythonKernelProvisioner | undefined;-- beforeEach(() => {- tempDir = join(tmpdir(), `pi-orchestration-heartbeat-skill-${Date.now()}-${Math.random().toString(36).slice(2)}`);- mkdirSync(tempDir, { recursive: true });- });-- afterEach(async () => {- await provisioner?.dispose();- provisioner = undefined;- rmSync(tempDir, { recursive: true, force: true });- });-- it("creates then refreshes a labeled RLM heartbeat from active session observations", async () => {- const requests: Array<{ type: string; payload: Record<string, unknown> }> = [];- let hasHeartbeat = false;- let missingOnce = false;- let scheduleExpression = "every 5m";-- provisioner = new IpythonKernelProvisioner(tempDir, {- pythonSkills: [bundledPythonSkill("orchestration-heartbeat", "orchestration_heartbeat")],- hostHandlers: {- "agent_observe.list": async (payload) => {- requests.push({ type: "agent_observe.list", payload });- return {- current: { sessionName: "orch", sessionId: "sess-orch", activeSessionId: "active-orch" },- agents: [- {- sessionName: "orch",- sessionId: "sess-orch",- activeSessionId: "active-orch",- cwd: "/repo/orch",- status: "idle",- isStreaming: false,- pendingMessageCount: 0,- },- {- sessionName: "autoenv",- sessionId: "sess-autoenv",- activeSessionId: "active-autoenv",- cwd: "/repo/autoenv",- status: "tool",- isStreaming: false,- pendingMessageCount: 1,- },- {- sessionName: "emulatorBench",- sessionId: "sess-emulator",- activeSessionId: "active-emulator",- cwd: "/repo/emulator",- status: "idle",- isStreaming: false,- pendingMessageCount: 0,- },- ],- };- },- "rlm_heartbeat.list": async (payload) => {- requests.push({ type: "rlm_heartbeat.list", payload });- return {- heartbeats: hasHeartbeat- ? [- {- id: "job-orch",- status: "active",- label: "orchestrator",- instruction: "old instruction",- schedule: { kind: "interval", expression: scheduleExpression },- },- {- id: "job-missing",- status: "active",- label: "missing-on-update",- instruction: "old instruction",- schedule: { kind: "interval", expression: scheduleExpression },- },- {- id: "job-paused",- status: "paused",- label: "paused-orchestrator",- instruction: "old instruction",- schedule: { kind: "interval", expression: scheduleExpression },- },- {- id: "job-plain",- status: "active",- label: "plain-schedule",- instruction: "old instruction",- schedule: { kind: "interval", expression: "10m" },- },- ]- : [],- };- },- "rlm_heartbeat.create": async (payload) => {- requests.push({ type: "rlm_heartbeat.create", payload });- hasHeartbeat = true;- scheduleExpression = String(payload.interval ?? "5m").startsWith("every ")- ? String(payload.interval)- : `every ${payload.interval ?? "5m"}`;- return {- heartbeat: {- id: "job-orch",- status: "active",- label: payload.label,- instruction: payload.instruction,- schedule: { kind: "interval", expression: scheduleExpression },- },- };- },- "rlm_heartbeat.update": async (payload) => {- requests.push({ type: "rlm_heartbeat.update", payload });- if (payload.label === "missing-on-update" && !missingOnce) {- missingOnce = true;- return { heartbeat: null };- }- if (payload.interval) {- scheduleExpression = String(payload.interval).startsWith("every ")- ? String(payload.interval)- : `every ${payload.interval}`;- }- return {- heartbeat: {- id: payload.id,- status: "active",- label: payload.label,- instruction: payload.instruction,- schedule: { kind: "interval", expression: scheduleExpression },- },- };- },- },- });-- const manager = await provisioner.ensure();- const result = await manager.execute(`-import json-created = await orchestration_heartbeat.initialize(focus="keep long-running sessions moving")-updated = await orchestration_heartbeat.initialize(interval="10m")-try:- await orchestration_heartbeat.initialize(interval="10m", label="missing-on-update")-except RuntimeError as error:- missing_once_error = str(error)-paused = await orchestration_heartbeat.initialize(interval="10m", label="paused-orchestrator")-refreshed = await orchestration_heartbeat.initialize(interval="10m")-plain = await orchestration_heartbeat.initialize(interval="every 10m", label="plain-schedule")-print(json.dumps({- "created_action": created["action"],- "updated_action": updated["action"],- "missing_once_error": missing_once_error,- "paused_action": paused["action"],- "refreshed_action": refreshed["action"],- "plain_action": plain["action"],- "created_label": created["heartbeat"]["label"],- "updated_label": updated["heartbeat"]["label"],- "session_names": [agent.get("sessionName") for agent in updated["sessions"]],- "instruction": updated["instruction"],-}, sort_keys=True))-`);-- expect(result.status).toBe("ok");- const output = JSON.parse(result.stdout.trim());- expect(output).toMatchObject({- created_action: "created",- updated_action: "updated",- paused_action: "updated",- refreshed_action: "updated",- plain_action: "updated",- created_label: "orchestrator",- updated_label: "orchestrator",- session_names: ["autoenv", "emulatorBench"],- });- expect(output.missing_once_error).toContain("RLM heartbeat job-missing disappeared");- expect(output.instruction).toContain("Use agent_observe to inspect active Prime Agent sessions");- expect(output.instruction).toContain("recommend the exact action and draft the target message");- expect(output.instruction).toContain("Do not send cross-session messages until the user approves");- expect(output.instruction).not.toContain("name=orch");- expect(output.instruction).toContain("name=autoenv");- expect(output.instruction).toContain("session_id=sess-autoenv");- expect(output.instruction).toContain("active_session_id=active-autoenv");- expect(output.instruction).toContain("streaming=False");- expect(output.instruction).toContain("pending_messages=1");- expect(requests.map((request) => request.type)).toEqual([- "agent_observe.list",- "rlm_heartbeat.list",- "rlm_heartbeat.create",- "agent_observe.list",- "rlm_heartbeat.list",- "rlm_heartbeat.update",- "agent_observe.list",- "rlm_heartbeat.list",- "rlm_heartbeat.update",- "agent_observe.list",- "rlm_heartbeat.list",- "rlm_heartbeat.update",- "agent_observe.list",- "rlm_heartbeat.list",- "rlm_heartbeat.update",- "agent_observe.list",- "rlm_heartbeat.list",- "rlm_heartbeat.update",- ]);- expect(requests[2].payload).toMatchObject({- type: "rlm_heartbeat.create",- interval: "5m",- label: "orchestrator",- });- expect(requests[5].payload).toMatchObject({- type: "rlm_heartbeat.update",- id: "job-orch",- interval: "10m",- label: "orchestrator",- });- expect(requests[5].payload).not.toHaveProperty("status");- expect(requests[8].payload).toMatchObject({- type: "rlm_heartbeat.update",- id: "job-missing",- label: "missing-on-update",- });- expect(requests[11].payload).toMatchObject({- type: "rlm_heartbeat.update",- id: "job-paused",- label: "paused-orchestrator",- status: "resume",- });- expect(requests[14].payload).toMatchObject({- type: "rlm_heartbeat.update",- id: "job-orch",- label: "orchestrator",- });- expect(requests[14].payload).not.toHaveProperty("interval");- expect(requests[14].payload).not.toHaveProperty("status");- expect(requests[17].payload).toMatchObject({- type: "rlm_heartbeat.update",- id: "job-plain",- label: "plain-schedule",- });- expect(requests[17].payload).not.toHaveProperty("interval");- });-});