{"record":{"id":"1281c61b28029b36","repo":"dagger/dagger","slug":"reset-workspace-w","errorCode":null,"errorMessage":"reset workspace: %w","messagePattern":"reset workspace: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/dagger/llm.go","lineNumber":525,"sourceCode":"\t}\n\treturn s.updateChangesPreview(s.llm)\n}\n\n// ResetWorkspace discards the workspace's pending overlay edits, re-binding the\n// LLM to the live workspace without exporting first.\n// It is the ctrl+u action: conceptually the opposite direction of ctrl+s, it\n// \"uploads\" the host's current state to the agent by throwing away the agent's\n// accumulated changes rather than writing them out. The binding goes through\n// Workspace.reloaded so cached host reads from earlier in the session are\n// invalidated and the agent genuinely re-reads whatever is on disk now. Sync\n// eagerly so a failure surfaces here rather than corrupting later saves.\nfunc (s *LLMSession) ResetWorkspace(ctx context.Context) error {\n\tif s.llm == nil {\n\t\treturn fmt.Errorf(\"no LLM session active\")\n\t}\n\treset, err := s.llm.WithWorkspace(s.dag.CurrentWorkspace().Reloaded()).Sync(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reset workspace: %w\", err)\n\t}\n\tif err := s.updateLLM(reset); err != nil {\n\t\treturn err\n\t}\n\tif s.onStep != nil {\n\t\ts.onStep(s)\n\t}\n\treturn s.updateChangesPreview(s.llm)\n}\n\nconst autoCompactReserveTokens = 16_384\n\n// maybeAutoCompact checks whether the current context is inside the response\n// reserve and automatically compacts if so.\nfunc (s *LLMSession) maybeAutoCompact(ctx context.Context) (_ *dagger.LLM, rerr error) {\n\tif !s.ShouldAutocompact() {\n\t\treturn s.llm, nil\n\t}","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/internal/cmd/dagger/llm.go#L507-L543","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the Dagger engine is running and reachable, then retry ResetWorkspace","Check the wrapped inner error for the concrete engine/IO failure and fix it (path exists, permissions, git root)","If reset keeps failing, restart the LLM session to get a fresh workspace binding"],"exampleFix":"// before\nif err := session.ResetWorkspace(ctx); err != nil {\n    return err\n}\n// after\nif err := session.ResetWorkspace(ctx); err != nil {\n    if isTransientEngineErr(err) && retryErr := retry(session.ResetWorkspace, ctx); retryErr == nil {\n        return nil\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"if session == nil || session.LLM == nil {\n    return fmt.Errorf(\"cannot reset: no active session\")\n}\nif _, err := dag.CurrentWorkspace().ID(ctx); err != nil {\n    return fmt.Errorf(\"workspace/engine unreachable before reset: %w\", err)\n}","typeGuard":"func sessionActive(s *LLMSession) bool { return s != nil && s.llm != nil }","tryCatchPattern":"err := session.ResetWorkspace(ctx)\nfor i := 0; err != nil && i < 3; i++ {\n    time.Sleep(backoff(i))\n    err = session.ResetWorkspace(ctx)\n}\nreturn err","preventionTips":["Ensure the Dagger engine is healthy before resetting (health check ping)","Do not delete or rename the workspace directory mid-session","Treat transient engine errors as retryable; permanent ones (permissions) as fatal"],"tags":["dagger","llm","workspace","engine"],"backgroundTag":"workspace-reset-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}