Skip to content

Add LocalAgentService gRPC: proto definition, nodespaced handler, and Tauri proxy #1137

Closed

Description

@malibio

Overview

Define the LocalAgentService protobuf service, implement the handler in nodespaced, and migrate commands/local_agent.rs in the Tauri app to a thin gRPC proxy. This covers the local llama.cpp inference path only — external PTY coding agent sessions (Claude Code, Codex, etc.) are handled by AgentSessionService (#1119).

Problem Statement

commands/local_agent.rs currently manages LocalAgentService (ReAct loop + llama.cpp inference) via ManagedAgentState held in the Tauri process. Under ADR-031 all services move to nodespaced. The local agent stops when the UI window is closed, model loading is tied to the Tauri lifecycle, and GPU resources are managed in the wrong process. Moving to nodespaced allows the local agent to run headlessly and survive UI restarts.

Proposed Solution

Define LocalAgentService in the nodespace proto with streaming RPCs for token output and model load progress, implement the handler in nodespaced wrapping LocalAgentService and CompositeModelManager, and replace ManagedAgentState in the Tauri commands with LocalAgentServiceClient gRPC calls.

Technical Specifications

Proto addition (packages/daemon/proto/nodespace.proto)

service LocalAgentService {
  rpc StartSession(StartSessionRequest)              returns (StartSessionResponse);
  rpc SendMessage(SendMessageRequest)                returns (stream AgentChunk);
  rpc GetStatus(GetStatusRequest)                   returns (LocalAgentStatusResponse);
  rpc EnsureModelReady(EnsureModelReadyRequest)     returns (stream ModelLoadProgressEvent);
  rpc ListModels(ListModelsRequest)                 returns (ListModelsResponse);
}

Reference Files

  • packages/desktop-app/src-tauri/src/commands/local_agent.rs — current implementation; ManagedAgentState to remove
  • packages/agent/src/local_agent/agent_loop.rs — LocalAgentService being wrapped
  • packages/agent/src/local_agent/composite_model_manager.rs — CompositeModelManager being wrapped
  • packages/daemon/src/services/node_service.rs — follow this handler pattern
  • packages/daemon/src/main.rs — register LocalAgentService alongside NodeService

Implementation Details

  • packages/daemon/src/services/local_agent_service.rs — new handler; model loading, GPU context, and ReAct loop run in daemon
  • Token streaming: nodespaced gRPC stream → Tauri proxy → Tauri event → Svelte frontend
  • ManagedAgentState removed from Tauri app state once migration complete
  • GPU context management moves to daemon shutdown sequence (same drain pattern as EmbeddingsService)

Acceptance Criteria

  • LocalAgentService proto defined and compiled via tonic-build
  • nodespaced handler wraps ReAct loop and CompositeModelManager; runs headlessly
  • Token streaming works end-to-end: nodespaced → gRPC stream → Tauri event → frontend
  • Model loading progress streamed via gRPC; UI shows progress indicator
  • commands/local_agent.rs proxies via gRPC; no direct packages/agent imports remain
  • Local agent session continues when Tauri window is closed
  • ManagedAgentState removed from Tauri app state
  • cargo build succeeds
  • bun run test:all passes
  • bun run quality:fix passes

Dependencies

Related Issues

Activity

  1. added a commit that references this issue on May 17, 2026
  2. malibio commented on May 18, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 128 files, 3916 tests passed

  3. self-assigned this
    on May 18, 2026
  4. added a commit that references this issue on Jun 22, 2026
    7a7cb4c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions