Repository navigation
Description
Summary
The subagent approval sidecar (scheddomain.SubagentApprovalFile) is written and read by hand in two other packages, while the subagent result file right next to it has owned helpers (scheddomain.WriteSubagentResultFile / scheddomain.ReadSubagentResultFile in internal/scheduler/domain/subagent.go).
- Writer:
internal/presentation/tui/toolcoordinator/approval_sidecar.gowriteSubagentApprovalSidecarcopies the body ofWriteSubagentResultFile(marshal,os.WriteFile(path+".tmp", data, 0o600), rename) but ends with_ = os.Rename(tmp, path). A failed rename is swallowed and leaves a stale<path>.tmpbehind, so the parent never sees the pending approval and nobody is told why. - Reader:
internal/tools/agent.goreadSubagentApprovalrepeatsos.ReadFile+json.Unmarshalintoscheddomain.SubagentApprovalFile, the same shape asReadSubagentResultFile.
Principles applied: clean-code (duplication - copy-pasted function body, and a swallowed error) and domain-driven-design (an invariant enforced by every caller instead of the type that owns it - the "temp file then rename so a polling parent never reads a half-written file" rule and the wire format belong to the scheduler domain that defines SubagentApprovalFile, exactly as they already do for SubagentResultFile).
The fix is local: one package gains two small functions that reuse the existing write path, and two call sites shrink to one line each.
Acceptance Criteria
-
internal/scheduler/domain/subagent.gogainsWriteSubagentApprovalFile(path string, af SubagentApprovalFile) errorandReadSubagentApprovalFile(path string) (SubagentApprovalFile, bool)next to the result-file pair, and both writers share one private temp-file-and-rename JSON helper instead of two copies of it. - Before:
writeSubagentApprovalSidecarmarshals, writespath + ".tmp"and calls_ = os.Rename(tmp, path). After: it callsscheddomain.WriteSubagentApprovalFile(path, ...)and the returned error is no longer discarded (logged withlogger.Warn, ascoordinator.goin the same package reports its own failures). - Before:
readSubagentApprovalininternal/tools/agent.godoes its ownos.ReadFile+json.Unmarshal. After: it callsscheddomain.ReadSubagentApprovalFile(subagentApprovalFilePath(sessionID))and keeps only theAwaitingcheck and summary trim. -
internal/tools/approve_subagent_test.gowrites its fixture sidecar throughscheddomain.WriteSubagentApprovalFileinstead of hand-marshallingSubagentApprovalFile. - Existing tests still pass.
Activity
inference-gateway-releaser commentedon Nov 22, 2026
🎉 This issue has been resolved in version 0.266.1 🎉
The release is available on:
Your semantic-release bot 📦🚀