agentleFS
fritzprixfritzprix/libr-agent/.agents/skills/libr-delegate/SKILL.md

libr-delegate

Skill11 starsChanged 19 days agoMITView on GitHub

Delegate work to a running LibrAgent desktop/headless instance via the local HTTP Session API (`POST /api/sessions`, messages, status, children, resume, terminate, delete). Use from Cursor (or other external harnesses) when LibrAgent is up and you need a LibrAgent session to run a task — optionally with `parentSessionId` lineage. After work: extract message history (session transcript / API-side "trace"), then terminate+delete one-shot sessions. Triggers: Session API, /api/sessions, parentSessionId, curl session, HTTP delegate to LibrAgent, "LibrAgent에 위임", "세션 API로 자식 띄워", Harbor/bench spawn, session cleanup, delete session, extract transcript. NEVER for LibrAgent-internal `agent__spawnSession` flows (that is the in-app `delegate` skill). NEVER invent MCP tool names here.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 2 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Write a self-contained handoff (LibrAgent child does not see Cursor chat, parent workspace instructions, or workspace-local skills unless …

    line 43
  2. Very specific:

    Create — write JSON payload to a file, validate non-empty JSON, then POST $BASE/api/sessions (include request or create idle).

    line 46
  3. Very specific:

    If idle — POST $BASE/api/sessions/:id/messages with {"content":"..."}

    line 49
  4. Very specific:

    Default limit is 50 — use a high limit for full history

    line 75
  5. Very specific:

    Treat latest assistant text as the deliverable.

    line 76
  6. Distinctive:

    If writing a one-off loop, lowercase before match:

    line 122
  7. Very specific:

    Follow-ups: another POST …/messages (queued if still busy).

    line 130
  8. Very specific:

    Default: LibrAgent session workspace, not the Cursor CWD unless workspacePath is set to that absolute path

    line 136
  9. Very specific:

    Put objective, scope, paths, and output format in request / message body

    line 138
  10. Distinctive:

    Do not assume Cursor files, notes, or tools are visible inside LibrAgent

    line 140

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Libr Delegate (Cursor → LibrAgent Session API)

Spawn and steer LibrAgent sessions over HTTP from Cursor. LibrAgent must already be running (desktop or headless). This skill does not ship into LibrAgent bundled_skills.

vs in-app delegate

CallerMechanism
Cursor / scripts / HarborThis skill → HTTP /api/sessions
Inside a LibrAgent agent turnIn-app delegate → agent__* tools

Base URL

PORT=$(cat ~/.libragent/http_port 2>/dev/null || echo 3030)
BASE="http://127.0.0.1:${PORT}"

Port file is written when LibrAgent’s HTTP server binds; fallback is 3030.

Workflow

  1. Confirm LibrAgent is up — GET $BASE/api/health (or assistants list)
  2. Resolve assistantId — GET $BASE/api/assistants
  3. Write a self-contained handoff (LibrAgent child does not see Cursor chat, parent workspace instructions, or workspace-local skills unless you pass an absolute workspacePath)
  4. Create — write JSON payload to a file, validate non-empty JSON, then POST $BASE/api/sessions (include request or create idle). See references/session-api.md (preferred file recipe + empty-body guard)
  5. If idle — POST $BASE/api/sessions/:id/messages with {"content":"..."}
  6. Poll — GET $BASE/api/sessions/:id until terminal (prefer scripts/poll-until-done.sh)
  7. Read result — GET $BASE/api/sessions/:id/messages
  8. On paused after crash — POST …/resume, then poll again
  9. Optional lineage — set parentSessionId; list with GET …/children
  10. Extract transcript before delete — dump GET …/messages?limit=500 to a file (see below)
  11. Cleanup one-shot sessions — POST …/terminate then DELETE …/sessions/:id (delete cascades descendants)

Curl recipes: references/session-api.md. Handoff / isolation: references/handoff.md. Poll helper: scripts/poll-until-done.sh.

Extract transcript (API-side "trace") then delete

There is no HTTP /api/sessions/:id/trace and no ATIF/Markdown export endpoint on the Session API. UI session export (Markdown / ATIF) is separate. For Cursor/harness handoffs, the recoverable history is message JSON:

# After idle (or error) — save BEFORE delete
curl -sS "$BASE/api/sessions/$SID/messages?limit=500" \
  > ".libragent/work/libr-delegate-${SID}-messages.json"
  • Default limit is 50 — use a high limit for full history
  • Treat latest assistant text as the deliverable; keep the JSON dump when debugging tool calls / failures (role user | assistant | tool)
  • Optional deeper analysis of a dumped file: Cursor skill trace-analyzer expects .trace.json shape — only use it if the dump matches that format; otherwise inspect the messages JSON directly
  • Order matters: extract → terminate → DELETE. Delete removes DB history

One-shot / automation default: always extract (or confirm you only need the final assistant text) then terminate+delete so sessions do not accumulate.

Create payload essentials

{
  "assistantId": "<from GET /api/assistants>",
  "request": "<self-contained task + deliverable format>",
  "workspacePath": "/absolute/path/optional",
  "parentSessionId": "<optional exact parent session id>",
  "executionMode": "normal | yolo | unsafe",
  "name": "optional label"
}
  • Blank/omit request → idle (no LLM turn until messages POST)
  • Unattended automation: prefer yolo; use unsafe only when hard-approval tools must also auto-run
  • Child inherits non-normal parent executionMode when omitted on create

Polling rules

Wire status is always lowercase (serde(rename_all = "lowercase")): idle | busy | paused | error | queued | provisioning.

Status (wire)Action
busy / queued / provisioningWait with backoff; do not spam
idle (after work)Read messages; treat latest assistant text as result
pausedPOST …/resume once, then poll
errorFail the handoff; do not claim success from partial prose

Preferred poll (normalizes case; exits on terminal):

./.agents/skills/libr-delegate/scripts/poll-until-done.sh "$SID" "$BASE"

If writing a one-off loop, lowercase before match:

status=$(curl -sS "$BASE/api/sessions/$SID" \
  | python3 -c 'import sys,json; print(json.load(sys.stdin).get("status","").lower())')
case "$status" in idle|error|paused) break ;; esac

Follow-ups: another POST …/messages (queued if still busy).

Isolation (critical)

The LibrAgent session is not a clone of this Cursor chat:

  • Default: LibrAgent session workspace, not the Cursor CWD unless workspacePath is set to that absolute path
  • Put objective, scope, paths, and output format in request / message body
  • Require deliverables in the session’s final assistant text
  • Do not assume Cursor files, notes, or tools are visible inside LibrAgent

Anti-patterns

  • Calling nonexistent MCP tools (spawnSession, session_api__*) from Cursor
  • Echo-only stubs instead of real POST …/messages
  • Rapid fixed-interval polls with no backoff
  • Matching PascalCase statuses (Idle/Busy) — API returns idle/busy; a case Idle) branch never fires and the poll loops until timeout even after the session finished (postmortem: editObject smoke, 2026-04)
  • Treating paused / empty history / error as success
  • Deleting a session before saving …/messages when a transcript is needed
  • Assuming ~/.libragent/traces/*.trace.json or /api/.../trace exists (they are not part of the Session API)
  • Leaving one-shot delegate sessions undeleted after the handoff completes
  • Putting this skill under src-tauri/bundled_skills (Cursor-only)
  • Referencing shell vars as bare Python names inside <<'PY' (e.g. workspacePath: WORKSPACE) → NameError → empty payload file → create 400 EOF while parsing a value
  • curl -d @file without checking the file is non-empty valid JSON first

Related repo docs

  • HTTP API: docs/api/http_api.md
  • In-app sub-agents (product): docs/user/guides/sub-agents.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.