Skip to content

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

@kingtobi1337

Description

@kingtobi1337

Bug Description

When using /background <prompt> in the CLI, the background task runs in a completely isolated session. Once it completes, the user gets a summary text box — but nothing else. There is no way to:

  1. See what files were created/modified — the background agent may scaffold an entire project, but the foreground agent and user have zero visibility into what changed on disk
  2. Access logs of what the background agent did — no tool call history, no terminal output, no execution trace
  3. Query status from the foreground agent — asking "how far is the background task" gets "no active task" because the foreground agent's session has no reference to background sessions
  4. Use /bg status — this gets parsed as /background status which spawns a NEW background task with the prompt "status" instead of showing background task status

Steps to Reproduce

  1. Run /background can you code on port 7373 an html website about brudi ai
  2. While it runs, ask the foreground agent: "how far is the background task?"
  3. Agent responds with "no active task" — it has no knowledge of the background session
  4. When the task completes, the ✅ notification appears with a summary
  5. Ask the agent to clean up the files from that task — it doesn't know which files were created
  6. Try /bg status — it spawns a new background task with prompt "status"

Expected Behavior

  • Background tasks should write a structured log (files created/modified, commands run, errors) to a known location (e.g. ~/.hermes/background_tasks/<task_id>/)
  • The foreground agent should be able to query background task status and results
  • /bg status, /bg log <id>, /bg files <id> should be dedicated subcommands, not parsed as new background prompts
  • On completion, the task summary should be injected into the foreground session history so the agent has context

Actual Behavior

  • No logs written anywhere
  • No file tracking
  • Foreground agent has zero context about background tasks
  • /bg prefix is not parsed as a subcommand namespace

Root Cause

_handle_background_command() in cli.py:5580 creates a separate AIAgent with its own session_id. The docstring explicitly states: "prints the result to the CLI without modifying the active session's conversation history". This means the foreground session never learns about background task results.

The /bg prefix is not registered as a separate command — it falls through to /background which treats everything after it as a prompt.

Affected Component

CLI (interactive chat)

Operating System

Ubuntu 24.04

Python Version

3.12.3

Hermes Version

Hermes Agent v0.8.0

Proposed Fix

  1. Minimal fix: On background task completion, inject a [SYSTEM: Background task #N completed. Files changed: ... Summary: ...] message into the foreground session history so the agent has context on next turn.

  2. Better fix: Write a structured log per background task to ~/.hermes/background_tasks/<task_id>/ containing:

    • log.jsonl — tool calls and results
    • files.txt — list of files created/modified/deleted
    • summary.txt — the final agent response
  3. Register /bg as a subcommand namespace with status, log, files, kill subcommands.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardtype/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions