LangEx.Middleware.Filesystem (LangEx v0.12.0)

Copy Markdown View Source

Middleware that gives the agent a state-backed virtual workspace.

Contributes six file tools (ls, read_file, write_file, edit_file, glob, grep) plus a :workspace state key holding a path => content map. The agent offloads large artifacts — evidence excerpts, long tool outputs, draft documents — out of chat history into named files it can re-read, search, and edit in later rounds. The workspace lives in graph state (and therefore in checkpoints), so files persist across rounds and survive context summarization.

Writes are merged with Map.merge/2, so a write only touches its own path and LangEx.Tool.Node unions concurrent writes from parallel tool calls safely. A nil content is a tombstone: reads, listings, and searches skip it, and the path no longer counts against :max_files.

Encourage use from the agent's system prompt (e.g. "Save large findings to workspace files instead of repeating them in conversation.").

Options

  • :max_file_bytes - reject writes/edits producing a larger file (default 65_536)
  • :max_files - reject new files beyond this count (default 128)

Summary

Functions

Builds a virtual-workspace middleware. See the module doc for options.

Functions

new(opts \\ [])

@spec new(keyword()) :: LangEx.Middleware.t()

Builds a virtual-workspace middleware. See the module doc for options.