Merge pull request 'test: subagents keep project context; general prompt verifies edits' (#161) from test/subagent-context into main
This commit was merged in pull request #161.
This commit is contained in:
commit
e553d2db52
2 files changed
+5
-1
No files matched your search
@@ -230,7 +230,7 @@ impl Sub {
|
|||||||
/// `bash` for a search/grep tool if models ignore that.
|
/// `bash` for a search/grep tool if models ignore that.
|
||||||
pub const EXPLORE_TOOLS: &[&str] = &["read", "lsp", "bash", "skill"];
|
pub const EXPLORE_TOOLS: &[&str] = &["read", "lsp", "bash", "skill"];
|
||||||
pub const EXPLORE_PROMPT: &str = "You are a research subagent of hx. Answer the task by reading code; do not modify anything (no writes, no redirects, no installs). Your final message is the only thing the caller sees: give the answer with file:line references, short, no preamble.";
|
pub const EXPLORE_PROMPT: &str = "You are a research subagent of hx. Answer the task by reading code; do not modify anything (no writes, no redirects, no installs). Your final message is the only thing the caller sees: give the answer with file:line references, short, no preamble.";
|
||||||
pub const GENERAL_PROMPT: &str = "You are a subagent of hx working in the user's repository. Do the task fully with the tools; read files before editing them. Your final message is the only thing the caller sees: say what you changed or found, short, with file paths.";
|
pub const GENERAL_PROMPT: &str = "You are a subagent of hx working in the user's repository. Do the task fully with the tools; read files before editing them, and run the narrowest relevant check (build, test, lint) after editing. Your final message is the only thing the caller sees: say what you changed or found, short, with file paths.";
|
||||||
const MAX_RESULT: usize = 8_000;
|
const MAX_RESULT: usize = 8_000;
|
||||||
|
|
||||||
impl Task {
|
impl Task {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ mkdir -p "$tmp/home/.hx" "$tmp/repo"
|
|||||||
echo '{"claude":{"access":"fake-token","refresh":"r","expires":99999999999999}}' > "$tmp/home/.hx/auth.json"
|
echo '{"claude":{"access":"fake-token","refresh":"r","expires":99999999999999}}' > "$tmp/home/.hx/auth.json"
|
||||||
printf '[lsp]\nmode = "off"\ntests = "off"\n' > "$tmp/home/.hx/config.toml"
|
printf '[lsp]\nmode = "off"\ntests = "off"\n' > "$tmp/home/.hx/config.toml"
|
||||||
echo "secret is 42" > "$tmp/repo/note.txt"
|
echo "secret is 42" > "$tmp/repo/note.txt"
|
||||||
|
echo "PROJECT-RULE-XYZ" > "$tmp/repo/AGENTS.md"
|
||||||
cat > "$tmp/turns.json" <<'J'
|
cat > "$tmp/turns.json" <<'J'
|
||||||
[[["tool_use", {"id": "p1", "name": "Task", "input": {"prompt": "what is in note.txt?"}}]],
|
[[["tool_use", {"id": "p1", "name": "Task", "input": {"prompt": "what is in note.txt?"}}]],
|
||||||
[["tool_use", {"id": "c1", "name": "Read", "input": {"path": "note.txt"}}]],
|
[["tool_use", {"id": "c1", "name": "Read", "input": {"path": "note.txt"}}]],
|
||||||
@@ -33,6 +34,9 @@ assert "haiku" in child1["model"] and "sonnet" in parent["model"], (child1["mode
|
|||||||
assert child1["messages"][0]["content"][0]["text"] == "what is in note.txt?"
|
assert child1["messages"][0]["content"][0]["text"] == "what is in note.txt?"
|
||||||
assert {t["name"] for t in child1["tools"]} == {"Read", "Bash", "skill"}, [t["name"] for t in child1["tools"]]
|
assert {t["name"] for t in child1["tools"]} == {"Read", "Bash", "skill"}, [t["name"] for t in child1["tools"]]
|
||||||
assert "Task" in {t["name"] for t in parent["tools"]}
|
assert "Task" in {t["name"] for t in parent["tools"]}
|
||||||
|
# children get the project context (AGENTS.md) in their system prompt, like the parent
|
||||||
|
for r in (parent, child1, child2):
|
||||||
|
assert "PROJECT-RULE-XYZ" in json.dumps(r["system"]), r["model"]
|
||||||
# parent got only the child's answer (+ stats line), not the Read result
|
# parent got only the child's answer (+ stats line), not the Read result
|
||||||
res = json.dumps(parent2["messages"][-1])
|
res = json.dumps(parent2["messages"][-1])
|
||||||
assert "secret is 42" in res and "[task explore" in res
|
assert "secret is 42" in res and "[task explore" in res
|
||||||
|
|||||||
Reference in new issue
Block a user