fix(agent): keep default prompt paths relative

This commit is contained in:
chengyongru
2026-08-21 11:45:05 +08:00
committed by chengyongru
parent c7710238a8
commit 8ca4bd9121
11 changed files with 94 additions and 21 deletions
+4 -1
View File
@@ -123,7 +123,10 @@ class ContextBuilder:
if active_content:
parts.append(f"# Active Skills\n\n{active_content}")
skills_summary = self.skills.build_skills_summary(exclude=set(active_skills))
skills_summary = self.skills.build_skills_summary(
exclude=set(active_skills),
workspace=root,
)
if skills_summary:
parts.append(render_template("agent/skills_section.md", skills_summary=skills_summary))
+16 -2
View File
@@ -201,7 +201,12 @@ class SkillsLoader:
),
)
def build_skills_summary(self, exclude: set[str] | None = None) -> str:
def build_skills_summary(
self,
exclude: set[str] | None = None,
*,
workspace: Path | None = None,
) -> str:
"""
Build a summary of all skills (name, description, path, availability).
@@ -210,6 +215,7 @@ class SkillsLoader:
Args:
exclude: Set of skill names to omit from the summary.
workspace: Effective project workspace used to choose safe display paths.
Returns:
Markdown-formatted skills summary.
@@ -218,6 +224,9 @@ class SkillsLoader:
if not all_skills:
return ""
agent_workspace = self.workspace.expanduser().resolve()
project_workspace = (workspace or self.workspace).expanduser().resolve()
use_relative_roots = project_workspace == agent_workspace
sections: list[str] = []
groups = (
("Workspace skills", "workspace", self.workspace_skills),
@@ -233,7 +242,12 @@ class SkillsLoader:
if not entries:
continue
lines = [f"### {label} (`{root.expanduser().resolve()}`)"]
resolved_root = root.expanduser().resolve()
if use_relative_roots:
display_root = Path("plugins" if source == "plugin" else "skills")
else:
display_root = resolved_root
lines = [f"### {label} (`{display_root}`)"]
for entry in entries:
skill_name = entry["name"]
meta = self._get_skill_meta(skill_name)
+7 -2
View File
@@ -540,12 +540,17 @@ class SubagentManager:
skills_summary = SkillsLoader(
self.workspace,
disabled_skills=self.disabled_skills,
).build_skills_summary()
).build_skills_summary(workspace=project_workspace)
history_log = (
str(agent_workspace / "memory" / "history.jsonl")
if agent_workspace != project_workspace
else "memory/history.jsonl"
)
return render_template(
"agent/subagent_system.md",
workspace=str(project_workspace),
agent_workspace=str(agent_workspace),
history_log=str(agent_workspace / "memory" / "history.jsonl"),
history_log=history_log,
skills_summary=skills_summary or "",
)
+3 -3
View File
@@ -15,8 +15,8 @@ description: Search conversation history and understand Dream-managed profile an
## Search Past Events
Use the absolute `History log` path shown in the system prompt. Always pass it to
`grep`; never substitute a project-relative `memory/history.jsonl`, which may belong
Use the `History log` path shown in the system prompt. Always pass it to `grep`;
never substitute a different project-relative `memory/history.jsonl`, which may belong
to the selected project. Each JSONL line contains `cursor`, `timestamp`, and `content`.
- For broad searches, start with `output_mode="count"` or the default
@@ -25,7 +25,7 @@ to the selected project. Each JSONL line contains `cursor`, `timestamp`, and `co
- Use `fixed_strings=true` for literal timestamps or JSON fragments
- Use `head_limit` / `offset` to page through long histories
Examples (replace `<history-log-path>` with the absolute path from the system prompt):
Examples (replace `<history-log-path>` with the path from the system prompt):
- `grep(pattern="keyword", path="<history-log-path>", case_insensitive=true)`
- `grep(pattern="2026-04-02 10:00", path="<history-log-path>", fixed_strings=true)`
- `grep(pattern="keyword", path="<history-log-path>", output_mode="count", case_insensitive=true)`
+6 -2
View File
@@ -2,14 +2,18 @@
{{ runtime }}
## Workspace
Your current project workspace is at: {{ workspace_path }}
{% if agent_workspace_path != workspace_path %}
Nanobot's agent workspace is at: {{ agent_workspace_path }}
{% endif %}
- Agent profile: {{ agent_workspace_path }}/SOUL.md and {{ agent_workspace_path }}/USER.md (automatically managed by Dream — do not edit directly)
- Long-term memory: {{ agent_workspace_path }}/memory/MEMORY.md (automatically managed by Dream — do not edit directly)
- History log: {{ agent_workspace_path }}/memory/history.jsonl (append-only JSONL; prefer built-in `grep` for search).
- Custom skills: {{ agent_workspace_path }}/skills/{% raw %}{skill-name}{% endraw %}/SKILL.md
{% else %}
- Agent profile: SOUL.md and USER.md (automatically managed by Dream — do not edit directly)
- Long-term memory: memory/MEMORY.md (automatically managed by Dream — do not edit directly)
- History log: memory/history.jsonl (append-only JSONL; prefer built-in `grep` for search).
- Custom skills: skills/{% raw %}{skill-name}{% endraw %}/SKILL.md
{% endif %}
{{ platform_policy }}
{% if channel == 'telegram' or channel == 'qq' or channel == 'discord' %}
+1 -1
View File
@@ -1,5 +1,5 @@
# Skills
The following skills extend your capabilities. Each group lists one absolute root and relative SKILL.md paths; join them when using `read_file`.
The following skills extend your capabilities. Each group lists one root and relative SKILL.md paths; join them when using `read_file`.
{{ skills_summary }}
+1 -2
View File
@@ -6,7 +6,6 @@ Stay focused on the assigned task. Your final response will be reported back to
{% include 'agent/_snippets/untrusted_content.md' %}
## Workspace
Current project workspace: {{ workspace }}
{% if agent_workspace != workspace %}
Nanobot's agent workspace: {{ agent_workspace }}
{% endif %}
@@ -15,7 +14,7 @@ History log: {{ history_log }}
## Skills
Each group lists one absolute root and relative SKILL.md paths. Join them when using `read_file`.
Each group lists one root and relative SKILL.md paths. Join them when using `read_file`.
{{ skills_summary }}
{% endif %}