Skip to content

Wake an idle agent session

A message to an agent waits in its mailbox. It never starts a model turn on its own, because a turn costs money. A wake is the separate, explicit action that starts one: you name a session, give an instruction and authorize that one paid turn.

The server admits a wake only when all of these hold. If one is missing, the wake is refused and nothing is reserved.

Requirement Where it comes from
You are a workspace owner or admin, and you own the session if a person owns it Your membership
The session is open, at the state you saw The session’s epoch
The grant carries session:wake and a wakes budget ceiling The grant the owner approved
The installed adapter measured idle wake The helper publishes this
The workspace’s quiet hours allow a wake now Workspace settings
No other wake of this session is running One live wake per session

The wake helper runs on the machine of the agent’s installation, beside a long-lived opencode server. It publishes what its adapter measured, asks every 30 seconds whether a wake is waiting, and starts the turn. sc-wake-helper install hands it to your user’s own supervisor, which starts it at login and again after a crash. See Keep the helper running.

Today two adapters qualified idle wake: opencode 2.2.5 and Claude Code 2.1.316. A Claude Code session has no server, so its helper works through hooks instead. See Wake a Claude Code session. The Codex adapter is in the helper and has not qualified yet, see Wake a Codex session.

  1. Set the environment. Neither variable belongs on the command line.

    Variable Value
    OPENCODE_SERVER_AUTH_HEADER The Authorization header of your opencode server
    SUPACLOUD_WAKE_HELPER_STORE_KEY Optional. Without it, the login leaves a key with your platform’s user-bound protection. Set it, base64 encoded, on a host without one, such as a container
  2. Enroll the installation once. On a machine with the @supacloud/artifact-mcp package the command is supacloud-artifact-mcp wake-helper; in the SupaCloud agent image it is sc-wake-helper. Both take the same arguments.

    Terminal window
    sc-wake-helper login \
    --api-url https://app.example.com \
    --registration-profile <registration-profile-id> \
    --state-dir /var/lib/sc-wake-helper

    It prints an address. Open it in a browser on the same machine, because the sign-in returns to 127.0.0.1. When you approve the agent, give it session:wake. The helper then prints the workspace and installation ids.

    The login first prints waiting up to <N> minutes for approval (source: …); the default is 15 minutes. Set SUPACLOUD_IDENTITY_LOGIN_TIMEOUT_SECONDS (whole seconds from 30 through 3600) or --timeout-seconds on the login, which wins, to change it. A value outside the range is refused; on a timeout nothing is stored, so run the login again.

  3. Start the helper with those ids.

    Terminal window
    sc-wake-helper \
    --api-url https://app.example.com \
    --workspace <workspace-id> \
    --installation <installation-id> \
    --harness-session <opencode-session-id> \
    --opencode-url http://127.0.0.1:4096 \
    --state-dir /var/lib/sc-wake-helper

    It prints wake helper ready with the identity session and epoch.

Put the word install in front of the same arguments. The command checks that the state directory holds a login, seals OPENCODE_SERVER_AUTH_HEADER into the state directory under the installation’s platform-held key, writes the supervisor definition and starts it:

Terminal window
sc-wake-helper install \
--api-url https://app.example.com \
--workspace <workspace-id> \
--installation <installation-id> \
--harness-session <opencode-session-id> \
--opencode-url http://127.0.0.1:4096 \
--state-dir /var/lib/sc-wake-helper
Platform Supervisor Restart after a crash
Linux A systemd user unit under ~/.config/systemd/user Restart=always
macOS A LaunchAgent under ~/Library/LaunchAgents KeepAlive
Windows A logon task under SupaCloud in Task Scheduler The task runs sc-wake-helper supervise, which starts the helper again after every exit

The secret never appears in the definition or on a command line. install refuses when SUPACLOUD_WAKE_HELPER_STORE_KEY is set, because a supervisor would start a helper that cannot read that key. Run install again after you rotate the opencode secret.

Claude Code starts a turn in an idle session when a hook with asyncRewake exits with code 2. Its helper therefore needs hooks in the session and no opencode server. A session reads its hooks when it starts, so a session that is already running does not take part until it is restarted. The folder of the session must be a trusted one.

  1. Add the hooks to the Claude Code settings of that machine. <hook> is the command supacloud-artifact-mcp claude-wake-hook <state-dir>/claude, with the helper’s absolute state directory. In the SupaCloud agent image it is node /app/dist/orchestration/claude-wake-hook-main.js <state-dir>/claude.

    {
    "hooks": {
    "SessionStart": [{ "hooks": [{ "type": "command", "command": "<hook>", "asyncRewake": true, "timeout": 604800 }] }],
    "Stop": [{ "hooks": [{ "type": "command", "command": "<hook>", "asyncRewake": true, "timeout": 604800 }] }],
    "UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "<hook>" }] }],
    "PostToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "<hook>" }] }],
    "SessionEnd": [{ "hooks": [{ "type": "command", "command": "<hook>" }] }]
    }
    }
  2. Start the helper with --harness claude-code. --harness-session current follows the session the hooks reported last, also across /clear.

    Terminal window
    sc-wake-helper \
    --harness claude-code \
    --api-url https://app.example.com \
    --workspace <workspace-id> \
    --installation <installation-id> \
    --harness-session current \
    --state-dir /var/lib/sc-wake-helper

A session is idle for the helper only when its last turn ended and a hook is waiting. A turn that is running gets the message at its next tool call or prompt instead, and no wake fires into it. The helper counts a wake as provider activity when the session’s transcript shows the model’s answer to that wake.

A Codex session has no server of its own either. The helper reaches the running Codex client on the same machine, such as the VS Code extension, through its local channel, and reads the session’s rollout file under $CODEX_HOME/sessions.

Start the helper with --harness codex and the thread id of the session as --harness-session:

Terminal window
sc-wake-helper --harness codex --api-url https://app.example.com --workspace <workspace-id> --installation <installation-id> --harness-session <thread-id> --state-dir /var/lib/sc-wake-helper

The adapter publishes unknown for every stage until a paid wake has been measured on an installed Codex client, so the Wake button stays away and a claimed wake is refused. A session is idle for the helper only when its rollout ended a turn and a running client owns the thread. A wake counts as provider activity when the rollout shows output tokens after that wake’s message.

  1. Open Settings → Agent identities and choose Details on the agent.

  2. Under Wake an idle session, find the open session. The row names the adapter and its version. A row without Wake says why: the installation has not reported its adapter, or the adapter has not qualified idle wake.

  3. Choose Wake, enter the instruction, and choose Authorize one paid turn. This button is your consent to the spend. Nothing else gives it.

The Agent identities list in the settings. No agent is enrolled here, so the list says so; an enrolled agent appears as a row with a Details action, and its detail view holds the Wake an idle session section.The Agent identities list in the settings. No agent is enrolled here, so the list says so; an enrolled agent appears as a row with a Details action, and its detail view holds the Wake an idle session section.

The helper picks the wake up within 30 seconds. A wake nobody claims expires after five minutes and its budget unit is returned.

Status Meaning Budget unit
Waiting for the helper The server admitted it; no helper has taken it yet Reserved
Taken by the helper The helper has it and is starting the turn Reserved
Provider activity observed The model provider worked on this turn Charged
Provider activity unknown The turn may have run, but no provider evidence came back Charged
Refused The turn provably never started Returned
Expired No helper took it before the deadline, or the helper took it and never recorded a start Returned

The helper records a start with the server before it hands the instruction to the harness. If it crashes after it took a wake and before that start, the turn provably never ran: the wake ends as Expired with identity_wake_never_started at its deadline and its unit is returned. A crash after the start ends as Provider activity unknown, because the turn may have run. If the helper cannot record the start, it does not deliver the instruction and reports the wake as Refused with wake_start_unrecorded. A helper of an older release does not record a start; its wakes keep the stricter rule and end as unknown after a crash.

A wake that reaches a session which is already working is delivered to its next turn and shows as Refused with delivered_to_running_turn. The instruction arrived, and no extra turn was paid for.

An acknowledgement alone never counts as a wake. Only evidence from the provider turns a wake into Provider activity observed.