{"slug": "task-assets-agent-workflows-that-run-while-you-sleep", "title": "Task Assets: Agent Workflows That Run While You Sleep", "summary": "Akm 0.8.0 introduces task assets, YAML files that define scheduled agent workflows capable of running autonomously without an open terminal session. The feature enables continuous operation by allowing tasks like the improve loop and Discord health reports to execute on cron schedules, writing results to a state database for later review.", "body_md": "This is part eleven in a series about managing the growing pile of skills, scripts, and context that AI coding agents depend on. [Part nine](https://dev.to/itlackey/agents-that-remember-where-they-were-1koe) covered workflow assets and resumable procedures. [Part ten](https://dev.to/itlackey/the-improvement-loop-how-akm-keeps-your-agent-sharp-2d4d) introduced the improve pipeline that continuously curates your stash. Earlier parts addressed teams, distributed stashes, and community knowledge.\n\nMost automation with AI agents is reactive. You open a session, give the agent a task, wait for the result, close the session. The agent's clock runs when you run it.\n\nTask assets flip that model. A task is a YAML file in your stash that defines a workflow — what to run, when to run it, what environment it needs, and how long it's allowed to take. Once registered, the task runs on schedule without your involvement. The OS scheduler calls `akm tasks run <id>`\n\n, which executes the task and writes the result to `state.db`\n\n. You find out what happened when you check `akm health`\n\nor look at the log.\n\nThis is the piece of akm 0.8.0 that makes continuous operation possible. The improve loop runs twice an hour because a task asset says it does. The hourly Discord health report fires because a task asset says it does. Neither requires an open terminal.\n\nTask assets live at `<stash>/tasks/<id>.yml`\n\n. The filename is the task ID. A minimal task looks like this:\n\n```\nschedule: 0 * * * *\ncommand: akm improve --auto-accept 90\nenabled: true\n```\n\nThat's enough to install a cron entry and run `akm improve`\n\nat the top of every hour. The full schema adds metadata and per-task timeout control:\n\n```\nschedule: \"7,37 * * * *\"\ncommand: akm improve --auto-accept 90 --timeout-ms 1620000\nenabled: true\ntimeoutMs: 1800000\nname: akm-improve\ndescription: Run the improve pass at :07 and :37 — reflect, distill, consolidate, lint, and eval.\nwhen_to_use: Twice per hour; leaves ~23 minutes of idle headroom between completions.\ntags:\n  - improve\n  - maintenance\n```\n\nThe fields that matter most:\n\n| Field | Required | Purpose |\n|---|---|---|\n`schedule` |\nyes | Standard cron expression. Maps to crontab on Linux, launchd plist on macOS, schtasks XML on Windows. Wrap expressions containing special characters in quotes. |\n`command` or `prompt`\n|\none of the two |\n`command` runs as a plain shell command. `prompt` dispatches through the configured agent profile. A third option, `workflow` , targets a stash workflow ref directly. |\n`enabled` |\nyes |\n`false` keeps the task definition in your stash without installing a scheduler entry. |\n`timeoutMs` |\nno | Per-task timeout in milliseconds, overriding whatever the agent profile sets globally. `null` removes the kill timer entirely — useful for long-running local-model tasks. |\n`name` , `description` , `when_to_use` , `tags`\n|\nno | Metadata. `name` appears in `akm tasks list` ; the others exist for your own records and for search. |\n\nThe distinction between `command`\n\nand `prompt`\n\nreflects two different execution models.\n\nA `command`\n\ntask is a shell invocation. `akm tasks run`\n\nexecutes the string directly in a child process. There is no agent involved. The command can call `akm`\n\n, run a shell script, invoke any binary. The exit code is what gets logged.\n\n```\ncommand: akm improve --auto-accept 90\n```\n\nA `prompt`\n\ntask dispatches to the agent configured in your default agent profile (or the profile specified in `--profile`\n\n). The value of `prompt`\n\nbecomes the task instruction. The agent runs autonomously, can use `akm`\n\ncommands, write files, and call tools according to its allowed tool set. The result is determined by whether the agent exits cleanly.\n\n```\nprompt: |\n  Run akm wiki ingest research and then run akm wiki lint research.\n  Fix any orphan pages the lint step reports.\n```\n\nThe practical split: use `command`\n\nfor tasks where the execution is fully scripted and the outcome is deterministic. Use `prompt`\n\nwhen you want the agent to exercise judgment — synthesizing content, triaging output, making decisions based on what it finds. The curate-to-wiki task is a good example of the latter: it runs a multi-step workflow where the agent reads each step's instructions, substitutes parameters, and advances the workflow run through to completion. Workflow assets themselves are covered in [part nine](https://dev.to/itlackey/agents-that-remember-where-they-were-1koe) of this series.\n\nThere are two ways to get a task into the scheduler.\n\nThe first way is `akm tasks add`\n\n, which creates the YAML file and installs it in one step:\n\n```\nakm tasks add my-task \\\n  --schedule \"0 9 * * *\" \\\n  --command \"akm improve --auto-accept 80\" \\\n  --name \"Morning improve pass\" \\\n  --description \"Daily improve at 9 AM\"\n```\n\nThe second way is to write the YAML file directly into your stash's `tasks/`\n\ndirectory and then call:\n\n```\nakm tasks sync\n```\n\n`sync`\n\nreconciles all `.yml`\n\nfiles in `tasks/`\n\nagainst the OS scheduler. Any task that's `enabled: true`\n\nand not yet installed gets a scheduler entry. Any task that's `enabled: false`\n\nor missing gets its entry removed. This is the right command to run after pulling stash changes that include new or updated task files.\n\nOther task management commands:\n\n```\nakm tasks list                        # all defined tasks with status\nakm tasks show <id>                   # parsed YAML + scheduler state\nakm tasks run <id>                    # execute immediately\nakm tasks enable <id>                 # install the scheduler entry\nakm tasks disable <id>                # remove the scheduler entry, keep the file\nakm tasks remove <id>                 # delete the file and uninstall\nakm tasks history [--id <id>]         # recent runs from state.db\nakm tasks doctor                      # scheduler backend + cron path\n```\n\n`akm tasks run`\n\nis the same command the scheduler calls. You can run a task immediately to test it before committing it to a schedule.\n\nTasks that need secrets or environment-specific configuration use `akm env`\n\nvaults. A vault is an encrypted `.env`\n\nfile stored in your stash under `env/<name>.env`\n\n. You inject it into a child process using `akm env run`\n\n:\n\n```\nakm env run env:fwdslsh -- bash ./scripts/post-to-discord.sh\n```\n\nThe `env:`\n\nprefix is the canonical ref form. In task YAML, akm also resolves bare vault names — the worked example below uses the bare name to match the production file exactly.\n\nIn a task `command`\n\nfield, the same pattern applies directly:\n\n```\ncommand: akm env run fwdslsh -- bash /home/founder3/akm/scripts/akm-health-discord.sh\n```\n\nThis injects every variable in the `fwdslsh`\n\nvault into the shell process that runs the script. The variables live only in that child process — they are never written to disk or exported to the parent environment. The task definition itself contains no secrets, only the vault reference. You can commit task YAML to your stash and share it without exposing credentials.\n\nIf a task needs only a subset of the vault's variables, `--only`\n\nnarrows the injection:\n\n```\nakm env run env:fwdslsh --only DISCORD_WEBHOOK_URL -- bash ./post.sh\n```\n\n`--only`\n\naccepts a single key or a comma-separated list. Use `--except`\n\nto inject everything in the vault except specific keys.\n\nThis is the health report task used in production to monitor the improve pipeline:\n\n```\n# ~/akm/tasks/akm-health-report.yml\nschedule: 0 * * * *\ncommand: akm env run fwdslsh -- bash /home/founder3/akm/scripts/akm-health-discord.sh\nenabled: true\nname: AKM Health Report → Discord\ndescription: \"Hourly: post a 4h rolling health report to Discord. Driven by\n  akm health --since=4h — same data source as manual reports.\"\ntags:\n  - health\n  - discord\n  - monitoring\n```\n\nThe task fires at the top of every hour. It injects the `fwdslsh`\n\nvault (which contains the Discord webhook URL and any other credentials the script needs), then runs the health report script. The script calls `akm health --since=4h`\n\nand `akm health --since=8h`\n\n, computes deltas between the two windows for trend context, and posts a formatted embed to Discord.\n\nThe embed has three inline fields — Output (promoted refs, merged memories, memory inference yield), Failures (chunk failures, skip reason anomalies), and Latency (median, P95, prior-window comparison) — plus a Needs Attention section that only appears when something is actually off. The footer includes the hostname and run timestamp so reports from multiple machines are distinguishable at a glance.\n\nTo register the task after writing the YAML:\n\n```\nakm tasks sync\nakm tasks list\n# → akm-health-report   0 * * * *   enabled   last run: —\n```\n\nRun it once immediately to confirm the script works before relying on the scheduled version:\n\n```\nakm tasks run akm-health-report\n```\n\nCheck the result:\n\n```\nakm tasks history --id akm-health-report --limit 5\n```\n\nEvery task run is recorded in `state.db`\n\nunder the `task_history`\n\ntable. `akm tasks history`\n\nsurfaces that data. For log output, each run writes to:\n\n```\n~/.cache/akm/tasks/logs/<id>.log\n```\n\n`akm health`\n\ninspects `task_history`\n\nfor missing log files, stale active runs (tasks that started but never completed), and recent failure rates. A task run that never wrote a `tasks_completed`\n\nevent shows up in `akm health`\n\noutput as a stuck active run — a reliable signal that something went wrong even if the log file doesn't say much.\n\n```\nakm health --since 4h\n```\n\nThe health check correlates the `task_history`\n\nevents with the log files on disk. If a log file is missing for a completed run, `logBackingRate`\n\ndrops below 1.0, which flags as a warning. This is the `task-log-backing`\n\nhard check — one of the deterministic checks that `akm health`\n\nruns before it looks at any metrics.\n\nThe pattern that emerges from several tasks working together is an operation that runs itself. The improve loop consolidates and curates the stash twice an hour — what that pipeline does internally is covered in [part ten](https://dev.to/itlackey/the-improvement-loop-how-akm-keeps-your-agent-sharp-2d4d). The health report surfaces the results every hour. A daily curation task pulls new articles from configured sources and ingests them into the research wiki. None of these require an open terminal.\n\nAdding a new automated behavior follows the same steps regardless of what the task does:\n\n`<stash>/tasks/<id>.yml`\n\n.`akm tasks sync`\n\nto install the scheduler entry.`akm tasks run <id>`\n\nto test it immediately.`akm tasks history`\n\nand check the log.The task YAML is the contract between what you want to happen and when it happens. The log and `state.db`\n\nare the record of what actually did.\n\nTask assets are available in akm 0.8.0. The full command reference is in [docs/cli.md](https://github.com/itlackey/akm/blob/main/docs/cli.md#tasks). The environment vault documentation is in [docs/cli.md](https://github.com/itlackey/akm/blob/main/docs/cli.md#env). If you're upgrading from 0.7.x, task `.md`\n\nfiles from the old format are not auto-discovered — check the migration guide for the conversion path.", "url": "https://wpnews.pro/news/task-assets-agent-workflows-that-run-while-you-sleep", "canonical_source": "https://dev.to/itlackey/task-assets-agent-workflows-that-run-while-you-sleep-1787", "published_at": "2026-06-04 00:30:58+00:00", "updated_at": "2026-06-04 00:42:44.574151+00:00", "lang": "en", "topics": ["ai-agents", "artificial-intelligence", "ai-tools", "ai-infrastructure", "mlops"], "entities": ["akm", "Discord", "YAML"], "alternates": {"html": "https://wpnews.pro/news/task-assets-agent-workflows-that-run-while-you-sleep", "markdown": "https://wpnews.pro/news/task-assets-agent-workflows-that-run-while-you-sleep.md", "text": "https://wpnews.pro/news/task-assets-agent-workflows-that-run-while-you-sleep.txt", "jsonld": "https://wpnews.pro/news/task-assets-agent-workflows-that-run-while-you-sleep.jsonld"}}