Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

pa-perf: green the nightly perf lane after the paged catalog and the attach fallback warning (#3714)

Sebastian Müller9f7853a652f9
diff --git a/crates/pa-perf/README.md b/crates/pa-perf/README.md
index 9bf07b3d49..f6442e40d6 100644
--- a/crates/pa-perf/README.md
+++ b/crates/pa-perf/README.md
@@ -114,10 +114,10 @@ the liveness deadline only fails broken runs):
| `cold-ready` | cold | the same launch, exec -> the tray's session-usage pill, the first attach-only content (daemon spawn + session create + attach included) |
| `warm-start` | warm | exec -> first paint, daemon pre-started |
| `warm-ready` | warm | the same launch, exec -> the attach pill |
-| `agents-view` | cold | left-arrow -> the completed `Inactive (N)` roster heading in the screen model |
+| `agents-view` | cold | left-arrow -> the settled first catalog page (`Inactive (N)` plus the `M older sessions not loaded` footer account for every session) in the screen model |
| `agents-view-warm` | cold | the same daemon's second populate (its in-process scan cache warm) |
-| `open-session` | cold | `--resume <huge session>` -> the huge session's tail marker |
-| `session-switch` | cold | enter on the uniquely-filtered switch-b row -> B's transcript marker |
+| `open-session` | cold | `--resume <huge session>` -> the huge session's tail marker (the final user row; its reply is one line) |
+| `session-switch` | cold | enter on the uniquely-filtered switch-b row -> B's transcript marker (the final user row; its reply is one line) |
| `at-completion` | cold | the `@` keystroke -> the first completion menu row |
Mechanics (the repo's pty-e2e discipline): the TUI child runs in its own
diff --git a/crates/pa-perf/src/bench/mod.rs b/crates/pa-perf/src/bench/mod.rs
index ddf861d295..95d74d364f 100644
--- a/crates/pa-perf/src/bench/mod.rs
+++ b/crates/pa-perf/src/bench/mod.rs
@@ -22,11 +22,10 @@ pub enum Scenario {
WarmStart,
/// The warm launch timed to the attach pill.
WarmReady,
- /// Fresh daemon+TUI: left-arrow -> the roster scan delivered the oldest
- /// session (its unique search-result row paints).
+ /// Fresh daemon+TUI: left-arrow -> the settled first catalog page.
AgentsView,
/// The same daemon's second populate (its in-process scan cache warm):
- /// a second TUI's left-arrow -> the completed roster.
+ /// a second TUI's left-arrow -> the settled first catalog page.
AgentsViewWarm,
/// Fresh daemon: `--resume <huge session>` -> the huge marker paints.
OpenSession,
diff --git a/crates/pa-perf/src/bench/pty.rs b/crates/pa-perf/src/bench/pty.rs
index 97de98a7c4..d5dfbab810 100644
--- a/crates/pa-perf/src/bench/pty.rs
+++ b/crates/pa-perf/src/bench/pty.rs
@@ -216,9 +216,25 @@ impl PtyChild {
needle: &str,
what: &str,
deadline: Instant,
+ ) -> anyhow::Result<Instant> {
+ self.wait_screen(what, deadline, |screen| screen.contains(needle))
+ }
+
+ /// Wait until `settled` accepts the decoded screen text, bounded by
+ /// `deadline`.
+ ///
+ /// # Errors
+ ///
+ /// Errors when the child exits first or the deadline passes (with the
+ /// decoded screen attached).
+ pub(crate) fn wait_screen(
+ &mut self,
+ what: &str,
+ deadline: Instant,
+ settled: impl Fn(&str) -> bool,
) -> anyhow::Result<Instant> {
loop {
- if self.screen_text().contains(needle) {
+ if settled(&self.screen_text()) {
return Ok(Instant::now());
}
if let Some(status) = self.exited {
@@ -229,7 +245,7 @@ impl PtyChild {
}
if Instant::now() >= deadline {
anyhow::bail!(
- "timeout waiting for {what} (screen needle {needle:?}); screen:\n{}",
+ "timeout waiting for {what}; screen:\n{}",
self.screen_text(),
);
}
diff --git a/crates/pa-perf/src/bench/runner.rs b/crates/pa-perf/src/bench/runner.rs
index aee1a9562c..419154aa69 100644
--- a/crates/pa-perf/src/bench/runner.rs
+++ b/crates/pa-perf/src/bench/runner.rs
@@ -480,21 +480,43 @@ impl Drop for Launch {
}
}
-/// The left-arrow opens the agents view; the populate needle is the
-/// completed `Inactive (N)` roster heading in the decoded screen (the
-/// heading count repaints as cell diffs, so the byte stream cannot see it
-/// — the screen model does). The count includes the TUI's own fresh
-/// session (rendered as one more inactive row).
+/// The left-arrow opens the agents view; populate completes when the
+/// roster settles (see [`roster_settled`]; the heading count repaints as
+/// cell diffs, so the byte stream cannot see it — the screen model does).
+/// The count includes the TUI's own fresh session (rendered as one more
+/// inactive row).
fn agents_view_populate(ctx: &RunCtx, child: &mut PtyChild) -> anyhow::Result<f64> {
- let needle = format!("Inactive ({})", ctx.manifest.markers.roster_inactive + 1);
let started = Instant::now();
child.write(b"\x1b[D")?;
- child.wait_screen_contains(
- &needle,
+ wait_roster(ctx, child, ctx.manifest.markers.roster_inactive + 1)?;
+ Ok(started.elapsed().as_secs_f64() * 1000.0)
+}
+
+/// The agents view opens on its first catalog page: the `Inactive (N)`
+/// heading counts the loaded rows and the `M older sessions not loaded`
+/// footer the rest, so the page is settled once both account for every
+/// expected session. An unpaged roster has no footer.
+fn roster_settled(screen: &str, expected: usize) -> bool {
+ let loaded = screen
+ .split_once("Inactive (")
+ .and_then(|(_, rest)| rest.split_once(')'))
+ .and_then(|(number, _)| number.parse::<usize>().ok());
+ let unloaded = screen
+ .lines()
+ .find_map(|line| {
+ let (number, _) = line.trim_start().split_once(" older sessions not loaded")?;
+ number.parse::<usize>().ok()
+ })
+ .unwrap_or(0);
+ loaded.is_some_and(|loaded| loaded + unloaded == expected)
+}
+
+fn wait_roster(ctx: &RunCtx, child: &mut PtyChild, expected: usize) -> anyhow::Result<Instant> {
+ child.wait_screen(
"the agents view roster",
Instant::now() + ctx.liveness,
- )?;
- Ok(started.elapsed().as_secs_f64() * 1000.0)
+ |screen| roster_settled(screen, expected),
+ )
}
/// From the opened session A: open the agents view, uniquely filter to
@@ -503,15 +525,11 @@ fn agents_view_populate(ctx: &RunCtx, child: &mut PtyChild) -> anyhow::Result<f6
/// letter z), so Enter always drills THE row.
fn switch_to_target_b(ctx: &RunCtx, child: &mut PtyChild) -> anyhow::Result<f64> {
child.write(b"\x1b[D")?;
- // Wait the completed roster before typing: keys racing the scan flood
+ // Wait the settled roster before typing: keys racing the scan flood
// were the CI-runner failure (the query echoed nothing). The resumed
- // session A renders as one IDLE row, so the completed heading counts
- // the remaining sessions.
- child.wait_screen_contains(
- &format!("Inactive ({})", ctx.manifest.markers.roster_inactive - 1),
- "the agents view roster",
- Instant::now() + ctx.liveness,
- )?;
+ // session A renders as one IDLE row, so the settled roster counts the
+ // remaining sessions.
+ wait_roster(ctx, child, ctx.manifest.markers.roster_inactive - 1)?;
child.write(ctx.manifest.markers.switch_query.as_bytes())?;
// The echoed query does not contain the row's "switch" prefix, so this
// needle is the picker's result row, not the echo.
@@ -762,7 +780,7 @@ fn needle_of(scenario: Scenario, ctx: &RunCtx) -> String {
"the attach pill (the tray's session-usage row)".to_string()
}
Scenario::AgentsView | Scenario::AgentsViewWarm => format!(
- "the completed roster heading (Inactive ({}))",
+ "the settled roster (Inactive + not-yet-loaded = {})",
ctx.manifest.markers.roster_inactive + 1
),
Scenario::OpenSession => {
@@ -1041,4 +1059,25 @@ mod tests {
"hello blocked for {elapsed:?}"
);
}
+
+ #[test]
+ fn roster_settled_accounts_for_unloaded_pages() {
+ let large = " ▗█▛▐█▙ ▗▄█▀▗█▀ prime agent v0.10.0
+ ▗█▛ ▟██▙▄██▛ ▟▛ agents 0 running, 0 idle, 200 inactive
+
+ > Search sessions
+
+Session Model Cost Age
+
+Inactive (200)
+• (no messages) amazon.nova-2-lite-v1:0:medium $0.00 4s
+• huge corpus session gpt-5.4:high $71727.10 29d
+ ...
+801 older sessions not loaded · scroll to load
+↑/↓ navigate Home/End first/last Enter/→ open";
+ assert!(roster_settled(large, 1001));
+ assert!(!roster_settled(large, 1000));
+ assert!(roster_settled("Inactive (11)\n• a\n• b", 11));
+ assert!(!roster_settled("Inactive (7)\n• a\n• b", 11));
+ }
}
diff --git a/crates/pa-perf/src/corpus/mod.rs b/crates/pa-perf/src/corpus/mod.rs
index dce1d8b520..7c5d9d6ac5 100644
--- a/crates/pa-perf/src/corpus/mod.rs
+++ b/crates/pa-perf/src/corpus/mod.rs
@@ -172,7 +172,8 @@ pub struct ManifestMarkers {
pub huge: MarkerSession,
pub switch_a: MarkerSession,
pub switch_b: MarkerSession,
- /// The agents view's expected `Inactive (N)` heading count.
+ /// The corpus sessions the agents view lists as inactive (loaded under
+ /// the `Inactive (N)` heading or counted in its not-yet-loaded footer).
pub roster_inactive: usize,
/// The session-switch search query (uniquely matches the switch-b row).
pub switch_query: String,
diff --git a/crates/pa-perf/src/corpus/rows.rs b/crates/pa-perf/src/corpus/rows.rs
index 721e7b7ddb..7f157a44bb 100644
--- a/crates/pa-perf/src/corpus/rows.rs
+++ b/crates/pa-perf/src/corpus/rows.rs
@@ -112,7 +112,9 @@ pub(crate) struct SessionSpec {
pub rows: usize,
pub name: Option<String>,
/// A unique string placed in the LAST user message (the bench needle:
- /// the transcript paints the session tail on open).
+ /// the transcript paints the session tail on open). Its reply is one
+ /// short text line, so rows the product appends at attach cannot push
+ /// the marker off screen.
pub marker: Option<String>,
pub parent_session: Option<String>,
pub rlm_depth: Option<u64>,
@@ -343,8 +345,9 @@ pub(crate) fn write_session_file(
continue;
}
+ let marker_turn = spec.marker.is_some() && target - rows.rows_written() <= 4;
let text = match &spec.marker {
- Some(marker) if target - rows.rows_written() <= 4 => marker.clone(),
+ Some(marker) if marker_turn => marker.clone(),
_ => user_text(rng),
};
let content = if rng.chance(30) {
@@ -370,7 +373,7 @@ pub(crate) fn write_session_file(
last_user_text = text;
// The assistant turn: thinking + text + a tool call, then the result.
- let tool = rng.chance(45).then(|| {
+ let tool = (!marker_turn && rng.chance(45)).then(|| {
let name = TOOLS[rng.below(TOOLS.len() as u64) as usize];
let id = format!("call-{:08x}", rows.counter);
let mut arguments = serde_json::Map::new();
@@ -382,7 +385,7 @@ pub(crate) fn write_session_file(
(id, name)
});
let mut blocks = Vec::new();
- if rng.chance(60) {
+ if !marker_turn && rng.chance(60) {
blocks.push(AssistantContentBlock::Thinking(ThinkingContent {
thinking: assistant_text(rng),
thinking_signature: None,
@@ -391,7 +394,11 @@ pub(crate) fn write_session_file(
}));
}
blocks.push(AssistantContentBlock::Text(TextContent {
- text: assistant_text(rng),
+ text: if marker_turn {
+ "Done.".to_string()
+ } else {
+ assistant_text(rng)
+ },
text_signature: None,
rest: serde_json::Map::new(),
}));
@@ -414,7 +421,7 @@ pub(crate) fn write_session_file(
}
let stop_reason = if tool.is_some() {
StopReason::ToolUse
- } else if rng.chance(2) {
+ } else if !marker_turn && rng.chance(2) {
StopReason::Error
} else {
StopReason::Stop
@@ -463,7 +470,7 @@ pub(crate) fn write_session_file(
)?;
}
- if rng.chance(7) {
+ if !marker_turn && rng.chance(7) {
let custom = CUSTOM_TYPES[rng.below(CUSTOM_TYPES.len() as u64) as usize];
rows.push(
"custom_message",
diff --git a/crates/pa-perf/tests/corpus_verification.rs b/crates/pa-perf/tests/corpus_verification.rs
index ace7796ed2..df380dbf99 100644
--- a/crates/pa-perf/tests/corpus_verification.rs
+++ b/crates/pa-perf/tests/corpus_verification.rs
@@ -67,6 +67,17 @@ fn markers_land_on_the_final_user_message() {
&manifest.markers.switch_b,
] {
let text = std::fs::read_to_string(&marker.file).expect("read session");
+ // The reply under the marker is one short text line, so rows the
+ // product appends at attach cannot push the marker off screen.
+ let last: serde_json::Value =
+ serde_json::from_str(text.lines().last().expect("a last row")).expect("valid row");
+ let blocks = last["message"]["content"].as_array();
+ assert!(
+ last["message"]["role"] == "assistant"
+ && last["message"]["stopReason"] == "stop"
+ && blocks.is_some_and(|blocks| blocks.len() == 1 && blocks[0]["type"] == "text"),
+ "the marker reply is one text block: {last}"
+ );
let last_user = text
.lines()
.rev()