Repository navigation
🤖 refactor: the turn's scratchpad, memory context, scratch dir and transcript index go through SessionFiles - #7430
Merged
Merged
Conversation
…anscript index go through SessionFiles
…ndex use the files they were given
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
🟢 e2e stories (Haiku): 14 passed27 agent steps · 7 replayed from cache · 31 model calls · 219.0k tokens (70% cached) All 14 tests in 9 files
e2e 0.20.0 · 3m 2s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 8.0k tokens (21% cached) All 3 tests in 3 files
e2e 0.20.0 · 21.5s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 5.3s · 2 targets (web, phone) · run artifacts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
5b PR 3 of phase 5 (Loop host I/O) of the agent-loop refactor. Four modules that an agent turn reaches read and write their files through injected file services instead of
fs/promises,osandwriteFileAtomic:additionalSystemContext.ts: the scratchpad (additional-system-context.md) and its disabled marker.memoryContextPersistence.ts: the memory-context file of the context window.runtimeScratchDir.ts: the host scratch dir, and the Docker client config read of the devcontainer mount check.subagentTranscriptArtifacts.ts: the sub-agent transcript index.The session-dir files go through
SessionFiles(phase 2). The turn passes theSessionFilesof its HistoryService, so a memory layer keeps these files off the disk too. The Docker client config (~/.docker) is no session file, so that read goes throughHostFilesandHostPaths(5a PR 5).Behavior does not change: every default is the Node layer (
nodeSessionFiles,nodeHostFiles,nodeHostPaths), which calls the samefs/promisesfunctions,os.homedir(),ensurePrivateDirandwriteFileAtomic.Order
Plan order: stack 5b is PR 1 to PR 9. This PR waits for phase 2 PR 7 and phase 4 PR 14 (#7425, merged), which changed
updateSubagentTranscriptArtifactsFile. It uses no code of 5b PRs 4 and 5, so it opens on its own, with base main.Implementation
additionalSystemContext.ts:readAdditionalSystemContextandwriteAdditionalSystemContexttake an optional lastfilesargument (defaultnodeSessionFiles).ensurePrivateDirisfiles.ensurePrivateDir.memoryContextPersistence.ts: theMemoryContextStoreconstructor takesfiles(same default).AgentSessionpasseshistoryService.files.runtimeScratchDir.ts:ensureScratchDirForSpectakesfilesafterabortSignal, andRemoteScratchDirCache.ensureforwards an optionalfiles. Both create the host and devcontainer-mount dirs, which are in the session dir.canBindMountHostPathsIntoContainerstakes the home dir fromnodeHostPaths.userHome()and gets aHostFilesargument.subagentTranscriptArtifacts.ts:readSubagentTranscriptArtifactsFiletakesfiles, andupdateSubagentTranscriptArtifactsFileandupsertSubagentTranscriptArtifactIndexEntrytakefiles?besidelocks.HistoryServicepassesthis.filesto its 2 index reads.turnRequestBuilder.ts: the scratchpad read and both scratch-dir calls passhistoryService.files.InstructionsService(the scratchpad panel), the child-artifact roll-up ofWorkspaceService(its copies still callfs/promises),artifactsOperations.tsandterminalService.ts.The plan estimated about 360 lines. This PR adds 266 and removes 47.
Validation
pairs.mjs --phase5lists no host import in the 4 files (it listed 2 in each on main).additionalSystemContext.test.ts: the scratchpad and its marker are in the memory volume, the Node default reads none, and the temp dir on disk stays empty.memoryContextPersistence.test.ts: save, load and discard work in memory, and the session dir on disk does not exist.runtimeScratchDir.test.ts:ensureScratchDirForSpeccreates the host dir in memory only.canBindMountHostPathsIntoContainersreads a client config that exists only in memory HostFiles and names a remote context (false), while the disk without a config gives true.historyService.test.ts: a transcript index written through memorySessionFilesis in memory and not on disk, andgetSubagentTranscriptfinds it by owner and by session scan.additionalSystemContext.test.ts,agentSession*.test.ts,runtimeScratchDir.test.ts,historyService*.test.ts) plus the golden and contract tests ofsessionFiles/,memoryContextPersistence,subagentTranscript*,instructionsService,turnRequestBuilder*,terminalService*,artifactsOperations*,DevcontainerRuntime*andsessionLocks/: 2476 pass, 0 fail in 94 files.make static-check,make lint-eslint,make crap-checkandmake dry-checkpass. crap-check warns only that theAgentSessionconstructor andprepareOrThroware touched hotspots, with unchanged complexity.make test(host suite lock) on head 0c9c084:bun test srchad 27908 pass, 7 skip, 1 fail. The failure wasBackgroundProcessManager > terminate > should deliver SIGTERM to the bash process(a 3 s timeout under a host load of 13). Its file passed twice on a rerun (166 pass, 0 fail). The shared scripts/storybook/vscode run had 729 pass, 1 skip, 0 fail, and the 18 isolated files had 0 fail. Loop-test tripwire, 3 runs against main: 0 trips.workspaceRemoval,sessionUsageService*andutils/journal/) have 2582 pass, 0 fail in 101 files.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$197.19