CSE Roadmap

Common tier · about 5 hours · 6 parts

Part 2 of 6 · 3 min read

Definitions and setup

Covers: Definitions; The loop; A worked example.

Definitions

Workspace, scratchpad, offloading

  • Workspace: a directory the agent can read and write only through confined file tools.
  • Scratchpad: a file (or a state object) where the agent writes working notes: findings, progress, intermediate results.
  • Offloading: saving a large tool output to a file and leaving only a stub in the window.

Stub, handle, on-demand read

  • Stub: the short text that replaces the data in the window: path, size, a first line.
  • Handle: anything that lets the agent get the data back later; here, the path.
  • On-demand read: fetching only the needed part with grep (matching lines) or read(start, n) (a line range), with a cap on the result.

Path confinement, symlink escape, atomic write

  • Path confinement: every path is resolved and checked to lie under the workspace root. Resolving matters: a/../../x and a symlink inside the workspace pointing outside both escape a naive prefix check.
  • Symlink escape: a link inside the workspace whose target is outside it.
  • Atomic write: write to a temporary file and rename it over the target, so a reader (or a crash) sees the old file or the new one, never half of one.

The loop

AAAWgmp1bWIAAAAeanVtZGMycGEAEQAQgAAAqgA4m3EDYzJwYQAAABZcanVtYgAAAEdqdW1kYzJtYQARABCAAACqADibcQN1cm46YzJwYToxMDgxOThjNy03YWYwLTQxOTItYWVjZi1jOWJlZDEzMDVlNjcAAAADl2p1bWIAAAApanVtZGMyYXMAEQAQgAAAqgA4m3EDYzJwYS5hc3NlcnRpb25zAAAAALxqdW1iAAAARGp1bWRjYm9yABEAEIAAAKoAOJtxE2MycGEuaW5ncmVkaWVudC52MwAAAAAYYzJzaI2T4GtPPiohzDMvE2BkRygAAABwY2JvcqNpZGM6Zm9ybWF0bWltYWdlL3N2Zyt4bWxqaW5zdGFuY2VJRHgseG1wOmlpZDphZjk3MGE1NC1mYTBiLTQzMjctYjQ5ZS1iOGU2NmNkNTRmY2RscmVsYXRpb25zaGlwaHBhcmVudE9mAAAB4mp1bWIAAABBanVtZGNib3IAEQAQgAAAqgA4m3ETYzJwYS5hY3Rpb25zLnYyAAAAABhjMnNoTBb7m8kXveCPBZwcdadTJgAAAZljYm9yomdhY3Rpb25zgqJmYWN0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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQHz5NIQOExY7pEH4JPTIoP35vdmzRBgMJIrhmdTS4yGFyPADe1El44tl3QzGVpLOlER38R8U5vPnu05m+UQR+6s=The window holds handles; the workspace holds the datatool outputabout 1,000 tokens123 lineswriteworkspace (files on disk)out/step01.txt out/step02.txt ...notes.md (flagged findings, one line each)paths confined to the root; writes are atomicreads and greps are capped at 400 tokensstub onlywindowpath, size, first lineabout 25 tokens per outputwhen the answer is neededgrep / read a rangereturns only the matching linesthe fileunchanged, completeNothing is lost by offloading: the cost moves from every step to the steps that ask.
The window holds handles. The workspace holds the data. A read returns only the lines asked for.

Three design choices are visible here, and each is a trade-off an interviewer will ask about:

  1. What goes in the stub. Enough for the agent to decide whether to open the file (title, size), not enough to answer from. A stub that contains the answer defeats the purpose; a stub with no title forces the agent to open everything.
  2. What goes in notes. Notes are always in the window, so every line has a standing cost. They should hold decisions and findings, not raw output. Notes are lossy by construction: whatever was not flagged at write time is not there.
  3. How reads are capped. An uncapped read can pull the whole file back and undo the saving. The workspace truncates a result at 400 tokens and says how to continue.

A worked example

Twelve tool outputs arrive over twelve steps (an API trace, an invoice scan, release notes, and so on), each about 960 tokens, 123 lines. Six questions follow: two about a flagged total, three about an unflagged reference code, one needing two totals from different outputs.

Offload: the window holds only stubs:
   [tool output saved to out/step01.txt: 962 tokens, 123 lines; first line: # api trace]
   [tool output saved to out/step02.txt: 943 tokens, 123 lines; first line: # release notes]

Question: What reference code appeared in the release notes?
agent runs grep('out/step02.txt', 'reference code') and gets:
   9: detail: release notes reference code K-2424

The 962-token output costs about 25 tokens in the window and about 20 tokens to read the one line that answers the question.