Skip to content

fix(sdk): improve path matching for ls_info method in root directory#1657

Open
刘康伟 (lksr1201) wants to merge 1 commit intolangchain-ai:mainfrom
lksr1201:patch-2
Open

fix(sdk): improve path matching for ls_info method in root directory#1657
刘康伟 (lksr1201) wants to merge 1 commit intolangchain-ai:mainfrom
lksr1201:patch-2

Conversation

@lksr1201
Copy link

Problem Description

In the deepagents/backends/store.py file, the ls_info method fails to list files directly in the root directory ("/") such as "test.md". This is because the current filtering logic requires file paths to start with the normalized path ("/"), but direct files like "test.md" don't meet this condition.

Reproduction Steps

  1. Create a file directly in the root directory, e.g., "test.md"
  2. Call the ls_info("/") method
  3. Observe the returned result, noting that "test.md" is not in the result list ## Expected Behavior
    ls_info("/") should return all files and directories in the root directory, including files directly in the root directory (like "test.md").

Actual Behavior

ls_info("/") only returns subdirectories in the root directory, not files directly in the root directory.

Root Cause

In the ls_info method, the filtering logic at lines 314-316 is:

(Replace this entire block of text)

Read the full contributing guidelines: https://docs.langchain.com/oss/python/contributing/overview
If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

Thank you for contributing to Deep Agents! Follow these steps to have your pull request considered as ready for review.

  1. PR title: Should follow the format: TYPE(SCOPE): DESCRIPTION
  1. PR description:
  • Write 1-2 sentences summarizing the change.
  • If this PR addresses a specific issue, please include "Fixes #ISSUE_NUMBER" in the description to automatically close the issue when the PR is merged.
  • If there are any breaking changes, please clearly describe them.
  • If this PR depends on another PR being merged first, please include "Depends on #PR_NUMBER" in the description.
  1. Run make format, make lint and make test from the root of the package(s) you've modified.
  • We will not consider a PR unless these three are passing in CI.
  1. How did you verify your code works?

Additional guidelines:

  • We ask that if you use generative AI for your contribution, you include a disclaimer.
  • PRs should not touch more than one package unless absolutely necessary.
  • Do not update the uv.lock files or add dependencies to pyproject.toml files (even optional ones) unless you have explicit permission to do so by a maintainer.

Social handles (optional)

Twitter: @
LinkedIn: https://linkedin.com/in/

## Problem Description
In the deepagents/backends/store.py file, the ls_info method fails to list files directly in the root directory ("/") such as "test.md". This is because the current filtering logic requires file paths to start with the normalized path ("/"), but direct files like "test.md" don't meet this condition.

## Reproduction Steps
1. Create a file directly in the root directory, e.g., "test.md"
2. Call the ls_info("/") method
3. Observe the returned result, noting that "test.md" is not in the result list
## Expected Behavior
ls_info("/") should return all files and directories in the root directory, including files directly in the root directory (like "test.md").

## Actual Behavior
ls_info("/") only returns subdirectories in the root directory, not files directly in the root directory.

## Root Cause
In the ls_info method, the filtering logic at lines 314-316 is:
@github-actions github-actions bot added deepagents Related to the `deepagents` SDK / agent harness external User is not a member of the `langchain-ai` GitHub organization fix A bug fix (PATCH) labels Mar 5, 2026
@eyurtsev
Copy link
Collaborator

If easy would you be willing to add a unit test that shows the failure with store?

@mdrxy Mason Daugherty (mdrxy) changed the title fix: Improve path matching for ls_info method (deepagents.backends.store.backend) in root directory fix(sdk): improve path matching for ls_info method in root directory Mar 5, 2026
@github-actions github-actions bot added fix A bug fix (PATCH) and removed fix A bug fix (PATCH) labels Mar 5, 2026
@lksr1201
Copy link
Author

ls_unittest.py

Unit Test for ls_info Root Directory Bug

I've created a comprehensive unit test that demonstrates the failure of the ls_info method when listing files directly in the root directory. Here's a brief introduction:

Test Overview

This unit test verifies the bug in the ls_info method where files directly in the root directory (like "test.md") are not listed when calling ls_info("/"). The test:

  1. Creates a mock store that returns two items:

    • A file "test.md" directly in the root directory
    • A file "subdir/file.txt" in a subdirectory
  2. Tests two scenarios:

    • test_ls_info_root_directory: Verifies that ls_info("/") lists both the root file and subdirectory
    • test_ls_info_subdirectory: Verifies that ls_info("/subdir") lists files in subdirectories (as a control test)
  3. Includes debugging output to show the flow of data and help diagnose the issue

Expected Behavior

When running the test, you'll see that:

  • The mock store correctly returns both items
  • However, ls_info("/") returns an empty list instead of including "test.md"
  • This confirms the bug where files directly in the root directory are filtered out

Test Structure

The test uses a mock store and runtime to isolate the ls_info method behavior, making it easy for maintainers to reproduce and verify the issue without needing a full store setup.

The test code is self-contained and can be run directly to demonstrate the failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepagents Related to the `deepagents` SDK / agent harness external User is not a member of the `langchain-ai` GitHub organization fix A bug fix (PATCH)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants