Is there a non-trivial group $C$ such that $A*C \cong B*C$ implies $A \cong B$? This is a crosspost from this MSE question from a year ago.

Finite groups are cancellable from direct products, i.e. if $F$ is a finite group and $A\times F \cong B\times F$, then $A \cong B$. A proof can be found in this note by Hirshon. In the same note, it is shown that $\mathbb{Z}$ is not cancellable, but if we only allow $A$ and $B$ to be abelian, it is (see here).
I would like to know if there are any groups that can be cancelled from free products rather than direct products. That is:

Is there a non-trivial group $C$ such that $A*C \cong B*C$ implies $A \cong B$?

It is certainly not true that every group is cancellable in free products. For example, if $A$, $B$, $C$ are the free groups on one, two, and infinitely many generators respectively, then $A*C \cong C \cong B*C$ but $A\not\cong B$. Many non-examples can be constructed this way, but they are all infinitely generated.
As is discussed in the original MSE question, it follows from Grushko's decomposition theorem that if $A$, $B$, and $C$ are finitely generated, then $A*C \cong B*C$ implies $A \cong B$.
 A: For $C=\mathbb{Z}/2\mathbb{Z}$, it follows from the Kurosh subgroup theorem that $A\ast C \cong B\ast C$ implies that $A\cong B$. Denote $C_1 \cong C_2\cong \mathbb{Z}/2\mathbb{Z}$, and let $\varphi: A\ast C_1 \to B\ast C_2$ be an isomorphism. 
Then $\varphi(C_1)\leq B\ast C_2$ is an injection. By Kurosh (and since $C$ is freely indecomposable), there is $C_3\leq B$ or $C_4\leq C_2$ and $g\in B\ast C_2$ such that $\varphi(C_1)=gC_3g^{-1}$ or $\varphi(C_1)=gC_4g^{-1}$. Replacing the isomorphism $\varphi$ with $g^{-1}\varphi g$, we may assume that $\varphi(C_1)=C_3$ or $C_4$. 
In the second case, we have $C_4\cong C_2$, and hence $\varphi(C_1)=C_2$. Taking the quotient by the normal closure of $C_1$ and $C_2$ on the left and right respectively, we see that $A\cong B$. 
In the case $\varphi(C_1)=C_3< B$, $\varphi^{-1}(C_2) = hC_5h^{-1}$, $C_5\leq A, h\in A\ast C_1$ (since otherwise we would be in the other case again). Then we see that $A \cong A\ast C_1 / \langle\!\langle C_1\rangle\!\rangle \cong B \ast C_2 /\langle\!\langle C_3\rangle\!\rangle \cong (B/\langle\!\langle C_3\rangle\!\rangle)\ast C_2$ (we use $G/\langle\!\langle H\rangle\!\rangle$ to denote the quotient by the normal subgroup generated by $H$). Similarly, $B\cong (A/\langle\!\langle C_5\rangle\!\rangle)\ast C_1$. Let $A_1=B/\langle\!\langle C_3\rangle\!\rangle, B_1=A/\langle\!\langle C_5\rangle\!\rangle$. Then $A\cong A_1\ast C_2, B\cong B_1\ast C_1$, and $\varphi: A_1\ast C_2\ast C_1 \to B_1\ast C_1\ast C_2$, taking $C_i$ to a conjugate of $C_i$. Take the quotient by the normal closures of $C_1$ and $C_2$ on both sides, we see that $A_1\cong B_1$, so $A\cong B$. 
A: Ian Agol's answer only uses two properties of $\mathbb{Z}/2\mathbb{Z}$: it is freely indecomposable, and it is not isomorphic to a proper subgroup of itself. There are many other groups which have these two properties, e.g. finite groups.
A group which is not isomorphic to a proper subgroup of itself is called co-Hopfian. As I recently learnt on MSE, all co-Hopfian groups are freely indecomposable: if $H$ and $K$ are non-trivial, their free product $H\ast K$ has the proper isomorphic subgroup $H\ast (kh)K(kh)^{-1}$ where $h \in H$ and $k \in K$ are non-identity elements. So we can conclude the following:

For any co-Hopfian group $C$, if $A\ast C \cong B\ast C$, then $A\cong B$.

Examples of co-Hopfian groups include finite groups, $\mathbb{Q}$, $\mathbb{Q}/\mathbb{Z}$, and fundamental groups of closed hyperbolic manifolds. This last class of examples leads to the following observation:

Let $M$, $M'$, and $N$ be closed hyperbolic manifolds. If $M\# N$ is diffeomorphic to $M'\# N$, then $M$ is diffeomorphic to $M'$.

Proof: In dimension two, the assumptions imply $M$ and $M'$ have the same genus and are therefore diffeomorphic. In dimensions greater than two we have
$$\pi_1(M)\ast\pi_1(N) \cong \pi_1(M\# N) \cong \pi_1(M'\# N) \cong \pi_1(M')\ast\pi_1(N).$$
As $\pi_1(N)$ is co-Hopfian, we see that $\pi_1(M) \cong \pi_1(M')$, so $M$ and $M'$ are diffeomorphic by Mostow rigidity. $\,\square$
Note, there are many examples of manifolds $M$, $M'$, and $N$ for which $M\# N$ is diffeomorphic to $M'\# N$, but $M$ is not diffeomorphic to $M'$, e.g. $M = T^2$, $M' = \mathbb{RP}^2\#\mathbb{RP}^2$, and $N = \mathbb{RP}^2$. For an orientable example, take $M = S^2\times S^2$, $M' = \mathbb{CP}^2\#\overline{\mathbb{CP}^2}$, and $N = \overline{\mathbb{CP}^2}$.
