Skip to content

Composite backend doesn't respect path->backend mapping #241

@alvedder

Description

Please let me know whether it's expected behavior or not, if the latter then I can submit a PR.

Description

Composite backend is supposed to route requests to backends based on path mapping, yet globInfo and grepRaw do not respect the path mapping configuration

Current Behavior

Both globInfo and grepRaw follow the same algorithm:

  1. try to find a backend by the path mapping configuration and delegate the command
  2. if a matching routed backend is not found delegate the command to the default backend
  3. keep delegating to each and every routed backend no matter what the path config says

grepRaw implementation
globInfo implementation

Expected Behavior

I'd expect step 3 to be dropped: if no routed backend is found then delegate only to the default backend and return the result.
Routed backends are configured for a reason and from my perspective they should be used for matching paths only.

Reproduction

For a setup like this

new CompositeBackend(workspaceFs, { // a remote sandbox
    'memory/': configsFs, // host machine's filesystem
    'skills/': configsFs, // same
})

a tool call like this

"tool_calls": [
  {
    "name": "grep",
    "args": {
      "path": "/workspace",
      "pattern": "index",
      "glob": "**/*"
    },
    "id": "call_eheeJEPNpT70OljJ5eYlrrbe",
    "type": "tool_call"
  }
]

will trigger composite backend to search within configsFs backend which in my case fails with "EPERM: operation not permitted, scandir '/Library/Bluetooth'" (which is expected on a MacOS machine)

Environment
deepagents: 1.8.0

Workaround

I extended CompositeBackend in my repo and fully overrode globInfo and grepRaw

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions