Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

penguiflow-background-tasks

БесплатноБез исполняемых скриптовНе проверен

Enable concurrent background work on a PenguiFlow ReactPlanner — configure `BackgroundTasksConfig(enabled=True, allow_tool_background=..., default_mode=…

hurtenerот hurtener★ 27 звёзд на GitHub

Об этом скилле

PenguiFlow Background Tasks

When to use

  • The foreground agent needs to stay responsive while a long task runs.
  • You need parallelism beyond a single parallel planner step.
  • An "always slow" tool (scrape, ETL) should run async with a delayed merge.
  • You want a multi-task report grouped for the user.

When NOT to use

  • The work is fast (<2s) — don't bother; foreground tools are simpler.
  • You need a durable task queue across processes — this is in-process by default; bring your own TaskService for cross-process work.
  • The work has user-visible interim output → use penguiflow-streaming instead.
  • A single LLM-driven parallel step suffices → use the planner's parallel-and-joins (see penguiflow-reactplanner-config).

Hard boundaries

This skill covers planner-driven background tasks: spawn, observe, merge. The TaskService implementation (executor, persistence) is something you (or your host platform) provide. The pause/resume mechanics for HITL on merged context belong to penguiflow-hitl-pause-resume.

Workflow

1) Configure BackgroundTasksConfig

from penguiflow.planner import ReactPlanner
from penguiflow.planner.models import BackgroundTasksConfig

planner = ReactPlanner(
    ...,
    background_tasks=BackgroundTasksConfig(
        enabled=True,                        # default False; must opt in
        include_prompt_guidance=True,        # default
        allow_tool_background=False,         # default
        default_mode="subagent",             # default — "subagent" | "job"
        default_merge_strategy="HUMAN_GATED",# default
        max_concurrent_tasks=5,              # default
        max_tasks_per_session=50,            # default
        task_timeout_s=3600,                 # default; INT seconds
        proactive_report_enabled=False,      # default
        default_group_merge_strategy="APPEND",  # library default; flip to HUMAN_GATED for safety
        default_group_report=True,           # default
        max_tasks_per_group=10,              # default
    ),
)

Full field table in references/config-and-policies.md.

2) Implement (or import) a TaskService

The tasks.* tools call into a TaskService you supply. PenguiFlow ships an in-process implementation suitable for development. Production deployments typically wrap it with persistence (StateStore) and a real executor (asyncio task group, worker pool, distributed queue).

The host app:

  1. Constructs a TaskService instance.
  2. Passes it via tool_context["task_service"] for every foreground planner.run(...) call.
  3. Ensures tool_context["session_id"] is set (required for scoping).

See references/task-service-protocol.md for the protocol and a reference implementation.

3) Expose tasks.* tools

from penguiflow.sessions.task_tools import build_task_tool_specs

task_tool_specs = build_task_tool_specs()
catalog = build_catalog(my_nodes + task_tool_specs, registry)

Tools exposed:

  • tasks.spawn, tasks.list, tasks.get, tasks.cancel, tasks.prioritize
  • tasks.seal_group, tasks.list_groups, tasks.apply_group

Hard rule: expose tasks.* only to the foreground agent. Subagents must not spawn further tasks unless you explicitly want recursive agents — apply a ToolVisibilityPolicy that hides tasks.* from subagent traces.

4) Pick a mode per task: subagent vs job

Mode What runs When to use
subagent A full ReactPlanner sub-run with its own catalog and prompt Multi-step reasoning, parallel research, anything needing the LLM in the loop.
job A single tool call (no further LLM) One slow tool you want async (scrape, ETL, batch download). No pause/resume inside the job.

Set per-call: tasks.spawn(mode="subagent", ...). The planner's task.subagent and task.tool action opcodes normalize into tasks.spawn with the right mode.

5) Pick a merge strategy

Strategy Behavior
HUMAN_GATED (default) Result waits in a queue; user/operator explicitly merges via tasks.apply_group or equivalent.
APPEND Result is appended to the foreground context automatically when the task completes.
REPLACE Result replaces a specified slice of context (uses ContextPatch).

Start with HUMAN_GATED until you trust the workflow. APPEND/REPLACE shine for trusted, idempotent tasks (e.g., scheduled fact refreshes).

6) Use task groups for coherent reports

Spawn related tasks with group="..." (e.g., per research segment), then tasks.seal_group(group=...) and tasks.apply_group(group=...) to merge as one. With default_group_report=True, the user gets a single summary instead of N partial updates. Full pattern in references/groups-and-merge.md.

7) (Advanced) Tool-initiated background spawns

A tool runs async (not inline) when all are true: allow_tool_background=True, spec.extra["background"]["enabled"]=True, and tool_context has task_service +

Полный SKILL.md на GitHub

Установить penguiflow-background-tasks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

agents/openai.yamlreferences/config-and-policies.mdreferences/groups-and-merge.mdreferences/task-service-protocol.md

FAQ

Что делает скилл penguiflow-background-tasks?

Enable concurrent background work on a PenguiFlow ReactPlanner — configure `BackgroundTasksConfig(enabled=True, allow_tool_background=..., default_mode=..., default_merge_strategy=..., max_concurrent_tasks=..., task_timeout_s=...)`, expose the `tasks.*` tool surface via `build_task_tool_specs()`, supply `tool_context["task_service"]` (implementing the `TaskService` protocol) plus `session_id`, choose merge strategies (`HUMAN_GATED`/`APPEND`/`REPLACE`), use task groups for coherent multi-task reports, and let tools opt-into background execution via `spec.extra["background"]`. Use when a user says "background task", "spawn a subagent", "async tool", "task groups", or names `BackgroundTasksConfig`, `tasks.spawn`, `task.subagent`.

Как установить скилл penguiflow-background-tasks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл penguiflow-background-tasks запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить penguiflow-background-tasks с