Repository navigation
Let Claude workflows run without blocking the composer - #854
Merged
Merged
Conversation
A native Claude workflow (`local_workflow`) was completion-blocking, so the logical bb turn stayed open for the workflow's whole run. That kept the thread `active`, which made the composer queue follow-ups instead of sending them. Workflows now let the turn complete and the thread go idle. Background agents and legacy subagents still block, as before. When the workflow settles and reinvokes the parent model, that work opens a fresh turn. The busy status disappears without any UI change: `displayStatus` derives from `thread.status` alone, so the thread-row indicator falls through from the generic "Thread working" spinner to the specific "Workflow running" glyph, and the timeline pill plus the composer workflow card keep rendering from background-task activity. Two consequences handled here: - A child thread can now report an outcome while its workflow is still running, so the parent notification says so and tells the parent to expect a second report rather than reading the excerpt as final. - With the turn closed, the thread no longer sits in the runtime's active set, so `evictIdleRuntimeEntries` could shut a runtime down mid-workflow and SIGTERM the provider process running it. `AgentRuntime` now tracks open background tasks from the event stream it already observes and exposes `hasOpenBackgroundWork()`, which `entryHasActiveRuntimeWork` counts as active work. This also fixes the pre-existing case of a backgrounded dev server being killed by a shell-env change. Bumps HOST_DAEMON_PROTOCOL_VERSION so enrolled daemons pick up the new turn timing; the wire shape is unchanged, so an older daemon keeps the old blocking behavior rather than failing to parse. Tests: - pnpm exec turbo run typecheck test --filter=@bb/agent-runtime - pnpm exec turbo run typecheck test --filter=@bb/host-daemon - pnpm exec turbo run typecheck test --filter=@bb/server Co-Authored-By: Claude <[email protected]>
SawyerHood
force-pushed
the
bb/avoid-queued-claude-workflows-thr_tym78nnbnb
branch
from
July 22, 2026 16:18
c328b74 to
8e855a7
Compare
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
A native Claude workflow (
local_workflow) was treated as completion-blocking byhasCompletionBlockingClaudeTasks, so the logical bb turn stayed open for the workflow's entire run. That kept the threadactive, andshouldQueueFollowUpMessagequeues onactive— so typing during a workflow queued the message instead of sending it. Introduced in #633, which added the predicate for background agents and folded workflows in alongside them.Workflows now let the turn complete and the thread go idle. Background agents and legacy subagents still block, unchanged. When the workflow settles and reinvokes the parent model, that work opens a fresh turn.
The busy status disappears with no UI change.
displayStatusderives fromthread.statusplus host connectivity only — background activity never feeds it. So once the turn completes, the thread-row indicator falls through from the generic "Thread working" spinner to the specific "Workflow running" glyph, while the timeline pill and the composer workflow cards keep rendering off background-task activity. All three workflow indicators survive; only the busy status goes.Two consequences handled here:
@thread:x completed, with 2 workflows still running:) and tells the parent to expect a second report rather than reading the excerpt as final. The count is captured at queue time, the same instant as the output excerpt.evictIdleRuntimeEntriescould shut a runtime down mid-workflow and SIGTERM the provider process running it.AgentRuntimenow tracks open background tasks from the event stream it already observes and exposeshasOpenBackgroundWork(), whichentryHasActiveRuntimeWorkcounts as active work. This also fixes the pre-existing case of a backgrounded dev server being killed by a shell-env change.HOST_DAEMON_PROTOCOL_VERSION63 → 64 so enrolled daemons pick up the new turn timing. The wire shape is unchanged, so an older daemon keeps the old blocking behavior rather than entering aninvalid-messageloop.Notes
RuntimeBackgroundWorkStateobserves the normalized event stream rather than plumbing the adapter'shasOpenClaudeBackgroundTasksup throughAgentRuntime— the adapter's copy is buried in a per-provider turn-state registry reachable only by the LRU pruner, and reading events keeps this provider-agnostic.skipTranscript) tasks do count for eviction. Keep Claude child threads active while subagents run #633 excluded them from turn completion because they're long-lived, but hiding a task from the transcript doesn't make it survive a SIGTERM. This matches the adapter's existingisEvictable.Tests
pnpm exec turbo run typecheck test --filter=@bb/agent-runtime— 794 passedpnpm exec turbo run typecheck test --filter=@bb/host-daemon— 467 passedpnpm exec turbo run typecheck test --filter=@bb/server— 1249 passedpnpm exec turbo run typecheck test --filter=@bb/app --filter=@bb/thread-view— passedNew coverage:
turn-2) and completes itRuntimeBackgroundWorkStateacross multi-task settling, terminal-status-via-progress, ambient tasks, and per-thread clearingreplaceBaseShellEnv, then evicts once the work settles — verified to fail without the fixOne pre-existing local failure unrelated to this change:
internal-skill-trees.test.tsexpects file mode420and gets436(umask artifact); it fails identically on a clean tree.🤖 Generated with Claude Code