Skip to content

fix: GeminiCliSubagent.fromFile() discards subdirectory paths via basename #1424

@dyoshikawa

Description

@dyoshikawa

Background

In PR #1409, GeminiCliSubagent was converted from a simulated subagent (extending SimulatedSubagent) to a native subagent (extending ToolSubagent directly). During this conversion, the fromFile method retained the old basename(relativeFilePath) call from the simulated pattern. However, native subagents (e.g., ClaudecodeSubagent) use relativeFilePath as-is without stripping directory components.

Details

In src/features/subagents/geminicli-subagent.ts, the fromFile method applies basename to relativeFilePath:

relativeFilePath: basename(relativeFilePath),

This means if relativeFilePath contains a subdirectory (e.g., subdir/nested-agent.md), the directory component is silently discarded. This inconsistency with ClaudecodeSubagent.fromFile() (which preserves the full relative path) could cause issues when:

  • Round-tripping subagent files (read -> convert -> write back)
  • Deleting subagent files that live in subdirectories
  • Any operation that relies on the stored relativeFilePath to locate the original file

The existing test ("should handle file path with subdirectories") only checks getBody() and getFrontmatter(), not getRelativeFilePath(), so this gap is not caught.

Solution / Next Steps

  1. Remove the basename call in GeminiCliSubagent.fromFile() and pass relativeFilePath directly, matching the ClaudecodeSubagent pattern.
  2. Update the subdirectory test to also assert that getRelativeFilePath() preserves the full path including directory components.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmaintainer-scrapRough notes for AI implementation. Not for human eyes.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions