Sub Agents & Memory management
When you talk to your ClaudeCode or Codex Agent, the discourse and the findings of any work goes into the “context” for the agent – basically a memory bank.
Each main agent has a limited amount of space to hold “context”. Eventually the context will be “trimmed” meaning that the memory that the main agent has of recent tasks will shrink, and the agent becomes somewhat “lobotomised”
To combat this you can ask your main agent to create a sub agent for you. The main agent becomes the orchestrator for you.
Besides saving context, another benefit is that this specialised sub agent has been created with user specified tools and knowledge bases which reduces the chance for the AI to choose the wrong solution.
I also advocate for telling claudeCode to write logs to text files, so that in future your agents will have a history for certain issues – this is another great way of handling context (which resets after each claude session)