Tutorial 15 - Investigate Documents with a Pipeline¶
Time 6 min · Difficulty ★★☆ · Surfaces Agentic Chat
Goal
Point the agent at a document it has never seen and let it dig the facts out with filesystem primitives - the Unix pipeline way (find | grep -C | wc -l), one tool call per step. You apply the Document detective preset and ask about a contract you have not pasted; the model calls requestFileUpload, you pick the file, and the agent hunts the clause down with grepFile and sliceFile, quoting it back with exact line numbers.
Steps¶
-
Open Agentic Chat, click the Prompt Library (clipboard) icon, and pick the Document detective preset from the Presets group. Apply to chat loads it into the Agentic Chat Setting drawer; Apply & New Chat commits it, and the Apply preset tools dialog then asks to publish the preset's twelve tools -
requestFileUploadplus the read pipeline (findFiles,searchInFiles,grepFile,sliceFile,lineCount, ...). Click Apply. -
Ask about a document you have not pasted - for example
I have a contract file. Find the late delivery penalty clause and quote it with its exact line numbers.The model realizes it cannot read what it does not have and callsrequestFileUpload- the chat opens an Upload a file dialog mid-conversation.Use a tool-capable model
This preset asks the model to chain several filesystem calls, which is more than the shipped
qwen3.5:4bdefault reliably manages: it tends to narrate the plan ("Step 1: check allowed directories") as text instead of calling the tools, and then no upload dialog ever opens. Switch toqwen3.5:9borgemma4:e4bin Agentic Chat Setting before you start - the run below isqwen3.5:9b.
The model writes the ask itself - here Please upload your contract file so we can analyze it for late delivery penalty clauses. The same human-in-the-loop seam as tool approvals: the turn pauses until you hand over a file or cancel. Excel converts to CSV in the browser before anything is stored.
- Pick the file. It lands under the conversation workspace at
uploads/<name>and the tool returns that path to the model, which reads it and answers with the clause quoted at its exact line numbers - evidence, not paraphrase. The preset scales the tooling to the file: a small contract like this one is read whole withreadTextFile; on a large document it switches togrepFile numbered=trueto pin the matching line andsliceFileto pull a context window around it.
Every claim carries a verbatim quote and a line number - the grep -n discipline as an agent behavior - and the answer ends with the Pipeline Steps it actually ran: listAllowedDirectories() to find the roots, requestFileUpload(...) to get the file, readTextFile(...), lineCount(...), grepFile(...) to pin the match, then sliceFile(start=3, end=8) for the context window. The run meta above it reports the cost of that discipline - here 135.8s · 27,908 tokens.
- No upload needed when the documents are already on disk: give it a folder path instead -
Search every file under ~/contracts for the word "penalty"- and the agent sweeps it withfindFiles+searchInFiles, then slices context around each hit, exactly like the preset card's captured run.
What to observe¶
- The upload is saved under the conversation workspace (
workspace/<conversationId>/uploads/) - each chat keeps its own files, and deleting the conversation removes them. - The pipeline idiom maps one-to-one:
findFiles=find,grepFile numbered=true=grep -n,sliceFile=sed -n 'a,bp',lineCount=wc -l,sortFile/cutFileFields=sort/cut. - Everything here is read-only (
L3) - unlike the write tools in Tutorial 13, no approval prompt is needed to search and quote. - Excel (
.xlsx/.xls) converts to CSV in the browser before upload; the server only ever stores text.
Why this matters
Contracts, reports, exports, logs from another machine - most real documents are files, not paste-able text. The upload dialog plus the read pipeline turns "let me summarize what I think it says" into "line 5 says exactly this", with the evidence trail to prove it. The full preset reference is at Prompt Presets → Document detective.