Call me back

From fritzprix/libr-agent · View interactive version

Call me back is an AI agent skill from the GitHub repository fritzprix/libr-agent. Resume this agent session on a signal instead of clock polling. Use when you need to (1) wait for a process this session started to finish — "끝나면 깨워줘", "완료되면 알려줘", "run in background and call me back"; (2) react to events that arrive from outside — "X가 오면 Y 해줘", "새 이벤트가 생기면 처리해줘", "when a new one co

How to use this skill

Skill file

Call Me Back (event-driven resume)

Wait for a process completion or an incoming external event, then continue

this session. Do not fake it with scheduleCallback / loop delays.

"me" = this agent session (inject/resume here), not a user phone/push alert.

First: what are you waiting for?

| Waiting for | Path |

| --- | --- |

| A process this session started (runShell / spawnProcess gave you a processId), result needed this turn | A — workspace__waitForProcess |

| A process this session started, runs many minutes, nothing to do meanwhile | A2 — chain a $LIBRAGENT_WAKE_URL POST, end the turn |

| Events from a system you do not control (something arrives, changes, fires) | B — hook/watcher POSTs to $LIBRAGENT_WAKE_URL; the woken session handles the event |

Is wake available here?

The only environment check: is $LIBRAGENT_WAKE_URL set? The variable exists only in

runShell / spawnProcess environments, so test it there with

[ -n "$LIBRAGENT_WAKE_URL" ] (never print it).

available in this environment.

vs `loop` / `schedule` (hard split)

| Signal | Skill |

| --- | --- |

| Process exit, job/ticket done, arriving event, webhook, watcher, hook | call-me-back (this skill) |

| Relative delay / wall-clock / checking on a time interval | loop |

| Permanent app-wide cron | schedule |

If the user names a command, job, ticket, or external system / event source, use this

skill. If they only name a clock time or interval, use loop.

Out of scope

Workflow

A. Process this session started — wait in this turn

workspace__waitForProcess only works for a process this session started with

runShell / spawnProcess and got a processId for (in a managed Docker session that

includes processes running in the container). It cannot wait for anything else.

  1. Start (or reuse) a background process:

workspace__spawnProcess (or a sync tool that handed off a processId).

  1. Block on completion — do not poll with loop:

workspace__waitForProcess(processId=..., timeout=...)

(default timeout is 30 seconds; give a timeout that fits the job.)

  1. On finish, read output if needed:

workspace__readProcessOutput(processId=...)

  1. Continue the user task with the result (pass/fail, logs, next steps).

Prefer one waitForProcess with a fitting timeout over repeated short waits or clock callbacks.

A2. Process this session started — end the turn, get woken

Requires $LIBRAGENT_WAKE_URL (see "Is wake available here?"); if unset, use A.

For jobs that run many minutes (long builds, training) with nothing else to do meanwhile,

do not hold the turn in waitForProcess. runShell / spawnProcess export

$LIBRAGENT_WAKE_URL, a tokenized wake URL for this session only.

  1. Start the job with an unconditional callback (fires on success and failure):

long_cmd > job.log 2>&1; curl -s -X POST "$LIBRAGENT_WAKE_URL" -H 'Content-Type: application/json' -d "{\"exitCode\":$?,\"logPath\":\"job.log\"}"

via workspace__spawnProcess.

  1. Tell the user it is running, then end the turn.
  2. You are woken by a [wake callback] message (see "Wake message"). Read the log and

continue. If the session is busy, the callback is queued, not dropped.

survive an app restart; late callbacks get 401. If no callback came, check

job.log yourself.

B. External events (hooks / webhooks / watchers)

Principle: the hook only wakes this session. The woken session decides and responds.

Success = a message lands in this LibrAgent session and the session handles the

event. Stdout from an external gateway/hook process is not resume.

What a hook / watcher may do

A hook, webhook command, or watcher process does exactly three things:

  1. Detect the event.
  2. Put the event content into the payload: summary (text) or a file referenced by logPath.
  3. POST to $LIBRAGENT_WAKE_URL.

Summarizing, deciding, or sending a reply from inside the hook/watcher is an anti-pattern:

that work happens in the woken session, where the user's task and context live.

A long-running watcher that POSTs once per event is fine — that is how repeated events

are received.

Contract (product-agnostic)

Do not add per-product recipes to this skill — read that system's own hook docs, then

wire its payload here.

Every wake goes through $LIBRAGENT_WAKE_URL, the tokenized wake URL for this session.

Point the hook, webhook or --exec command at it. Do not invent a path, do not use the

main Session API /messages, and do not leave --exec as echo / file-append only.

register the callback (double-quoted), so the stored hook carries the value. Never print it.

content in summary (up to 2000 characters) or write it to a file and send its path in

logPath.

Two phases
  1. Register the hook / start the watcher once (that system's register API, or a

workspace__spawnProcess watcher). Tell the user it is set up, then end the turn.

  1. When woken (this session receives the [wake callback] message): read the event

from summary / logPath, then decide and respond here.

Do not treat "callback registered" as done unless wake/inject is wired.

Do not assume work done only inside the external callback will appear in this chat.

If `$LIBRAGENT_WAKE_URL` is unset

Nothing can wake the session after the turn ends. Either tell the user wake is not available

in this environment, or:

  1. Start a watcher with workspace__spawnProcess that exits after the first event and

writes it to a file.

  1. Block on workspace__waitForProcess with a long timeout (minutes, not the 30-second

default); if it times out, wait again.

  1. Read the event file and handle it in this session.

This handles one event per wait. If the user asked for an ongoing subscription, tell them

about this limit.

Anti-patterns

non-blocking register-callback API exists

If the system only offers coarse polling

Prefer its native wait/watch over LibrAgent clock loops, and keep poll intervals

honest in the reply. Prefer inject/wake whenever a callback hook exists.

Wake message

Every wake — process or external event — arrives as one message in this format:

[wake callback] Background process finished: status=<status>
exitCode: <exitCode>      (if sent)
logPath: <logPath>        (if sent)
summary: <summary>        (if sent)

The first line always says "Background process finished", also for external events.

status is your status value as sent (up to 32 characters, for example event); without

it, it is derived from exitCode (0 → success, other → failure) or is unknown.

C. Ambiguous "끝나면 알려줘"

Guardrails

explicitly asked for a global scheduled worker (schedule).

Related skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.