Is there a non-trivial group $C$ such that $A*C \cong B*C$ implies $A \cong B$?
I recently learnt that 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$?
If it helps, I would also be interested in the case where the groups are finitely generated.
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. This leads to the question:
Are there finitely generated groups $A, B, C$ with $A \not\cong B$ but $A*C \cong B*C$?
An answer to the second question follows from:
Grushko's decomposition theorem: Let $G$ be a non-trivial finitely generated group. Then $G \cong A_1*\dots *A_r*F_s$ where $A_1, \dots, A_r$ are non-trivial, freely indecomposable groups which are not infinite cyclic, and $s \geq 0$. Moreover, this decomposition is unique in the following sense: if $G \cong B_1*\dots*B_l*F_t$, then $l = k$, $s = t$, and there is $\sigma \in S_r$ such that $A_i$ and $B_{\sigma(i)}$ are conjugate in $G$ (in particular, isomorphic).
Let
\begin{align*} A &\cong A_1*\dots*A_k*F_p\\ B &\cong B_1*\dots*B_l*F_q\\ C &\cong C_1*\dots*C_m*F_r \end{align*}
be the Grushko decompositions of $A$, $B$, and $C$. Then by uniqueness, the Grushko decompositions of $A*C$ and $B*C$ are
\begin{align*} A*C &\cong A_1*\dots*A_k*C_1*\dots*C_m*F_{p+r}\\ B*C &\cong B_1*\dots*B_l*C_1*\dots*C_m*F_{q+r}. \end{align*}
If $A*C \cong B*C$, then $k + m = l + m$, so $k = l$, and $p + r = q + r$, so $p = q$. Moreover, there is a bijection $\{A_1, \dots, A_k, C_1, \dots, C_m\} \to \{B_1, \dots, B_l, C_1, \dots, C_m\}$ such that a group and its image are isomorphic. It follows that there is a bijection $\{A_1, \dots, A_k\} \to \{B_1, \dots, B_l\}$ such that a group and its image are isomorphic, that is, there is $\sigma \in S_k$ such that $A_i \cong B_{\sigma(i)}$. Now
$$A \cong A_1*\dots *A_k*F_p \cong B_{\sigma(1)}*\dots*B_{\sigma(k)}*F_q \cong B_1*\dots*B_l*F_q \cong B$$
where the second last isomorphism holds because $G_1*G_2 \cong G_2*G_1$ and $p = q$.
So, in conclusion, we have:
If $A, B, C$ are finitely generated groups with $A*C \cong B*C$, then $A \cong B$.
That is, the answer to the second question is no.
After a year, I asked about the first question on MathOverflow. Ian Agol's answer there shows that there are groups $C$ such that $A*C \cong B*C$ implies $A \cong B$, in particular, any finite group works.