Pyramid $OABCD$ has square base $ABCD,$ congruent edges $\overline{OA}, \overline{OB}, \overline{OC},$ and $\overline{OD},$ and $\angle AOB=45^\circ.$  Let $\theta$ be the measure of the dihedral angle formed by faces $OAB$ and $OBC.$  Given that $\cos \theta=m+\sqrt{n},$ where $m$ and $n$ are integers, find $m+n.$
1. **Assume the base and calculate the edge length:**
   Let the side length of the square base \(ABCD\) be \(1\). Since \( \angle AOB = 45^\circ \), we can use the Law of Cosines in triangle \(OAB\) to find the length of \(OA\) and \(OB\).

   \[
   AB^2 = OA^2 + OB^2 - 2 \cdot OA \cdot OB \cdot \cos(45^\circ)
   \]

   Given \(AB = 1\) and \(\cos(45^\circ) = \frac{1}{\sqrt{2}}\), we have:

   \[
   1 = OA^2 + OB^2 - 2 \cdot OA \cdot OB \cdot \frac{1}{\sqrt{2}}
   \]

   Since \(OA = OB\), let \(OA = OB = x\):

   \[
   1 = x^2 + x^2 - 2 \cdot x^2 \cdot \frac{1}{\sqrt{2}}
   \]

   Simplify the equation:

   \[
   1 = 2x^2 - \sqrt{2}x^2
   \]

   \[
   1 = x^2(2 - \sqrt{2})
   \]

   \[
   x^2 = \frac{1}{2 - \sqrt{2}}
   \]

   Rationalize the denominator:

   \[
   x^2 = \frac{1}{2 - \sqrt{2}} \cdot \frac{2 + \sqrt{2}}{2 + \sqrt{2}} = \frac{2 + \sqrt{2}}{4 - 2} = \frac{2 + \sqrt{2}}{2}
   \]

   \[
   x = \sqrt{\frac{2 + \sqrt{2}}{2}}
   \]

2. **Projection and calculation of \(AX\):**
   Let \(P\) be the projection of \(A\) onto \(OB\). By symmetry, \(P\) coincides with the projection of \(C\) onto \(OB\). The length \(AX\) (where \(X\) is the projection of \(A\) onto the line \(OB\)) is:

   \[
   AX = \frac{OA}{\sqrt{2}} = \sqrt{\frac{2 + \sqrt{2}}{2}} \cdot \frac{1}{\sqrt{2}} = \sqrt{\frac{2 + \sqrt{2}}{4}}
   \]

3. **Using the Law of Cosines in triangle \(AXC\):**
   We need to find \(\cos \theta\) where \(\theta\) is the dihedral angle between faces \(OAB\) and \(OBC\). Using the Law of Cosines in triangle \(AXC\):

   \[
   \cos \theta = \frac{XA^2 + XC^2 - AC^2}{2 \cdot XA \cdot XC}
   \]

   Since \(XA = XC\):

   \[
   XA = XC = \sqrt{\frac{2 + \sqrt{2}}{4}}
   \]

   And \(AC = \sqrt{2}\):

   \[
   \cos \theta = \frac{2 \cdot \left(\sqrt{\frac{2 + \sqrt{2}}{4}}\right)^2 - 2}{2 \cdot \left(\sqrt{\frac{2 + \sqrt{2}}{4}}\right)^2}
   \]

   Simplify the expression:

   \[
   \cos \theta = \frac{2 \cdot \frac{2 + \sqrt{2}}{4} - 2}{2 \cdot \frac{2 + \sqrt{2}}{4}} = \frac{\frac{2 + \sqrt{2}}{2} - 2}{\frac{2 + \sqrt{2}}{2}} = \frac{\sqrt{2} - 2}{2 + \sqrt{2}}
   \]

   Rationalize the denominator:

   \[
   \cos \theta = \frac{\sqrt{2} - 2}{2 + \sqrt{2}} \cdot \frac{2 - \sqrt{2}}{2 - \sqrt{2}} = \frac{(\sqrt{2} - 2)(2 - \sqrt{2})}{(2 + \sqrt{2})(2 - \sqrt{2})} = \frac{2\sqrt{2} - 2\sqrt{2} - 4 + 2}{4 - 2} = \frac{-2}{2} = -1
   \]

   However, this result seems incorrect. Let's re-evaluate the rationalization step:

   \[
   \cos \theta = \frac{\sqrt{2} - 2}{2 + \sqrt{2}} \cdot \frac{2 - \sqrt{2}}{2 - \sqrt{2}} = \frac{(\sqrt{2} - 2)(2 - \sqrt{2})}{4 - 2} = \frac{2\sqrt{2} - 2\sqrt{2} - 4 + 2}{2} = \frac{-2}{2} = -1
   \]

   Correcting the rationalization:

   \[
   \cos \theta = \frac{\sqrt{2} - 2}{2 + \sqrt{2}} = \frac{-(2 - \sqrt{2})}{2 + \sqrt{2}} = \frac{-(2 - \sqrt{2})^2}{2}
   \]

   \[
   = -3 + 2\sqrt{2} = -3 + \sqrt{8}
   \]

   Therefore, \(m = -3\) and \(n = 8\).

The final answer is \( \boxed{ m + n = -3 + 8 = 5 } \).