Skip to content

feat(cli): background task observability and /bg namespace#8592

Closed
Dusk1e wants to merge 1 commit into
NousResearch:mainfrom
Dusk1e:feat/issue-8568-bg-task-observability
Closed

feat(cli): background task observability and /bg namespace#8592
Dusk1e wants to merge 1 commit into
NousResearch:mainfrom
Dusk1e:feat/issue-8568-bg-task-observability

Conversation

@Dusk1e

@Dusk1e Dusk1e commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR improves CLI background task observability and fixes the /bg alias behavior. Background tasks launched with /background <prompt> were previously run in isolated sessions with no durable, user-visible state.

Fixes #8568

Why

Previously, the /background command was a "black box" with several limitations:

  • No structured task logs or file change lists.
  • No way to inspect task status from the foreground CLI.
  • No foreground session context after completion (the agent didn't know what happened).
  • /bg status was incorrectly parsed as a new background prompt.

Changes

1. Persisted Artifacts

Added profile-safe background task artifact storage under HERMES_HOME/background_tasks/<task_id>/:

  • manifest.json: Task metadata and current status.
  • log.jsonl: Structured event stream of activity.
  • summary.txt & files.txt: Final result and changed file reporting.

2. New /bg Subcommand Namespace

Registered /bg as a dedicated subcommand area to prevent prompt fall-through:

  • /bg status [task-id]
  • /bg log <task-id>
  • /bg files <task-id>
  • /bg kill <task-id>

3. Context Awareness

  • Session Injection: Lifecycle events (start/finish) are now injected as SYSTEM messages into the foreground session history.
  • Workspace Diffs: Added file tracking via before/after workspace snapshots.
  • UI Updates: Added active background task count to the /status command.

How To Test

  1. Start the CLI and run: /background build a small HTML site
  2. While running, verify status: /bg status
  3. After completion, inspect results:
    • /bg log <task-id>
    • /bg files <task-id>
  4. Ask the foreground agent: "What did the background task do?" (Confirm it has session context).
  5. Verify files exist in ~/.hermes/background_tasks/<task-id>/.

Tests Run

Passed 38 targeted tests:

python -m pytest tests/cli/test_cli_background_commands.py \
  tests/cli/test_cli_background_tui_refresh.py \
  tests/cli/test_cli_status_command.py \
  tests/cli/test_cli_save_config_value.py \
  tests/gateway/test_background_command.py -q

@Dusk1e Dusk1e changed the title fix(cli): persist background task state and add /bg status/log/files commands feat(cli): background task observability and /bg namespace Apr 12, 2026
@Dusk1e Dusk1e marked this pull request as draft April 13, 2026 01:35
@Dusk1e Dusk1e marked this pull request as ready for review April 13, 2026 01:35
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 28, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing in favor of the minimum-viable fix in PR #27175 (merged), which addresses the core UX gap that motivated #8568 with ~25 LOC: a live ▶ N indicator in the status bar showing running /background tasks.

Your implementation here was clean and complete — artifacts under background_tasks/<id>/, /bg status|log|files|kill subcommands, foreground SYSTEM-note injection, 38 passing tests. After reviewing it against the actual user complaint (people asking the agent about bg tasks because there's no visible signal one exists), we concluded a status-bar indicator solves the root cause without the larger feature footprint. The richer inspection surfaces can be added later if demand materializes.

Thank you for the contribution — closing this with credit.

@teknium1 teknium1 closed this May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Background tasks have no observable state — no logs, no file list, no session context for foreground agent

3 participants