Skip to content

fix(core): stop requiring FileSystem to start a session - #47

Merged
K-Mistele merged 1 commit into
mainfrom
fold-session-optional-filesystem
Sep 29, 2026
Merged

K-Mistele merged 1 commit into
mainfrom
fold-session-optional-filesystem

Conversation

@K-Mistele

Copy link
Copy Markdown
Contributor

Problem

startSession and resumeSession required FileSystem.FileSystem in every case. assembleSessionGraph ran yield* FileSystem.FileSystem unconditionally, and defineTool added FileSystem to every tool's dependencies. A session with a memory log and a pure tool (see fold-core/examples/AnthropicAgent.ts) still had to provide NodeFileSystem.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, Path and ChildProcessSpawner out of the caller's context, if present, and passes them to:

  • tool init effects, at start and on switchModel
  • the event log source's make
  • the session service graph, which Effect AI's toolkit hands to tool handlers. Path and ChildProcessSpawner already reached handlers this way.

Descriptors that need disk keep working unchanged: coding tools declare platformToolDependencies, and jsonlEventLog and skillsFromDisk declare FileSystem. 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:

  • Removed FileSystem from ToolHandlerServices, defineTool's default dependencies, liveToolRuntimeLayer, Toolset.handle and SessionProvisioningServices.
  • Exported a PlatformServices type (previously the private PlatformToolServices).
  • Removed NodeFileSystem.layer from the fold-core examples that don't use disk.

Tradeoff

A direct startSession caller that uses jsonlEventLog or the coding tools no longer gets a compile error if it forgets to provide FileSystem. It gets a defect at runtime instead, as Path and ChildProcessSpawner users already did. fold-agent's launchSession still requires FileSystem in its own signature, so the CLI path keeps the static check. Keeping the check everywhere would mean threading a generic R through FoldTool, agent and subagent definitions, and FoldSession. That is a much larger change.

The repo lint bans Effect.serviceOption, so the code reads the caller's context with Effect.context + Context.pick, the same way Effect AI's Toolkit.toHandlers captures handler context.

Tests

  • New: a tool-calling session runs with no FileSystem provided.
  • New: a handler that declares platformToolDependencies reads the FileSystem the caller provided.
  • bun run typecheck, bun run test, bun run lint and bun run format:check all pass.

🤖 Generated with Claude Code

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
@K-Mistele
K-Mistele merged commit 00a1e29 into main Sep 29, 2026
5 checks passed
@K-Mistele
K-Mistele deleted the fold-session-optional-filesystem branch September 29, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant