Skip to content

Agent: bad /workspace path or failed turn no longer kills the session - #217

Merged
bararchy merged 1 commit into
masterfrom
fix/agent-workspace-crash
Nov 22, 2026
Merged

bararchy merged 1 commit into
masterfrom
fix/agent-workspace-crash

Conversation

@bararchy

Copy link
Copy Markdown
Member

Problem

/workspace ~/some/path crashed the agent with an uncaught File::NotFoundError, ending the session. ~ was not expanded (no shell), and File.realpath raises File::Error, which the handler (rescue ArgumentError) did not catch.

Fix

  • WorkspacePath.resolve_root: expands a leading ~, turns File::Error into ArgumentError("no such directory: ..."). switch_workspace! uses it.
  • REPL: slash-command dispatch and agent.chat are wrapped, so any unexpected error is reported and the session continues. After a failed turn the KV cache is dropped (Agent#drop_cache!) so the next turn re-prefills instead of trusting a cache that may not match the transcript.

Tests

spec/agent_workspace_spec.cr: ~ expansion, missing path (the input that crashed), file instead of directory, canonicalization. 24 examples, 0 failures. Typecheck, format, Ameba clean.

@bararchy
bararchy merged commit 77cbfad into master Nov 22, 2026
5 checks passed
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