feat(btw): own detached work execution and lifecycle - #137
Conversation
BegoniaHe
left a comment
There was a problem hiding this comment.
AI-assisted review completed against the stacked base split/btw-entry. Focused tests passed, but the blocking error-redaction issue below must be fixed before this slice is ready.
| WorkSessionStatus.FAILED, | ||
| error="Work task failed.", | ||
| ) | ||
| raise |
There was a problem hiding this comment.
[P1] Redact detached executor failures before they reach task logging
This re-raises the original executor exception from the detached task. create_tracked_task then logs that exception with exc_info=exc, so provider/tool exception messages can place URLs, tokens, credentials, or sensitive configuration into logs even though the session stores "Work task failed.". That violates the repository error-redaction invariant. Please terminate the detached failure path with a sanitized/log-safe exception (or consume and log it through safe_error / redact_sensitive_text) while preserving cancellation propagation, and add a log-capture regression test proving a sentinel secret from the executor is absent from emitted logs.
There was a problem hiding this comment.
Fixed in e2f20cc. Detached execution now consumes non-cancellation failures after logging them through safe_error, so the task registry cannot emit the raw traceback. The added regression test verifies an api_key sentinel is absent from captured logs while the session remains generically failed and finalization still runs.
Reuse the existing Agent executor with bounded execution concurrency, terminal retention, cancellation propagation and generic failure state. Related: #125 AI-Generated: true Generated-At: 2026-09-10T15:34:43Z
Restore the six work enablement, concurrency, and retention translations from their runtime metadata descriptions and hints. AI-Generated: true Generated-At: 2026-09-10T16:37:36Z
0b17c33 to
0851fb1
Compare
Prevent raw executor exceptions from reaching tracked-task logging and cover the redaction boundary. AI-Generated: true Generated-At: 2026-09-10T19:02:24Z
5f7b20c to
e2f20cc
Compare
| await asyncio.wait_for(executor.started.wait(), timeout=1) | ||
| task.cancel() | ||
| with pytest.raises(asyncio.CancelledError): | ||
| await task |
Summary
Extract work execution and per-origin task state over the existing Agent executor. Track pending/running/terminal outcomes, propagate cancellation, retain terminal records, and store generic failure text.
Related issue
Related: #125
Parent: #122
Design: #28
Stack
split/btw-entry. Depends on PR #136.Behavior
Own detached work under the existing runtime lifecycle. Acknowledge a task, track pending/running/terminal states, and execute through the established Agent executor with bounded concurrency. Keep conversation available while work runs.
Non-goals
Persistent jobs, restart recovery, cross-device scheduling, and an automatic retry/rollback platform are separate work.
Implementation notes
Base branch:
split/btw-entry. Depends on PR #136. This PR shows only this feature's changes relative to that dependency. The original prototype at33ee103a62937db3e930c89ba47a648b75cc7772is provenance; integration follows current master's owners and authorization contracts. The parent issue records review/integration order.No new HTTP contract or dependency changes. Feature settings and behavior are documented in both languages.
Validation
89 focused work/entry/config tests passed initially. After integrating the metadata repair from B1, 17 work and metadata tests passed; converted enablement, concurrency and retention controls remain visible. Six damaged Chinese labels/hints were then restored; metadata tests and scoped Prettier passed, and all related Chinese strings were checked for encoding damage.
Python checks used the existing Python 3.14.1 environment with
python -m pytestand task-local--basetempdirectories. Local Node was 24.11.1; CI must validate the pinned toolchain. Relevant scoped formatting and Markdown checks were run. The root tracker records the final combined validation. No live model evaluation is implied by deterministic tests or documentation checks.Compatibility and risk
Depends on B1. This slice provides the work runtime; B4 attaches scheduler delivery and shutdown ownership, and B2 provides the command. max_concurrent bounds active execution, not the waiting backlog.
Checklist
Repository references: AGENTS.md, GOVERNANCE.md, AI_POLICY.md, and the feat PR template.
Agent note
Codex prepared this PR at the user's request to split the original #28 implementation into reviewable features, with only classifier experiments marked as drafts. AI assisted extraction, current-path adaptation, tests, and English descriptions. The validation above was performed locally; remaining limitations are stated explicitly. This note is not a maintainer approval. No PR has been merged.