dagger/dagger · error

reset workspace: %w

Error message

reset workspace: %w

What it means

ResetWorkspace throws this when discarding pending overlay edits and re-binding the LLM to the reloaded workspace fails during the Sync call. The binding uses Workspace.reloaded to invalidate cached host reads so the agent re-reads disk; a failure here is surfaced eagerly to avoid corrupting later saves, with the engine error wrapped via %w.

Source

Thrown at internal/cmd/dagger/llm.go:525

	}
	return s.updateChangesPreview(s.llm)
}

// ResetWorkspace discards the workspace's pending overlay edits, re-binding the
// LLM to the live workspace without exporting first.
// It is the ctrl+u action: conceptually the opposite direction of ctrl+s, it
// "uploads" the host's current state to the agent by throwing away the agent's
// accumulated changes rather than writing them out. The binding goes through
// Workspace.reloaded so cached host reads from earlier in the session are
// invalidated and the agent genuinely re-reads whatever is on disk now. Sync
// eagerly so a failure surfaces here rather than corrupting later saves.
func (s *LLMSession) ResetWorkspace(ctx context.Context) error {
	if s.llm == nil {
		return fmt.Errorf("no LLM session active")
	}
	reset, err := s.llm.WithWorkspace(s.dag.CurrentWorkspace().Reloaded()).Sync(ctx)
	if err != nil {
		return fmt.Errorf("reset workspace: %w", err)
	}
	if err := s.updateLLM(reset); err != nil {
		return err
	}
	if s.onStep != nil {
		s.onStep(s)
	}
	return s.updateChangesPreview(s.llm)
}

const autoCompactReserveTokens = 16_384

// maybeAutoCompact checks whether the current context is inside the response
// reserve and automatically compacts if so.
func (s *LLMSession) maybeAutoCompact(ctx context.Context) (_ *dagger.LLM, rerr error) {
	if !s.ShouldAutocompact() {
		return s.llm, nil
	}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Verify the Dagger engine is running and reachable, then retry ResetWorkspace
  2. Check the wrapped inner error for the concrete engine/IO failure and fix it (path exists, permissions, git root)
  3. If reset keeps failing, restart the LLM session to get a fresh workspace binding

Example fix

// before
if err := session.ResetWorkspace(ctx); err != nil {
    return err
}
// after
if err := session.ResetWorkspace(ctx); err != nil {
    if isTransientEngineErr(err) && retryErr := retry(session.ResetWorkspace, ctx); retryErr == nil {
        return nil
    }
    return err
}
Defensive patterns

Strategy: retry

Validate before calling

if session == nil || session.LLM == nil {
    return fmt.Errorf("cannot reset: no active session")
}
if _, err := dag.CurrentWorkspace().ID(ctx); err != nil {
    return fmt.Errorf("workspace/engine unreachable before reset: %w", err)
}

Type guard

func sessionActive(s *LLMSession) bool { return s != nil && s.llm != nil }

Try / catch

err := session.ResetWorkspace(ctx)
for i := 0; err != nil && i < 3; i++ {
    time.Sleep(backoff(i))
    err = session.ResetWorkspace(ctx)
}
return err

Prevention

When it happens

Trigger: Calling LLMSession.ResetWorkspace when s.llm.WithWorkspace(s.dag.CurrentWorkspace().Reloaded()).Sync(ctx) fails — engine-side error reading the reloaded workspace or syncing the rebound LLM (engine unreachable, workspace path invalid, epoch/permission problems).

Common situations: Hitting ctrl+u in the LLM TUI while the Dagger engine is down or restarting, the working directory was deleted or became unreadable, or host-read caching state conflicts with the reloaded workspace.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/1281c61b28029b36. Report an issue: GitHub.