spacedriveapp / spacedriveapp/spacebot
feat: update BranchTracker.last_activity_at during branch execution
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.4k
- Forks
- 367
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Follow-up from #556. The last_activity_at field on BranchTracker is currently only set at branch spawn time. To make branch timeout detection truly activity-based, it should be updated during branch execution — on tool completions, text deltas, or LLM call boundaries.
Current State
BranchTracker.last_activity_atis set toInstant::now()intrack_branch_start- The cortex supervisor checks it for timeout detection:
now.duration_since(tracker.last_activity_at) >= branch_timeout - But since it's never updated after spawn, it's functionally equivalent to
started_at
Proposed Approach
Add a ProcessEvent variant (e.g., BranchActivity { branch_id }) sent from SpacebotHook on tool completions and/or text deltas. The cortex event loop would then update last_activity_at in the branch tracker. This requires:
- New
ProcessEventvariant insrc/agent.rs(or wherever the enum lives) - Hook emits the event from
on_tool_resultand/oron_text_deltainSpacebotHook - Cortex event loop handler in
cortex.rsreceives it and updatesbranch_trackers[last_activity_at] - Careful mutex handling to avoid blocking the health tick or the event loop
Why Not Just Use Wall-Clock
A branch can legitimately run for 2-3 minutes doing memory recalls and tool calls. Wall-clock timeouts would kill active branches. Activity-based detection distinguishes "working slowly" from "genuinely stuck."
Related
- #556 — initial per-call timeout + BranchTracker infrastructure
- #332 — related activity tracking work
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ProcessEvent in src/agent.rs, then trace SpacebotHook's on_tool_result and on_text_delta into the cortex.rs event loop. Follow the existing BranchTracker timeout check and track_branch_start flow. Done means branch activity updates last_activity_at during execution without blocking health ticks or the event loop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100