penguiflow-hitl-pause-resume
Add human-in-the-loop pause/resume to a PenguiFlow ReactPlanner — let tools call `ctx.pause(reason, payload)` to gate approvals, OAuth handoffs, await-input…
от hurtener★ 27 звёзд на GitHub
Установить penguiflow-hitl-pause-resume в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
PenguiFlow HITL Pause and Resume
When to use
- A tool must wait for a human decision (approval, edit, OAuth completion).
- A run must survive a process restart between pause and resume.
- You need a structured pause payload your UI renders (not just a yield).
When NOT to use
- Async background work the user doesn't directly approve → use penguiflow-background-tasks.
- Streaming partial responses to the user → use penguiflow-streaming.
- The durable backend that persists pauses → use penguiflow-statestore.
- The OAuth bookkeeping inside
ToolNode→ use penguiflow-mcp-integration (this skill covers the planner-side pause machinery).
Hard boundaries
This skill is the pause/resume contract between tools, the planner, and your host app. It does not define your UI, your auth model, or the durable backend (statestore does). It does explain how OAuth pauses look from the planner's perspective, but the MCP skill owns the ToolNode-side OAuth wiring.
Workflow
1) Decide what to pause for
reason |
Use case |
|---|---|
approval_required |
"Is it OK to send this email / write this row?" |
await_input |
"Please provide the missing field" |
external_event |
OAuth handoff, third-party webhook, async callback |
constraints_conflict |
Policy violation that needs operator override |
The reason is observable; the planner emits it in events and the payload travels with it.
2) Pause from a tool
@tool(desc="Write a line to a system (approval required)", side_effects="write")
async def write_line(args: WriteArgs, ctx: ToolContext) -> WriteOut:
approvals = ctx.tool_context.get("approvals") or {}
if not approvals.get("write_line"):
await ctx.pause(
"approval_required",
{
"title": "Approve write",
"preview": args.text,
"approval_key": "write_line",
},
)
# safe path after approval
return WriteOut(ok=True)
Critical mental model: ctx.pause(...) raises an internal signal that exits the tool body. The tool does not resume mid-function. After planner.resume(...), the planner replays its trajectory and the LLM decides the next step — usually calling the same tool again with the approval flag now set.
3) Consume the pause in the host app
result = await planner.run(user_message, tool_context=tool_ctx)
while isinstance(result, PlannerPause):
# render result.payload in the UI
# wait for user action
updated_ctx = {**tool_ctx, "approvals": {"write_line": True}}
result = await planner.resume(
result.resume_token,
user_input="approved", # optional
tool_context=updated_ctx,
)
# result is now a final answer
PlannerPause fields:
reason: str— one of the four above.payload: dict— JSON-friendly, application-defined.resume_token: str— opaque, treat as a secret.
4) Make resume_token survive restarts
Pause records live in memory by default. For multi-worker / restart-prone deployments, configure a StateStore implementing SupportsPlannerState:
save_planner_state(token, payload) -> Noneload_planner_state(token) -> payload | None(consume-on-load recommended)
Attach via ReactPlanner(state_store=YourStore()). A failing store does not block the pause — it's logged and ignored, and the in-memory record still works for the current process.
See penguiflow-statestore for backend implementations.
5) Pass session identity on every call
On both run() and resume() pass tool_context={"session_id": ..., "tenant_id": ..., "user_id": ...}. Required for session dispatch, multi-tenant memory (penguiflow-memory), and OAuth tools. On resume, tool_context overrides any stored value — use this to supply the answer (set approvals, add a missing field, etc.).
6) Keep payloads small and safe
JSON-friendly only. No secrets. Large binary → upload to artifact store, reference by id. Long strings → truncate.
7) Special case: OAuth pauses
ToolNodes with AuthType.OAUTH2_USER pause with reason="external_event" and payload {"pause_type": "oauth", "provider": ..., "auth_url": ..., "state": ..., "scopes": [...], "display_name": ...}. UI opens auth_url; callback stores token; you call planner.resume(...). See penguiflow-mcp-integration for the callback/token store contract.
Troubleshooting (fast checks)
planner.resume(...)raisesKeyError— in-memory record lost on restart or StateStore doesn't implementsave_planner_state/load_planner_state. Add durable planner state.- Resume missing clients — non-JSON
tool_contextvalues got dropped on persist. Re-passtool_context; keep clients in factories/registries. - Pauses never happen —
pause_enabled=False, or the tool doesn't callctx.pause(...). - Same approval keeps re-prompting — resume
tool_contextdidn't carry the approval flag
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- agents/openai.yaml
- references/durability-and-statestore.md
- references/pause-contract.md
- references/resume-mechanics.md
FAQ
Что делает скилл penguiflow-hitl-pause-resume?
Add human-in-the-loop pause/resume to a PenguiFlow ReactPlanner — let tools call `ctx.pause(reason, payload)` to gate approvals, OAuth handoffs, await-input prompts, and policy decisions; consume the resulting `PlannerPause(reason, payload, resume_token)` in your UI; call `planner.resume(resume_token, user_input=..., tool_context=...)` to continue; and persist pause state across workers via a `StateStore` implementing `save_planner_state`/`load_planner_state`. Use when a user says "pause for HITL", "human in the loop", "approval gate", "wait for user input", "OAuth handoff", "resume after restart", or names `PlannerPause`, `ctx.pause`, `resume_token`.
Как установить скилл penguiflow-hitl-pause-resume?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл penguiflow-hitl-pause-resume запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
AnthropicUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
xlsx
AnthropicUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
pptx
AnthropicUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…