Skip to content

Context breakdown can label virtual bootstrap files as 'undefined' instead of falling back to path/basename #47941

@i0ivi0i

Description

@i0ivi0i

Summary

/context breakdown (or similar context reporting) can show a virtual bootstrap file as undefined even when the injected content is present and counted.

In the observed case, a bootstrap hook injected a virtual file with:

  • path: 'SELF_IMPROVEMENT_REMINDER.md'
  • content present
  • virtual: true

The context report then showed something like:

  • undefined: OK | raw 1966 chars (~492 tok) | injected 1966 chars (~492 tok)

Why this looks like a display-layer bug

The content is clearly present (char/token counts are non-zero), so the problem is not "missing content". It appears the reporting path is using a missing/empty display name and rendering undefined instead of falling back to:

  1. file.name
  2. file.path
  3. basename of file.path
  4. a generic placeholder like (virtual bootstrap file)

Expected behavior

For virtual bootstrap files, context reporting should never render the label as literal undefined if path or basename is available.

Suggested fix

In the breakdown/reporting layer, normalize the label with a fallback chain similar to:

const label =
  nonEmpty(file.name) ??
  nonEmpty(file.path) ??
  basename(file.path ?? '') ??
  '(virtual bootstrap file)'

Also worth considering:

  • if hooks inject virtual bootstrap files with path but no name, display logic should still remain stable
  • if multiple virtual bootstrap files exist, dedupe/reporting should remain deterministic

Notes

I also separately reported to the skill author that adding explicit name + dedupe in the hook would be a useful compatibility hardening. But even without that, the OpenClaw display layer should ideally avoid surfacing literal undefined when enough metadata exists to label the item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    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