Account subagent token usage toward root goals (#41183)

## What changed

- Roll token usage from spawned descendants, including nested subagents, into the root goal's usage.
- Apply descendant usage during active and idle progress accounting so it contributes to token budgets.
- Reset descendant accounting baselines when the active goal changes and preserve usage recorded concurrently with a checkpoint.

## Testing

- Cover child and grandchild usage, budget exhaustion, unloaded parent runtimes, goal replacement, idle accounting, and concurrent checkpoints.

GitOrigin-RevId: 8f97ec6778c55b9adf94b887b5fd03999ed0eb94
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-27 19:42:18 +00:00
1 parent 5f49aba876
commit 4761851ff3
6 files changed
+398 -18

No files matched your search

+1 -1
View File
@@ -345,7 +345,7 @@ impl GoalService {
}
}
fn runtime_for_thread(&self, thread_id: ThreadId) -> Option<Arc<GoalRuntimeHandle>> {
pub(crate) fn runtime_for_thread(&self, thread_id: ThreadId) -> Option<Arc<GoalRuntimeHandle>> {
let key = thread_id.to_string();
let mut runtimes = self.runtimes();
let runtime = runtimes.get(&key).and_then(Weak::upgrade);