Skip to content

Conversation

@santosflores
Copy link

Passing this.rootAgent (from the parent) to updateRootAgent is the correct approach to ensure the sub-agent becomes part of the existing tree structure, rather than creating a new one or pointing incorrectly.

Here is why:

  • Inheritance of Context: When a sub-agent is added to a parent, it effectively becomes a child node in that parent's tree. The parent already knows who its root is (stored in this.rootAgent).
  • Consistency: By using this.rootAgent, we guarantee that every node in the tree points to the same root object. This single source of truth is crucial for tree-wide operations like getAgentByName to work correctly.
  • Handling Nested Structures: If we were adding Orchestrator -> MiddleManager -> Worker, when MiddleManager adds Worker, MiddleManager.rootAgent would already point to Orchestrator. Passing this.rootAgent ensures Worker also points to Orchestrator, maintaining the hierarchy correctly across multiple levels.

@santosflores
Copy link
Author

This PR tries to solve Isseu #82

@ScottMansfield
Copy link
Member

I left a comment in the issue, if you have a minimal repro it would be very helpful.

Thank you for the PR. A couple immediate comments:

  1. The formatting / whitespace changes are noise in this case and don't match the existing formatting. That should match
  2. I'm not sure this is the right approach as this isn't necessary in the Python version for it to function. I don't think we will need a recursive update to the full tree to make this work.

@ScottMansfield ScottMansfield self-assigned this Jan 29, 2026
@kalenkevich
Copy link
Collaborator

The formatting / whitespace changes are noise in this case and don't match the existing formatting. That should match

That is primarily my fault but not @santosflores
We need to format the whole project to reflect current formatter rules or maybe disable formatting for now.

@santosflores
Copy link
Author

hey @kalenkevich, closing this PR in favor of #95 ; Let me know if I need to reopen but I think we are g2g.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants