Repository navigation
fix(core): stop requiring FileSystem to start a session - #47
Merged
Merged
Conversation
startSession and resumeSession required FileSystem.FileSystem even for a memory log and tools that never touch disk, so hosts without a filesystem (Cloudflare Durable Objects, browsers) had to provide a fake one. The session now passes along whichever platform services (FileSystem, Path, ChildProcessSpawner) its caller provides, the way Path and ChildProcessSpawner already reached tool handlers. Descriptors that declare them - coding tools, the JSONL log, disk skills - still get them; one that declares a service the caller left out dies when it asks for it. - Drop FileSystem from ToolHandlerServices, defineTool's default dependencies, ToolRuntime, Toolset.handle, and provisioning services - Export PlatformServices; disk tools keep opting in through platformToolDependencies - Remove the NodeFileSystem layer from fold-core examples that need none Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> HumanLayer-Session: https://app.dev.codelayer.gg/sessions/01a0ef47-f9da-79e2-a532-a2cd10daaa2b
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.
Problem
startSessionandresumeSessionrequiredFileSystem.FileSystemin every case.assembleSessionGraphranyield* FileSystem.FileSystemunconditionally, anddefineTooladdedFileSystemto every tool's dependencies. A session with a memory log and a pure tool (seefold-core/examples/AnthropicAgent.ts) still had to provideNodeFileSystem.layer. On a host without a filesystem, such as a Durable Object, the caller had to supply a fake one.Change
The session no longer requires platform services. It picks
FileSystem,PathandChildProcessSpawnerout of the caller's context, if present, and passes them to:initeffects, at start and onswitchModelmakePathandChildProcessSpawneralready reached handlers this way.Descriptors that need disk keep working unchanged: coding tools declare
platformToolDependencies, andjsonlEventLogandskillsFromDiskdeclareFileSystem. If one declares a service the caller left out, it dies with a missing-service defect when it asks for it, not at session start.Other changes:
FileSystemfromToolHandlerServices,defineTool's default dependencies,liveToolRuntimeLayer,Toolset.handleandSessionProvisioningServices.PlatformServicestype (previously the privatePlatformToolServices).NodeFileSystem.layerfrom thefold-coreexamples that don't use disk.Tradeoff
A direct
startSessioncaller that usesjsonlEventLogor the coding tools no longer gets a compile error if it forgets to provideFileSystem. It gets a defect at runtime instead, asPathandChildProcessSpawnerusers already did.fold-agent'slaunchSessionstill requiresFileSystemin its own signature, so the CLI path keeps the static check. Keeping the check everywhere would mean threading a genericRthroughFoldTool, agent and subagent definitions, andFoldSession. That is a much larger change.The repo lint bans
Effect.serviceOption, so the code reads the caller's context withEffect.context+Context.pick, the same way Effect AI'sToolkit.toHandlerscaptures handler context.Tests
FileSystemprovided.platformToolDependenciesreads theFileSystemthe caller provided.bun run typecheck,bun run test,bun run lintandbun run format:checkall pass.🤖 Generated with Claude Code