From fa91352430f81269a1d20b67456a2b7ecdd01432 Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Thu, 5 Feb 2026 23:06:59 +0530 Subject: [PATCH] feat: add agent name uniqueness check and enhance heartbeat guidelines for leads --- backend/app/api/agents.py | 16 +++++++++++++++- templates/HEARTBEAT_AGENT.md | 9 +++++++-- templates/HEARTBEAT_LEAD.md | 4 +++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/backend/app/api/agents.py b/backend/app/api/agents.py index ad13c6ac..2857fc00 100644 --- a/backend/app/api/agents.py +++ b/backend/app/api/agents.py @@ -193,7 +193,9 @@ def _with_computed_status(agent: Agent) -> Agent: def _serialize_agent(agent: Agent, main_session_keys: set[str]) -> dict[str, object]: - return _to_agent_read(_with_computed_status(agent), main_session_keys).model_dump() + return _to_agent_read( + _with_computed_status(agent), main_session_keys + ).model_dump(mode="json") def _fetch_agent_events( @@ -318,6 +320,18 @@ async def create_agent( board = _require_board(session, payload.board_id) gateway, client_config = _require_gateway(session, board) data = payload.model_dump() + requested_name = (data.get("name") or "").strip() + if requested_name: + existing = session.exec( + select(Agent) + .where(Agent.board_id == board.id) + .where(col(Agent.name).ilike(requested_name)) + ).first() + if existing: + raise HTTPException( + status_code=status.HTTP_409_CONFLICT, + detail="An agent with this name already exists on this board.", + ) if data.get("identity_template") == "": data["identity_template"] = None if data.get("soul_template") == "": diff --git a/templates/HEARTBEAT_AGENT.md b/templates/HEARTBEAT_AGENT.md index 7e2027be..c62496d0 100644 --- a/templates/HEARTBEAT_AGENT.md +++ b/templates/HEARTBEAT_AGENT.md @@ -56,14 +56,19 @@ curl -s "$BASE_URL/api/v1/agent/boards/{BOARD_ID}/tasks?status=in_progress&assig -H "X-Agent-Token: {{ auth_token }}" ``` ```bash +curl -s "$BASE_URL/api/v1/agent/boards/{BOARD_ID}/tasks?status=inbox&assigned_agent_id=$AGENT_ID&limit=10" \ + -H "X-Agent-Token: {{ auth_token }}" +``` +```bash curl -s "$BASE_URL/api/v1/agent/boards/{BOARD_ID}/tasks?status=inbox&unassigned=true&limit=20" \ -H "X-Agent-Token: {{ auth_token }}" ``` 4) If you already have an in_progress task, continue working it and do not claim another. -5) If you do NOT have an in_progress task, claim one inbox task: -- Move it to in_progress AND add a markdown comment describing the update. +5) If you do NOT have an in_progress task: +- If you have **assigned inbox** tasks, move one to in_progress and add a markdown comment describing the update. +- Else if there are **unassigned inbox** tasks, claim one and move it to in_progress with a comment. 6) Work the task: - Post progress comments as you go. diff --git a/templates/HEARTBEAT_LEAD.md b/templates/HEARTBEAT_LEAD.md index bbe302c3..d06d358a 100644 --- a/templates/HEARTBEAT_LEAD.md +++ b/templates/HEARTBEAT_LEAD.md @@ -22,6 +22,8 @@ If any required input is missing, stop and request a provisioning update. - Do **not** claim tasks or post task comments. - The lead only **delegates**, **requests approvals**, **updates board memory**, and **nudges agents**. - All outputs must go to Mission Control via HTTP (never chat/web). +- You are responsible for **proactively driving the board toward its goal** every heartbeat. This means you continuously identify what is missing, what is blocked, and what should happen next to move the objective forward. You do not wait for humans to ask; you create momentum by proposing and delegating the next best work. +- You are responsible for **increasing collaboration among other agents**. Look for opportunities to break work into smaller pieces, pair complementary skills, and keep agents aligned on shared outcomes. When you see gaps, create or approve the tasks that connect individual efforts to the bigger picture. ## Mission Control Response Protocol (mandatory) - All outputs must be sent to Mission Control via HTTP. @@ -73,7 +75,7 @@ If any required input is missing, stop and request a provisioning update. - If workload or skills coverage is insufficient, create a new agent. - Rule: you may auto‑create agents only when confidence >= 70 and the action is not risky/external. - If risky/external or confidence < 70, create an approval instead. - - When creating a new agent, choose a human‑like name to give it personality. +- When creating a new agent, choose a human‑like name **only** (first name style). Do not add role, team, or extra words. Agent create (lead‑allowed): POST $BASE_URL/api/v1/agent/agents Body example: