diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-27 20:57:00 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-27 20:57:00 +0300 |
| commit | 2552d101afe46b8622a7695f38f6cd1766dd1afc (patch) | |
| tree | e560c2cc8ef02689711af0865a5b541ee3050bf1 /docs | |
| parent | 0d1a39dcee6a0f244a036c55935970f40cfa76b8 (diff) | |
feat: let agents report their own resume command (#4687)
* feat: let agents report their own resume command
* fix: keep reported resume commands tied to accepted sessions and current owners
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/next/api/herdr-api.schema.json | 20 | ||||
| -rw-r--r-- | docs/next/website/src/content/docs/cli-reference.mdx | 8 | ||||
| -rw-r--r-- | docs/next/website/src/content/docs/integrations.mdx | 16 | ||||
| -rw-r--r-- | docs/next/website/src/content/docs/session-state.mdx | 2 | ||||
| -rw-r--r-- | docs/next/website/src/content/docs/socket-api.mdx | 16 |
5 files changed, 58 insertions, 4 deletions
diff --git a/docs/next/api/herdr-api.schema.json b/docs/next/api/herdr-api.schema.json index 3151bff3..e2553f75 100644 --- a/docs/next/api/herdr-api.schema.json +++ b/docs/next/api/herdr-api.schema.json @@ -2909,6 +2909,16 @@ "pane_id": { "type": "string" }, + "resume_argv": { + "description": "Command that resumes this agent's session after a Herdr restart. The\nfirst element must be a plain command name.", + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, "seq": { "format": "uint64", "minimum": 0, @@ -2952,6 +2962,16 @@ "pane_id": { "type": "string" }, + "resume_argv": { + "description": "Command that resumes this agent's session after a Herdr restart. The\nfirst element must be a plain command name.", + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, "seq": { "format": "uint64", "minimum": 0, diff --git a/docs/next/website/src/content/docs/cli-reference.mdx b/docs/next/website/src/content/docs/cli-reference.mdx index 05a539d6..1b6f7019 100644 --- a/docs/next/website/src/content/docs/cli-reference.mdx +++ b/docs/next/website/src/content/docs/cli-reference.mdx @@ -278,7 +278,8 @@ herdr pane report-agent <pane_id> \ [--message TEXT] \ [--seq N] \ [--agent-session-id ID] \ - [--agent-session-path PATH] + [--agent-session-path PATH] \ + [-- RESUME_COMMAND...] herdr pane report-agent-session <pane_id> \ --source ID \ @@ -286,7 +287,8 @@ herdr pane report-agent-session <pane_id> \ [--seq N] \ [--agent-session-id ID] \ [--agent-session-path PATH] \ - [--session-start-source SOURCE] + [--session-start-source SOURCE] \ + [-- RESUME_COMMAND...] herdr pane release-agent <pane_id> \ --source ID \ @@ -296,6 +298,8 @@ herdr pane release-agent <pane_id> \ `report-agent-session` updates native session identity without reporting lifecycle state. `release-agent` ends that source's lifecycle authority when its agent process exits. +Arguments after `--` are the command Herdr runs to resume this session after a server restart. The first argument must be a plain command name on `PATH`, and no argument may contain an apostrophe. + `pane get`, `pane list`, `agent get`, and `agent list` include a read-only `agent_session` object when an official integration has reported a native session reference. If no native session reference is stored, the field is omitted. Those commands include `foreground_cwd` when Herdr can resolve the cwd of the foreground process controlling the pane. The `cwd` field remains the pane/workspace cwd used for labels and follow-cwd behavior. diff --git a/docs/next/website/src/content/docs/integrations.mdx b/docs/next/website/src/content/docs/integrations.mdx index 1261b38d..e36dfdf2 100644 --- a/docs/next/website/src/content/docs/integrations.mdx +++ b/docs/next/website/src/content/docs/integrations.mdx @@ -87,7 +87,21 @@ Report `idle` when the agent is ready for input and `blocked` when it needs a us Report only when `HERDR_ENV=1` and the required variables are present. This keeps the integration a no-op outside Herdr. Keep `--source` stable and unique to the integration. If reports can arrive out of order, include a strictly increasing `--seq`; Herdr ignores stale sequence numbers from the same source. -You can include `--agent-session-id` or `--agent-session-path` with `report-agent`, or use `pane report-agent-session` when session identity changes independently of state. Herdr exposes that reference through its pane and agent APIs. Automatic session restore also requires Herdr to know how to launch that agent and resume the referenced session. +You can include `--agent-session-id` or `--agent-session-path` with `report-agent`, or use `pane report-agent-session` when session identity changes independently of state. Herdr exposes that reference through its pane and agent APIs. + +To have Herdr resume your agent after a Herdr server restart, report the command that resumes the current session after `--`. Include any options the session needs, such as the model or permission mode: + +```bash +"$HERDR_BIN_PATH" pane report-agent-session "$HERDR_PANE_ID" \ + --source custom:my-agent \ + --agent my-agent \ + --agent-session-id "$SESSION_ID" \ + -- my-agent --resume "$SESSION_ID" --model my-model +``` + +Herdr runs that command in the restored pane's directory. The first word must be a plain command name on `PATH`, not a path, and no argument may contain an apostrophe. Report the agent's state with `report-agent` first so your source holds the pane, and report the command again whenever the session changes. Herdr keeps it only while your source holds the pane and drops it on release. `[session] resume_agents_on_restore = false` disables it. + +Herdr cannot identify a custom agent's process, so it treats the pane returning to its idle shell prompt as the agent exiting and clears the agent and its resume command. Still release authority on exit so the pane updates immediately. Use `HERDR_BIN_PATH` and the CLI wrappers for portable integrations. Code that needs direct IPC can send the equivalent `pane.report_agent`, `pane.report_agent_session`, and `pane.release_agent` requests described in the [Socket API](/docs/socket-api/#agent-state-reporting). diff --git a/docs/next/website/src/content/docs/session-state.mdx b/docs/next/website/src/content/docs/session-state.mdx index b8706cd5..d333dab7 100644 --- a/docs/next/website/src/content/docs/session-state.mdx +++ b/docs/next/website/src/content/docs/session-state.mdx @@ -81,7 +81,7 @@ Native agent session restore is enabled by default. Disable it with: resume_agents_on_restore = false ``` -Herdr only resumes panes that reported a native session reference through a current official Herdr integration. +Herdr resumes panes that reported a native session reference through a current official Herdr integration, and panes whose agent reported its own resume command. See [Integrate your own agent](/docs/integrations/#integrate-your-own-agent). After a client attaches and provides terminal size and theme context, Herdr resumes eligible restored agent panes across workspaces and tabs without waiting for each pane to be focused. diff --git a/docs/next/website/src/content/docs/socket-api.mdx b/docs/next/website/src/content/docs/socket-api.mdx index 4572b5ab..9e844d7e 100644 --- a/docs/next/website/src/content/docs/socket-api.mdx +++ b/docs/next/website/src/content/docs/socket-api.mdx @@ -687,6 +687,22 @@ Session-only official integrations report native session references with `pane.r } ``` +Both methods accept an optional `resume_argv` array with the command that resumes the reporter's current session after a Herdr server restart. Its first element must be a plain command name, not a path, and no element may contain an apostrophe; invalid values fail with `invalid_resume_argv` and the report is not applied. A custom agent must hold the pane through `pane.report_agent` before it can attach a command; otherwise the request fails with `resume_not_accepted`. Herdr keeps the command only while the same `source` and `agent` hold the pane, and it takes precedence over Herdr's built-in resume command for that agent. Older Herdr versions ignore the field. + +```json +{ + "id": "req_3", + "method": "pane.report_agent_session", + "params": { + "pane_id": "w1:p1", + "source": "custom:my-agent", + "agent": "my-agent", + "agent_session_id": "...", + "resume_argv": ["my-agent", "--resume", "..."] + } +} +``` + `pane.get`, `pane.list`, `agent.get`, and `agent.list` expose a read-only `agent_session` object when Herdr has a stored native session reference: ```json |
