Skip to content

feat(#2761): multi-agent orchestration — copilot/worker pattern#2779

Open
windoliver wants to merge 9 commits intodevelopfrom
feat/2761-agent-runtime-syscalls
Open

feat(#2761): multi-agent orchestration — copilot/worker pattern#2779
windoliver wants to merge 9 commits intodevelopfrom
feat/2761-agent-runtime-syscalls

Conversation

@windoliver
Copy link
Collaborator

@windoliver windoliver commented Mar 5, 2026

Closes #2761

Summary

  • Wire agent runtime (ProcessManager, ToolDispatcher, CopilotOrchestrator) through the NexusFS kernel syscall layer — same pattern as sys_read/sys_write for files
  • Add 5 new @rpc_expose syscalls: sys_proc_spawn, sys_proc_kill, sys_proc_wait, sys_proc_list, sys_dispatch
  • Fix CopilotOrchestrator tier violation by introducing TaskManagerProtocol in contracts
  • Add process hook dispatch (pre/post spawn, post terminate) to KernelDispatch
  • Wire ProcessManager + ToolDispatcher through factory boot with degradable fallback
  • Update README with agent runtime quickstart examples and architecture docs

Changes

Contracts (Tier 0)

  • contracts/vfs_hooks.py — add ProcessSpawnHookContext, ProcessTerminateHookContext, VFSProcessHook protocol
  • contracts/agent_runtime_types.py — add TaskManagerProtocol, ProcessManagerProtocol, ToolDispatcherProtocol, data types

Core (Tier 0)

  • core/kernel_dispatch.py — add process hook slot with register/intercept methods
  • core/nexus_fs.py — add 5 sys_proc_* and sys_dispatch syscalls via run_sync() bridge
  • core/config.py — add process_manager and tool_dispatcher to SystemServices

System Services (Tier 1)

  • system_services/agent_runtime/agent_loop.py — reasoning loop (message → LLM → tool calls → respond)
  • system_services/agent_runtime/copilot_orchestrator.py — copilot/worker delegation with inherit-and-restrict permissions
  • system_services/agent_runtime/process_audit_hook.py — audit logging for spawn/terminate events

Factory

  • factory/_system.py — degradable boot block for ProcessManager + ToolDispatcher
  • factory/orchestrator.py — wire into SystemServices + register ProcessAuditHook

Tests (266 passing)

  • 208 unit tests (process syscalls, kernel dispatch, agent loop, process manager, tool dispatcher, session store, copilot orchestrator, delegation)
  • 10 multi-agent orchestration e2e tests
  • 48 scheduler phase 3 tests

Test plan

  • uv run pytest tests/unit/core/test_process_syscalls.py tests/unit/core/test_kernel_dispatch_process.py -v — 20 tests pass
  • uv run pytest tests/unit/system_services/ -v — 80+ tests pass
  • uv run pytest tests/e2e/self_contained/test_multi_agent_orchestration_e2e.py -v — 10 tests pass
  • ruff check + ruff format — clean
  • Performance: 266 tests in 1.52s, 10-worker fan-out <0.08s

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Type Safety Progress 📉

Current: 276 type: ignore comments
Baseline: 531 (Phase 3 start)
Change: -255

✅ Progress! Keep eliminating type suppressions!

@windoliver windoliver changed the title feat(#2761): wire agent runtime through kernel syscalls feat(#2761): multi-agent orchestration with kernel syscalls + README update Mar 5, 2026
@windoliver windoliver changed the title feat(#2761): multi-agent orchestration with kernel syscalls + README update feat(#2761): multi-agent orchestration — copilot/worker pattern Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Type Safety Progress 📉

Current: 276 type: ignore comments
Baseline: 531 (Phase 3 start)
Change: -255

✅ Progress! Keep eliminating type suppressions!

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Type Safety Progress 📉

Current: 265 type: ignore comments
Baseline: 531 (Phase 3 start)
Change: -266

✅ Progress! Keep eliminating type suppressions!

- Add process hook types (ProcessSpawnHookContext, ProcessTerminateHookContext,
  VFSProcessHook) to contracts/vfs_hooks.py
- Add TaskManagerProtocol to contracts/agent_runtime_types.py to fix
  CopilotOrchestrator LEGO tier violation (system_services -> bricks)
- Add process hook dispatch to KernelDispatch (register, pre/post spawn,
  post terminate)
- Add sys_proc_spawn, sys_proc_kill, sys_proc_wait, sys_proc_list,
  sys_dispatch syscalls to NexusFS with hook integration
- Add ProcessAuditHook for spawn/terminate audit logging
- Wire ProcessManager + ToolDispatcher through factory boot
- Add agent_loop, copilot_orchestrator, process_audit_hook implementations
- Update README with agent runtime quickstart and architecture examples
- 266 tests passing (208 unit + 10 e2e + 48 scheduler)
Previous commit incorrectly overwrote develop's README during merge
conflict resolution. This restores the full OS-architecture README
from develop and only adds the copilot/worker delegation quickstart.
… fixes

- Extract agent_step() single-turn function from agent_loop()
- Add AgentVFSProtocol + AgentSearchProtocol (decouple from NexusFS)
- Add registry-based spawn (agent_id lookup like installed binary)
- Fix import-linter: use importlib pattern for bricks.a2a imports
- Fix e2e test: use _StubProcessManager for Protocol-compatible fixtures
- Extend AgentSpec with runtime fields (model, tools, prompt, limits)
- Add StepAction/StepResult/AgentNotFoundError to contracts
- 63 new/updated tests across 4 test files
Show agent_id registry lookup (Option A) as the primary spawn path,
with inline AgentProcessConfig as backward-compatible Option B.
- test_full_lifecycle: use orchestrator.complete_task() instead of
  direct tm.update_task_state() so the asyncio.Event in collect()
  gets set properly
- test_partial_cancel: accept WORKING state (background _run_worker
  may have transitioned from SUBMITTED)
- _make_mock_td: return ToolResult objects from _dispatch() instead
  of raw strings, matching agent_loop's _dispatch_tool expectations
- Agent Engine section now shows AgentProcessConfig with all key fields
  (model, system_prompt, tools, max_turns, max_context_tokens)
- New "Registry-Based Spawn" section shows AgentSpec registration and
  spawn-by-name pattern (like installed binaries in /usr/bin/)
- Copilot/Worker section now shows full import paths, WorkerConfig
  fields with inline comments, and DeliveryPolicy usage
- Fix: `registry` no longer appears out of nowhere
After the #2776 refactoring that renamed LocalBackend → CASLocalBackend,
the README and live LLM e2e test still used the old import path.
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 3f4b0d9 Previous: 8cca243 Ratio
tests/benchmarks/test_core_operations.py::TestFileOperationBenchmarks::test_write_small_file 75.54370716430918 iter/sec (stddev: 0.04459602137253007) 300.78711742209896 iter/sec (stddev: 0.00047809087645420096) 3.98
tests/benchmarks/test_core_operations.py::TestBulkOperationBenchmarks::test_write_batch_10 27.969178798253438 iter/sec (stddev: 0.0013931588749504598) 39.188778970248656 iter/sec (stddev: 0.001138536110711972) 1.40
tests/benchmarks/test_rebac_latency.py::TestL1CacheHit::test_l1_cache_hit_latency 16553.73243238054 iter/sec (stddev: 0.000010926039033361148) 29000.081830264273 iter/sec (stddev: 0.000003409453269809088) 1.75
tests/benchmarks/test_service_delegation.py::TestAsyncDelegationOverhead::test_version_get_delegation 6559.310038051228 iter/sec (stddev: 0.000025041315679128562) 8930.124477576594 iter/sec (stddev: 0.00003489369801859649) 1.36
tests/benchmarks/test_service_delegation.py::TestAsyncDelegationOverhead::test_rebac_check_delegation 4642.175264378427 iter/sec (stddev: 0.004855035428926194) 8769.424929753402 iter/sec (stddev: 0.000028394751338990928) 1.89
tests/benchmarks/test_service_delegation.py::TestAsyncDelegationOverhead::test_mcp_list_mounts_delegation 6487.711891739203 iter/sec (stddev: 0.000024624263603431895) 8921.993016840954 iter/sec (stddev: 0.00003357628815439365) 1.38

This comment was automatically generated by workflow using github-action-benchmark.

Rebase conflict resolution incorrectly kept develop's concrete NexusFS
version. Restores AgentVFSProtocol + AgentSearchProtocol decoupling
in constructor, _grep(), and _glob() methods.
@windoliver windoliver force-pushed the feat/2761-agent-runtime-syscalls branch from 9f26eb6 to 2da730e Compare March 5, 2026 19:59
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Type Safety Progress 📉

Current: 265 type: ignore comments
Baseline: 531 (Phase 3 start)
Change: -266

✅ Progress! Keep eliminating type suppressions!

test_delegation.py had broken imports (AgentLoopConfig,
CheckpointNotFoundError, etc.) that caused ImportError during
pytest collection → orphan Python processes → macOS CI hung for 2h52m.

This file is superseded by test_copilot_orchestrator.py (1073 lines,
36 tests, all passing).
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Type Safety Progress 📉

Current: 265 type: ignore comments
Baseline: 531 (Phase 3 start)
Change: -266

✅ Progress! Keep eliminating type suppressions!

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.

[FEATURE] Multi-Agent Orchestration — Copilot / Worker Pattern

1 participant