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.
In this repository48 other files it gives its agents.
- agents.mdAGENTS.md
- .agents/skills/react-best-practices/AGENTS.mdAGENTS.md
- .agents/skills/react-native-skills/AGENTS.mdAGENTS.md
- .agents/skills/react-view-transitions/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- agent-initSkill
- agy-delegateSkill
- audit-docsSkill
- code-audit-expertSkill
- computer-diagnosisSkill
- create-builtin-toolSkill
- create-prSkill
- critique-builtin-toolSkill
- doc-auditorSkill
- docxSkill
- extract-log-debugSkill
- feature-refactor-proposalSkill
- gatekeeper-loopSkill
- harbor-harness-improvement-loopSkill
- i18n-language-standardsSkill
- jobs-trace-analyzerSkill
- lean-builtin-tool-auditorSkill
- libragent-qualitySkill
- libr-tool-e2e-harness-loopSkill
- modular-large-file-refactorSkill
- performance-auditSkill
- pptxSkill
- vercel-react-best-practicesSkill
- vercel-react-native-skillsSkill
- vercel-react-view-transitionsSkill
- readme-showcase-syncSkill
- refactor-builtin-toolSkill
- release-managerSkill
- review-local-changesSkill
- review-pr-commentsSkill
- science-searchSkill
- setup-wizardSkill
- skill-creatorSkill
- soul-awakeningSkill
- sqlite-analyzerSkill
- sync-pending-approvalsSkill
- tool-creatorSkill
- trace-analyzerSkill
- trace-eval-loopSkill
- vitepress-doc-syncSkill
- worker-loopSkill
- x-cliSkill
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
- Very specific: line 43
Write a self-contained handoff (LibrAgent child does not see Cursor chat, parent workspace instructions, or workspace-local skills unless …
- Very specific: line 46
Create — write JSON payload to a file, validate non-empty JSON, then POST $BASE/api/sessions (include request or create idle).
- Very specific: line 49
If idle — POST $BASE/api/sessions/:id/messages with {"content":"..."}
- Very specific: line 75
Default limit is 50 — use a high limit for full history
- Very specific: line 76
Treat latest assistant text as the deliverable.
- Distinctive: line 122
If writing a one-off loop, lowercase before match:
- Very specific: line 130
Follow-ups: another POST …/messages (queued if still busy).
- Very specific: line 136
Default: LibrAgent session workspace, not the Cursor CWD unless workspacePath is set to that absolute path
- Very specific: line 138
Put objective, scope, paths, and output format in request / message body
- Distinctive: line 140
Do not assume Cursor files, notes, or tools are visible inside LibrAgent
≈ “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.
Files
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
| Caller | Mechanism |
| Cursor / scripts / Harbor | This skill → HTTP /api/sessions |
| Inside a LibrAgent agent turn | In-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
- Confirm LibrAgent is up —
GET $BASE/api/health(or assistants list) - Resolve
assistantId—GET $BASE/api/assistants - 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) - Create — write JSON payload to a file, validate non-empty JSON, then
POST $BASE/api/sessions(includerequestor create idle). Seereferences/session-api.md(preferred file recipe + empty-body guard) - If idle —
POST $BASE/api/sessions/:id/messageswith{"content":"..."} - Poll —
GET $BASE/api/sessions/:iduntil terminal (preferscripts/poll-until-done.sh) - Read result —
GET $BASE/api/sessions/:id/messages - On paused after crash —
POST …/resume, then poll again - Optional lineage — set
parentSessionId; list withGET …/children - Extract transcript before delete — dump
GET …/messages?limit=500to a file (see below) - Cleanup one-shot sessions —
POST …/terminatethenDELETE …/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
limitis 50 — use a high limit for full history - Treat latest assistant
textas the deliverable; keep the JSON dump when debugging tool calls / failures (roleuser|assistant|tool) - Optional deeper analysis of a dumped file: Cursor skill
trace-analyzerexpects.trace.jsonshape — 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; useunsafeonly when hard-approval tools must also auto-run - Child inherits non-
normalparentexecutionModewhen 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 / provisioning | Wait with backoff; do not spam |
idle (after work) | Read messages; treat latest assistant text as result |
paused | POST …/resume once, then poll |
error | Fail 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 ;; esacFollow-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
workspacePathis 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 returnsidle/busy; acase 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
…/messageswhen a transcript is needed - Assuming
~/.libragent/traces/*.trace.jsonor/api/.../traceexists (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 400EOF while parsing a value curl -d @filewithout 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
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
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.

