I have an orchestration agent on a chat route, that has access to a sub-agent. Every time the sub-agent is called, it creates a new thread, rather than inheriting the threadId from the parent. So I can't get a coherent chat history from the threads table in storage.
After a chat with Claude, the workaround seems to be to create a tool "delegateToSubAgent" which can then pass the threadId to the sub-agent via generate() and the memory option. Then give the orchestration agent access to that tool.
It seems a bit convoluted and having to create a new tool to call every sub-agent doesn't seem right.