Skip to content

feat: add graph representation of agent network#15056

Merged
jif-oai merged 3 commits intomainfrom
jif/agent-tree
Mar 19, 2026
Merged

feat: add graph representation of agent network#15056
jif-oai merged 3 commits intomainfrom
jif/agent-tree

Conversation

@jif-oai
Copy link
Collaborator

@jif-oai jif-oai commented Mar 18, 2026

Add a representation of the agent graph. This is now used for:

  • Cascade close agents (when I close a parent, it close the kids)
  • Cascade resume (oposite)

Later, this will also be used for post-compaction stuffing of the context

Direct fix for: #14458

@jif-oai
Copy link
Collaborator Author

jif-oai commented Mar 18, 2026

@codex review

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e24a0f8c4f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jif-oai
Copy link
Collaborator Author

jif-oai commented Mar 18, 2026

@codex review

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3b9f1b72c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Collaborator

@charley-oai charley-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks graphical to me

let mut resume_queue = VecDeque::from([(thread_id, root_depth)]);
while let Some((parent_thread_id, parent_depth)) = resume_queue.pop_front() {
let child_ids = match state_db_ctx
.list_thread_spawn_children_with_status(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could maybe just call list_thread_spawn_descendants_matching and then share code with live_thread_spawn_children to traverse the tree in level order except a separate sqlite query per level. However I imagine the num levels will normally be small so that's prob not necessary.

Maybe vague benefit would be to share more code btwn the in-memory traversals and the sqlite traversals

The other slightly confusing thing about reviewing this diff is how the names of functions for traversing sqlite-stored graph vs in-memory graph are similar, so it's a bit unclear when we're querying sqlite vs when we're pulling from in-memory state (maybe a footgun for future editors?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really a simplification because we need the depth during resume while the other is just a BFS
I will try to unify in a follow-up

@jif-oai jif-oai merged commit 70cdb17 into main Mar 19, 2026
33 checks passed
@jif-oai jif-oai deleted the jif/agent-tree branch March 19, 2026 10:21
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants