agent: Fix segv running in --server mode