feat(inbox): approval-item expiry (TTL) for all approval kinds (#622) - #637
Open
cagdasyurekli wants to merge 1 commit into
Open
feat(inbox): approval-item expiry (TTL) for all approval kinds (#622)#637cagdasyurekli wants to merge 1 commit into
cagdasyurekli wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #622.
Pending approvals in the inbox previously had no expiry (
coworker/inbox.py) — an approval could sit indefinitely, wedging the suspending agent turn permanently on an approval request that might never be answered, or allowing a user to click allow hours later on stale consent context.This PR implements TTL and expiry handling across all approval kinds (
approval,question,directory,plan,tool):expires_atandttl_secondsparameters toInboxItem,InboxStore.add, and all kind-specific add helpers (add_approval,add_question,add_directory,add_plan,add_tool_request,add_notification).InboxStore.resolve: late resolutions for expired items are rejected (resolvereturnsFalse) and the item auto-resolves as"expired"to prevent acting on stale human consent.InboxStore.wait: pending items with an expiry wait with an asyncio timeout; when the TTL elapses, the item is auto-resolved as"expired"and unblocks the suspending agent turn.InboxStore.list/InboxStore.pending/InboxStore.get: pending items whose TTL has elapsed are lazily transitioned to"expired".ApprovalOutcome.EXPIREDtocoworker/engine.py.inbox_approverreturnsApprovalOutcome.EXPIRED.TurnEnginerecords the event in the audit trail withstatus="expired"and returns an informative tool-error response ("approval request expired (TTL elapsed)") so the agent turn resumes gracefully rather than hanging forever.inbox_approval_ttl_seconds: Optional[float] = NonetoConfig(coworker/config.py), passed intoInboxStoreandTurnEnginedefaults.SessionManager._scheduler_tickchecks for due expired inbox items and durably resumes parked sessions if needed.Verification
tests/test_inbox.pycovering expiry calculation, default TTL, late resolution rejection, list/get filtering, wait timeout auto-resolution, and approver outcome.test_turn_engine_approval_expired_resumes_with_noticeintests/test_engine.pyto verify that expired approvals resume turn execution without wedging and emit the proper audit trail and tool error message.pytest tests/test_inbox.py tests/test_engine.py tests/test_unattended.py).