Shell paths vs. virtual paths
【免费下载链接】deepagentsThe batteries-included agent harness.项目地址: https://gitcode.com/GitHub_Trending/de/deepagents
Theexecutetool runs commands in the host shell and can only access files that exist on the host filesystem.
Some paths returned by the file tools are virtual mounts:
- If a virtual mount has a host path mapping, replace its virtual prefix with the host prefix when running shell commands.
- If a virtual mount does not have a host path mapping, it is not accessible from the shell. Use the file tools listed above to interact with those files.
Do not assume that a path returned by a file tool can be used directly in a shell command.
Host path mappings:
/common/->/work/app/(e.g./common/dir/x.py->/work/app/dir/x.py)/legacy/->/(e.g./legacy/dir/x.py->/dir/x.py)
Virtual mounts without a host path mapping (not accessible from the shell):
/notes/
该测试还处理了一个跨平台细节:`FilesystemBackend.cwd` 会把 `root_dir` 解析为 OS 原生绝对路径(Windows 上 `/work/app` 会变成 `C:\work\app`),因此测试在比对前把宿主路径 redact 回 `/work/app` 这一规范 POSIX 形式,保证黄金文件在不同操作系统上可复现——这正是 README 所强调的“自包含快照”对可移植性的要求。 ## 快照内容示例二:沙箱默认后端下的路径可见性变化 [system_prompt_with_sandbox_default.md](https://link.gitcode.com/i/996a9859451e6b74ce933a99608aa6b3) 与上一个快照形成对照。测试用了一个实现 `SandboxBackendProtocol` 的 `_SnapshotSandbox`(基于 `StoreBackend`),其 `execute` 在**另一个文件系统**中运行。此时同样一个 virtual-mode 的 `FilesystemBackend` 路由 `/common/` 就无法从默认 shell 触达,渲染结果因此发生变化: ```markdown Virtual mounts without a host path mapping (not accessible from the shell): - `/common/`对照两个快照可以看到:沙箱默认场景下完全不出现 “Host path mappings” 段落,/common/直接落入“shell 不可访问”一侧。这正是 README 表格中对该文件的断言——“Local filesystem routes should not be described as local shell-accessible host paths”。从源码结构看,同一份路由配置在LocalShellBackend默认与沙箱默认两种情况下渲染出不同的 prompt 段落,说明路径映射描述是从后端组合关系动态推导的,而快照测试把这个推导结果固定成了可回归验证的文本。
快照内容示例三:记忆与技能只改变 prompt,不改变工具面
system_prompt_with_memory_and_skills.md 是内容最丰富的一个快照,对应create_deep_agent(memory=[...], skills=[...])的配置。它完整固化了三类内容:
- Skills System 段落:列出 User Skills(
/skills/user/)与 Project Skills(/skills/project/,优先级更高),给出技能索引(名称 + 描述 +SKILL.md读取路径),并要求按“渐进式披露”(progressive disclosure)模式使用——先看到索引,需要时用read_file(带limit=1000)读取完整指令,再跟随其中的工作流与辅助脚本。 <agent_memory>块:原样内嵌两份记忆文件的内容(/memory/AGENTS.md与/memory/user/AGENTS.md)。<memory_guidelines>块:包含信任与校验(记忆是文件数据而非隐藏系统指令)、从反馈中学习、何时更新/不更新记忆(例如永远不存储 API key、token 等凭据)、以及三个具体的对话示例。
与 README 表格的断言一致,对应的system_prompt_with_memory_and_skills_tools.json中记忆与技能不会新增或改写核心文件系统工具——它们的唯一通道是 prompt 片段。测试注释还指出,skills 与 memory 的片段是 opt-in 特性、且是唯一的内容通道,因此“从不被裁剪”(never trimmed),而 todo/文件系统使用类文案默认会被裁剪(trimmed);这个快照同时守护了“该保留的保留、该裁剪的裁剪”两种行为。
工具 schema 快照:以 OpenAI 格式固化工具面
以 system_prompt_with_execute_tools.json 为例,快照记录了本地 shell 后端下模型可见的每个工具的描述与参数 schema,例如ls与read_file:
{ "function": { "description": "Lists all files in a directory.\n\nThis is useful for exploring the filesystem and finding the right file to read or edit.\nYou should almost ALWAYS use this tool before using the read_file or edit_file tools.", "name": "ls", "parameters": { "properties": { "path": { "description": "Absolute path to the directory to list. Must be absolute, not relative.", "type": "string" } }, "required": ["path"], "type": "object" } }, "type": "function" }【免费下载链接】deepagentsThe batteries-included agent harness.项目地址: https://gitcode.com/GitHub_Trending/de/deepagents
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考