Skip to content

Credit a running OpenCode subagent in the co-authorship check - #2807

Merged
Soph merged 6 commits into
mainfrom
feat/opencode-live-coauthor
Oct 21, 2026
Merged

Soph merged 6 commits into
mainfrom
feat/opencode-live-coauthor

Conversation

@peyton-alt

@peyton-alt peyton-alt commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/1602

An OpenCode session whose background subagent is still running can now be credited for a commit that another session also claims, whether the parent is IDLE or still in its turn (ACTIVE).

A running subagent's edits reach the parent's tracked files only when it stops. Until then, post-commit's read-only gate asks the live task records whether they touched a committed file (liveTaskFilesInCommit). It read only transcripts on disk, and a running OpenCode child has none (its transcript exists only through opencode export), so the parent was skipped as read-only and the commit lost its link to that session.

Changes

  • New agent.LiveSubagentFileReporter: reports the files a running subagent call has modified so far. OpenCode implements it by exporting the child to a private staging file, cutting it to the running call, and removing it. Only completed tool parts count: a pending, running or failed edit is no evidence. It writes nothing a capture reads, so a report that finishes after the call's stop cannot replace the stop's complete transcript.
  • liveTaskFilesInCommit uses the reporter for a live record with no transcript on disk. A report that fails, or runs out of budget, is no evidence.
  • Fetch budgets: the co-authorship checks of all a commit's sessions share 10s, counted from the start of post-commit's session loop, so a hung export there cannot hold the commit. Condensation's re-exports of completed tasks keep their own 30s per session (agent.SubagentFetchBudget), as on main.
  • The gate is memoized per session (sync.OnceValue), since each consultation may export.
  • prepare-commit-msg's check of a foreign session's running subagents shares the same 10s deadline, so a slow or hung export cannot hold up git commit either.
  • The gate's evidence applies to an ACTIVE parent too (hasFreshLiveTaskRecord: any phase but ENDED), for every agent. A parent keeps working after launching a background subagent. For OpenCode this is what credits it at all, since its live transcript does not include its children; for Claude and others it applies when the parent's own transcript does not yet show the subagent's files and its on-disk transcript names a committed file. When to skip the overlap check is unchanged (idleWithLiveTaskRecord, IDLE only).
  • Docs: OpenCode AGENT.md and sessions-and-checkpoints.md, including that a still-running subagent credits its session again on a later commit of the same file (as Claude's on-disk transcripts do on main).

A commit made outside the parent's agent process (a terminal, another window) goes through #2668's foreign-session checks. #2668 has merged, and this PR switches both of them (the prepare-commit-msg staged-file overlap and post-commit's liveTaskCoauthored) to hasFreshLiveTaskRecord, so an ACTIVE parent's running subagent counts there too, as #2668 already allowed for an IDLE one.

This redoes the co-authorship part cut from #2390, rebuilt on what landed there: readTaskTranscript no longer re-exports live records, so the check uses its own non-writing probe instead.

Tests

  • Live-tested with OpenCode 1.18.33 (opencode serve, gpt-5.6-luna): an IDLE parent whose background child rewrote a file the coder session also claimed, committed while the child was still running: main 1 session, this PR 2; with Keep a running agent's session off commits it did not make #2668 merged in, also 2 (both sessions foreign). With Keep a running agent's session off commits it did not make #2668 merged in, also: an ACTIVE parent (still in its own turn) is credited (2 sessions), and a parent alone gets the trailer when its running child's file is committed.

  • TestOpenCodeSubagentRunningChildCoauthorsCommit (integration): an IDLE parent with a running child that wrote a file another session claims is condensed into the commit. Fails without the change.

  • TestLiveTaskFilesInCommit_AsksTheAgentForARunningSubagent: committed file, other files, failed report, spent budget.

  • TestCommitFetchBudgets_CoauthorshipGetsAShare.

  • TestLiveSubagentModifiedFiles_WritesNothingACaptureReads: reports only the running call's files and leaves nothing under .entire/tmp.

  • TestOpenCodeSubagentRunningChildCoauthorsCommit_ActiveParent (integration): the same with the parent mid-turn. Fails without the change.

  • TestHasFreshLiveTaskRecord_AnyPhaseButEnded.

  • TestShouldCondense_RunningSubagentCreditsAnActiveParent: the read-only gate for an ACTIVE parent of any agent.

  • TestCommitFetchBudgets_CondensationKeepsItsOwnBudget: condensation still re-exports after the co-authorship deadline has passed.

  • TestCompletedToolParts_DropsUnfinishedEdits.

  • TestRunOpenCodeExportToFile_CancelKillsTheLaunchersChild: a launcher-style fake returns at the deadline (30s without the fix).

  • TestForeignCommit_RunningOpenCodeSubagentLinksActiveForeignParent (integration): an ACTIVE OpenCode parent, foreign to the commit, is credited through its running child. Fails without the switch to hasFreshLiveTaskRecord.

  • TestCommitFetchBudgets_PrepareCommitMsgIsBounded.

Diff: +675/−45 across 16 files.

🤖 Generated with Claude Code


Note

Medium Risk
Touches post-commit session linking and runs live opencode export during commits with time budgets; incorrect attribution or budget starvation could mis-link checkpoints or skip co-authorship, but failures degrade to “no evidence” rather than hard errors.

Overview
Post-commit can now treat an IDLE OpenCode parent as a co-author when a still-running background subagent has already edited files in the commit, even though those edits are not in FilesTouched until the child stops.

Adds LiveSubagentFileReporter and OpenCode’s LiveSubagentModifiedFiles, which runs a scoped opencode export into a private staging file (no writes to .entire/tmp cache or the call’s declared transcript). liveTaskFilesInCommit falls back to that probe when a live task record has no on-disk transcript; failed or budget-exhausted reports count as no evidence.

Subagent fetch budgeting is refactored (WithSubagentFetchDeadline, shared subagentFetchContext); each commit gets a 30s export budget with 10s reserved for co-authorship checks. The live-task gate is memoized per session via sync.OnceValue.

Docs (AGENT.md, sessions-and-checkpoints.md) and tests cover the running-child commit case, budget splitting, and the no-persistent-writes guarantee.

Reviewed by Cursor Bugbot for commit 6c5727f. Configure here.

liveTaskFilesInCommit read only transcripts on disk, and a running
OpenCode child has none until its stop hook exports it, so an IDLE parent
whose background child wrote a file another session also claims was
skipped as read-only.

Agents can now report what a running subagent call has modified
(agent.LiveSubagentFileReporter). OpenCode exports the child to a private
staging file, cuts it to the running call and removes it, writing nothing
a capture reads. Post-commit gives all subagent exports one 30s budget and
the co-authorship checks a 10s share of it, so they cannot starve
condensation's re-exports. The gate is memoized per session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M53CTW9M0EBHK204XGKMCH71
@peyton-alt
peyton-alt requested a review from a team as a code owner October 16, 2026 22:21
Copilot AI balanced review requested due to automatic review settings October 16, 2026 22:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Live probes can incorrectly credit unsuccessful edits and bypass repository-resolution safety checks.

2 open issues
What changed in this PR

Enables Entire CLI to credit an idle OpenCode parent when its running subagent modified files committed alongside another session.

Changes:

  • Adds a private, call-scoped live subagent probe.
  • Shares export budgets across post-commit processing and memoizes co-authorship checks.
  • Adds regression tests and updates documentation.
File Description
docs/​architecture/​sessions-and-checkpoints.md Documents live-task co-authorship.
cmd/​entire/​cli/​strategy/​manual_commit_task_fetch_test.go Tests reporting and budget limits.
cmd/​entire/​cli/​strategy/​manual_commit_hooks.go Integrates budgeted, memoized probes.
cmd/​entire/​cli/​integration_test/​opencode_subagent_test.go Tests running-child co-authorship.
cmd/​entire/​cli/​integration_test/​hooks.go Adds configurable transcript timestamps.
cmd/​entire/​cli/​agent/​subagent_fetch.go Shares deadline handling between fetch operations.
cmd/​entire/​cli/​agent/​opencode/​subagent_export.go Implements private live exports.
cmd/​entire/​cli/​agent/​opencode/​subagent_export_test.go Tests call scoping and staging cleanup.
cmd/​entire/​cli/​agent/​opencode/​lifecycle.go Asserts reporter interface implementation.
cmd/​entire/​cli/​agent/​opencode/​AGENT.md Documents probe behavior and budgets.
cmd/​entire/​cli/​agent/​capabilities.go Adds built-in reporter capability lookup.
cmd/​entire/​cli/​agent/​agent.go Defines the live file-reporting interface.

Review effort: Balanced

peyton-alt and others added 2 commits October 19, 2026 13:11
- Kill the export's whole process group on cancel. opencode's npm
  launcher runs the real binary with inherited stdio, so a hung export
  outlived the co-authorship check's 10s share (42s in a repro).
- The live probe counts only completed tool parts: a pending, running or
  failed edit is no evidence the subagent changed the file.
- Document that a running subagent credits its session again on a later
  commit of the same file, as Claude's on-disk transcripts already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M5AWNAYJYQGEFQMV87JK61FE
The read-only gate asked the live task records only for an IDLE session.
A parent that keeps working after launching a background subagent is
ACTIVE, so with another session claiming the committed file it was
dropped although its running child wrote that file (an OpenCode parent's
live transcript does not include its children). The evidence now comes
from hasFreshLiveTaskRecord, any phase but ENDED; idleWithLiveTaskRecord
still alone decides when to skip the overlap check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M5BB580JKSNB5YS2N45HC2E8
peyton-alt and others added 3 commits October 20, 2026 13:59
…iew fixes

- Post-commit set one 30s subagent fetch budget for the whole commit, so a
  second session condensing completed OpenCode tasks could find it spent
  and lose their transcripts. Only the co-authorship checks' 10s deadline
  is now commit-wide; each condensation keeps its own 30s, as on main.
- LiveSubagentModifiedFiles returns the worktree error instead of falling
  back to the CWD.
- One mockExportName helper holds the ENTIRE_TEST_OPENCODE_MOCK_EXPORT hook
  and its file name for both export paths.
- Test the read-only gate's running-subagent credit for an ACTIVE parent of
  any agent; note what a forced second Ctrl-C leaves behind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M5DHSAQ4BW7BT4NRMKDWFDMH
…author

# Conflicts:
#	cmd/entire/cli/strategy/manual_commit_hooks.go
The prepare-commit-msg check for a foreign session's running subagent
could run an agent export per live task record with no deadline, so a
slow or hung export held up git commit; this branch also widened that
check to ACTIVE sessions. It now shares the commit's co-authorship
deadline, as post-commit does, and never extends one already set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M5E15XYD0DXHVD121CAVH76N
@Soph
Soph merged commit 2bb9d90 into main Oct 21, 2026
30 of 32 checks passed
@Soph
Soph deleted the feat/opencode-live-coauthor branch October 21, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants