Skip to content

Commit 6ba2a96

Browse files
Merge pull request #865 from corbitsdev/cl-7617-only-prompt-read_file-of-a-uri-when-truncation-named-one
Gate tool-output URI reads on named truncation notices
2 parents 52e811b + c7bad0f commit 6ba2a96

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/agent/prompts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function buildHarnessFacts(
7878
"- Shell file-writes and deletions are blocked; never use echo/heredoc/sed/rm as a substitute for product tools. Path tools are the DIY surface.",
7979
]),
8080
"- Use the provided tools for file reads/searches instead of shelling out as a substitute.",
81-
"- read_file accepts a filesystem path or a tool-output:///{callId} URI from a prior tool result when the harness exposes one; prefer the URI over re-reading huge blobs.",
81+
"- read_file accepts a filesystem path or a tool-output:///{callId} URI from a prior tool result when the harness exposes one. Only read_file a tool-output:// URI if the truncation notice on that result named one; do not re-read a complete inline result.",
8282
"- run_shell has no default timeout; pass timeout for builds, tests, and other long commands. Prefer background:true for builds, test suites, and dev servers: it returns a shell_id at once, the result is delivered when the process finishes (foreground runs hold steers; background runs do not), and shell_collect collects or cancels later. background does not change the retained shell cwd.",
8383
"- Shell find, rg, and grep -r are blocked — they can walk huge trees and OOM the host. Prefer the bounded grep/search_files tools, and do not substitute another unbounded walk (fd, ls -R, scripted os.walk).",
8484
...(subAgent
@@ -226,7 +226,7 @@ export function buildPromptDisciplineBlock(
226226

227227
const TOOL_SUMMARIES: Record<string, string> = {
228228
read_file:
229-
"read a file or tool-output:///{callId} from a prior tool result (prefer over cat/head/tail in the shell)",
229+
"read a file or tool-output:///{callId} from a prior tool result (prefer over cat/head/tail in the shell). Only read_file a tool-output:// URI if the truncation notice named one",
230230
write_file: "create or overwrite a file (never shell redirects or heredocs)",
231231
edit_file:
232232
"make a surgical edit (exact old_string match, or start_line/end_line line-range mode; never include read_file's NNNNNN\\t line prefix; substring failures include nearby file text; prefer over sed/awk in the shell)",

src/prompts.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,26 @@ test("harness facts state only the non-derivable tool and safety rules", () => {
8787
expect(facts).not.toContain("Tool results already render richly");
8888
});
8989

90+
test("harness facts gate tool-output URI reads on a named truncation notice", () => {
91+
const facts = buildHarnessFacts();
92+
expect(facts).toContain("read_file");
93+
expect(facts).toMatch(/filesystem path/i);
94+
expect(facts).toMatch(/tool-output:\/\//);
95+
expect(facts).toContain("truncation notice on that result named one");
96+
expect(facts).toContain("do not re-read a complete inline result");
97+
expect(facts).not.toMatch(/prefer the URI/i);
98+
expect(facts).not.toMatch(/re-reading huge blobs/i);
99+
});
100+
101+
test("read_file catalog summary gates tool-output URI reads on truncation", () => {
102+
const listed = buildAvailableTools(["read_file"]);
103+
expect(listed).toContain("read_file");
104+
expect(listed).toMatch(/tool-output:\/\//);
105+
expect(listed).toContain("truncation notice named one");
106+
expect(listed).toContain("cat/head/tail");
107+
expect(listed).not.toMatch(/prefer the URI/i);
108+
});
109+
90110
test("harness facts name skill_search as a resident catalog tool", () => {
91111
const facts = buildHarnessFacts();
92112
expect(facts).toMatch(

0 commit comments

Comments
 (0)