Skip to content

fix(tui): bound agent picker lineage discovery - #675

Closed
GraciousGazelles wants to merge 24 commits into
mainfrom
fix/picker-lineage-bounded-discovery
Closed

GraciousGazelles wants to merge 24 commits into
mainfrom
fix/picker-lineage-bounded-discovery

Conversation

@GraciousGazelles

Copy link
Copy Markdown
Collaborator

Summary

  • query descendant metadata through ancestor-filtered, paginated thread listing
  • keep unrelated loaded threads outside the picker discovery request budget
  • cover picker event completion when an unrelated metadata read cannot return

Validation

  • cargo fmt --all
  • git diff --check
  • hosted targeted TUI validation pending

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the subagent thread backfill mechanism in the TUI. Instead of fetching all loaded threads and filtering them individually, it now queries the app server's thread_list endpoint with an ancestor filter to fetch only the descendants of the primary thread, utilizing pagination. This change significantly reduces redundant metadata reads and improves performance. The review feedback suggests adding a safety limit on the maximum number of pages fetched during the backfill loop to prevent potential infinite loops or excessive resource consumption from circular cursors or unexpectedly large lineages.

@GraciousGazelles

Copy link
Copy Markdown
Collaborator Author

Successor 91335f1 addresses the rejected candidate findings. Lineage pages are now validated and applied incrementally, transient list failures retain the failed cursor, cursor cycles remain explicitly incomplete until reset, and each picker open builds a rotating bounded row slice. The already-tracked pathless-child fallback now uses the existing liveness refresh path directly, preserving V1/V2 ownership semantics without scanning unrelated loaded threads. Hosted regressions were added for cross-page descendants, failed-cursor resume, terminal cursor cycles, multi-open page-budget progress, linear indexed traversal, bounded rotating rows, and reset cleanup. Fresh hosted validation is being dispatched for this exact head.

@GraciousGazelles

Copy link
Copy Markdown
Collaborator Author

Successor dc11277 consolidates the current review and hosted-test findings. It keeps ancestor-only empty-preview descendants visible to lineage discovery, requires an authoritative read before exposing unknown-capability pathless children, preserves transient read failures as retryable continuation state without relisting, and bounds cursor cycles independently per picker open so a later open can recover. The recurring V1/V2 capability regression remains substantive, with additional state, app-server, retry, and cycle-recovery coverage in the focused hosted lane.

@GraciousGazelles

GraciousGazelles commented Aug 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

Successor 8ad15fb fixes the exact dc11277 hosted blockers. All four push_thread_filters call sites now pass the new preview policy explicitly; only ancestor DescendantsOf listing can include empty previews, while memories, exact-title, and id listing remain false. Cursor-cycle detection now resets pagination for the next open but drains the bounded authoritative-read queue before returning, so pathless V2 descendants are visible with server-confirmed ownership even under a persistent cycle. A focused fixture proves two bounded list calls and one authoritative read per open with fresh cursor restart, and the memories query test is now part of the targeted lane.

@GraciousGazelles
GraciousGazelles force-pushed the fix/picker-lineage-bounded-discovery branch from 8ad15fb to 6d3076a Compare August 23, 2026 14:56
@GraciousGazelles

Copy link
Copy Markdown
Collaborator Author

Base-refresh receipt: the same five-commit semantic delta has been rebased without conflicts onto origin/main 3eda3f2. The rebased head is 6d3076a. Pre- and post-rebase full-index diff SHA-256 are identical at 437f3bdeaf00f45be6de2cffdd42b75dd25345270d750fdb4f0f19038e9d6a3e, with the same changed paths. Prior checks are superseded; fresh exact-head validation is being dispatched.

@GraciousGazelles
GraciousGazelles force-pushed the fix/picker-lineage-bounded-discovery branch from 6d3076a to dc2a1ad Compare August 23, 2026 15:09
@GraciousGazelles
GraciousGazelles force-pushed the fix/picker-lineage-bounded-discovery branch from 982cc54 to 27fb021 Compare August 23, 2026 16:19
1,
))?),
])));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage_and_state(
let page_count = rows
.len()
.div_ceil(crate::app::session_lifecycle::SUBAGENT_BACKFILL_PAGE_SIZE as usize);
for (page_index, page) in rows
let thread_read_responses = Arc::new(Mutex::new(VecDeque::from([
ScriptedThreadReadResponse::Thread(serde_json::to_value(child)?),
])));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage_and_state(
/*next_cursor*/ None,
),
)])));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
/*next_cursor*/ None,
)),
])));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
scripted_unacknowledged_lineage_page(Vec::new(), /*next_cursor*/ None),
));
let responses = Arc::new(Mutex::new(pages));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
crate::app::loaded_threads::SUBAGENT_BACKFILL_PAGES_PER_ATTEMPT + 1
);
let responses = Arc::new(Mutex::new(pages));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
ScriptedThreadReadResponse::Error("transient read failure".to_string()),
ScriptedThreadReadResponse::Thread(serde_json::to_value(authoritative_child)?),
])));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
configure_backfill_primary(&mut app, primary_thread_id);
let mut pages = VecDeque::new();
let descendant_thread_ids = (0..PAGE_COUNT).map(|_| ThreadId::new()).collect::<Vec<_>>();
for (index, descendant_thread_id) in descendant_thread_ids.iter().copied().enumerate() {
)));
}
let responses = Arc::new(Mutex::new(pages));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
let responses = Arc::new(Mutex::new(VecDeque::from([ScriptedLineageResponse::Page(
scripted_relation_limited_lineage_page(Vec::new(), /*next_cursor*/ None),
)])));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
)));
}
let responses = Arc::new(Mutex::new(pages));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
let responses = Arc::new(Mutex::new(VecDeque::from([ScriptedLineageResponse::Page(
scripted_lineage_page(Vec::new(), Some("over-limit".to_string())),
)])));
let (mut app_server, requests, proxy) = start_recording_app_server_with_lineage(
@GraciousGazelles

Copy link
Copy Markdown
Collaborator Author

Superseded by #736, merged as f40ba8f and contained in current main. The landed successor covers bounded ancestor-filtered discovery, persisted lineage, cursor and traversal limits, protected picker rows, notifications, and regression tests. Closing this older proposal; retaining its source branch for historical reference.

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.

2 participants