Keep pi alive while it is actively streaming (inactivity timeout) #18
Labels
No labels
in-review
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
weiwen/evie#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
Today evie kills the pi subprocess whenever a single response exceeds a fixed wall-clock deadline (default 60s), even when pi is actively streaming events the whole time. Long but healthy requests (e.g. a slow tool call) get guillotined mid-progress.
Replace the whole-response deadline with an inactivity timeout: the clock is measured against silence from pi, not total elapsed time. Any line pi emits on its stdout event stream — a recognized event, an unrecognized/
Otherevent, or even a malformed line — is a sign of life and resets the timer. Pi is only reaped after a full window elapses with zero output. This also preserves protection against a pi that never responds at all (the first read is under the same timeout).Mechanically this means the timeout wraps each individual line read inside the response loop rather than wrapping the entire read-until-
agent_endfuture.Rename the config field that controls this from
response_timeout_secstoresponse_idle_timeout_secs(value stays 60) and update its doc comment to describe the new semantics ("max seconds of silence from pi before it is treated as hung; resets on any activity"). Update all sample config blocks and the session-layer plumbing that carries this value.Acceptance criteria
response_idle_timeout_secswith updated doc comment; all sample config blocks + session plumbing updated; no staleresponse_timeout_secsreferences remaincargo build,cargo test,cargo clippyare cleanBlocked by
None - can start immediately
Implemented per-line inactivity timeout on branch
sandcastle/issue-18(commit14a5517).What changed:
src/pi.rs:read_agent_responsenow acceptsidle_timeout: Durationand wraps eachreader.read_line()individually withtokio::time::timeout. Any stdout output resets the clock; only a full silent window trips it. The outer whole-responsetimeout()wrapper insend_messageis removed.response_timeout_secs→response_idle_timeout_secsinconfig.rs,session.rs,main.rs,README.md,DESIGN.md,CONTEXT.md(comment updated to explain inactivity semantics).Three new tests using
#[tokio::test(start_paused = true)]: silent-from-start trips timeout, activity-then-silence trips timeout, continuous activity does not trip.Note: No Rust toolchain in this sandbox; CI will validate compilation and tests.