Skip to content

fix(context): Support subagent and BTW context inspection - #3993

Merged
wsp1911 merged 4 commits into
openBitFun:mainfrom
wsp1911:dev-mac
Nov 18, 2026
Merged

wsp1911 merged 4 commits into
openBitFun:mainfrom
wsp1911:dev-mac

Conversation

@wsp1911

@wsp1911 wsp1911 commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Enable on-demand context composition and category previews for native subagent and BTW sessions.
  • Keep AgentSpawn and AgentFork definitions visible in fresh and reused children, matching forks, while enforcing delegation policy when tools run.
  • Read temporary BTW messages, turn metadata, prompt caches, and listing baselines from memory without creating session files or consulting unrelated durable recovery records.
  • Open child context previews in the visible conversation canvas while keeping content queries, resource identity, and duplicate detection bound to the selected child.

Type and Areas

Type: Bug fix / regression fix

Areas: Rust core session/runtime inspection; desktop/shared Web UI composer and context previews.

Motivation / Impact

Selecting a subagent or BTW conversation in the composer previously produced an unsupported context estimate. After native subagent estimates became available, clicking a category could still appear to do nothing because its preview was stored in the hidden child canvas.

Users can now inspect the selected child's current context and open its read-only category details in the visible sidebar. BTW remains memory-only, including during live turns and after compression. Inspection neither starts model execution nor restores or rewrites the session.

Verification

Passed 23 focused Rust tests, covering fresh/reused/forked children, runtime delegation denial, BTW memory ownership, previews, compression, legacy snapshots, workspace identity, and existing revert/fork behavior:

cargo test --locked -p openbitfun-core --no-default-features \
  --features agent-runtime,git,remote-workspace --lib -- \
  current_context_estimate context_composition \
  visible_launch_tools_reject_nested_subagent_delegation \
  fresh_subagent_inherits_matching_parent_worktree_binding \
  fresh_subagent_inherits_transient_parent_persistence_boundary \
  reused_subagent_send_input_updates_requested_and_inherited_model \
  reused_subagent_legacy_smart_keeps_target_until_explicit_model_replacement \
  fork_subagent_request_allows_requested_model_override \
  btw_session_is_ephemeral_and_seeds_forked_listing_baselines \
  session_fork_reconciles_pending_revert_and_rejects_hidden_explicit_turns \
  session_fork_uses_verified_remote_storage_and_preserves_execution_identity \
  sdk_usage_provider_validates_ids_and_keeps_live_token_enrichment

Passed 155 frontend DOM/store tests, including all preview categories, parent canvas routing, sibling isolation, delayed responses, and device activation fences (run from src/web-ui):

node scripts/run-vitest.mjs run --maxWorkers=50% \
  src/flow_chat/components/ChatInputWorkspaceStrip.test.tsx \
  src/flow_chat/services/openSessionContextPreview.test.ts \
  src/flow_chat/components/usage/SessionUsageComponents.test.tsx

Also passed:

pnpm run check:web
pnpm run i18n:audit
git diff --check upstream/main...HEAD

Reviewer Notes

  • Four focused commits; no persisted schema, wire protocol, or dependency changes.
  • Runtime delegation checks remain authoritative. External agents and internal ephemeral workers with execution-only restrictions retain explicit unsupported states.
  • Existing callers without an explicit canvas owner keep their previous session-scoped preview behavior.
  • AI-assisted implementation. Verification uses local unit/DOM fixtures, simulated remote-workspace and Peer surfaces, and dispatch refusal checks. Native desktop rendering and live SSH, Remote Control, Peer Device, and Detached Dispatch connections were not exercised.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

Keep launch tool definitions visible in fresh and reused child sessions,
matching forked sessions. Enforce delegation policy when tools run while
preserving transient session restrictions.

Verify child preparation, visible tool definitions, and runtime denial
with six focused unit tests.
Allow native subagent sessions to use on-demand context estimates while
retaining explicit unsupported states for external and ephemeral agents.

Cover fresh, reused, forked, and unloaded children, read-only inspection,
preview consistency, legacy snapshots, and remote rule isolation.

Validation: 12 focused tests passed with agent-runtime, git, and
remote-workspace enabled.
Keep context preview queries and identities bound to the selected child
while opening their tabs in the visible conversation canvas.

Preserve asynchronous canvas ownership, device activation fences, and
separate previews for sibling sessions.

Validation: 155 focused tests and check:web passed. Remote coverage uses
simulated SSH and Peer surfaces.
Read temporary context, turn metadata, prompt caches, and listing
baselines from their in-memory owners without creating session files.
Allow parent-owned BTW sessions to estimate context while retaining the
unsupported state for internal workers with execution-only restrictions.

Keep live memory inspection independent from unrelated durable recovery
records while preserving workspace ownership validation.

Validation: 17 focused tests passed with remote-workspace enabled, and
the i18n audit passed. Remote coverage uses simulated workspaces.
@wsp1911
wsp1911 merged commit e53e126 into openBitFun:main Nov 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant