Skip to content

LBA REQ 106

github-actions[bot] edited this page Nov 25, 2026 · 3 revisions

LBA-REQ-106: Local-model loop in one command

Status

Planned

Area

Capture / agentic infrastructure (ADR-0095)

Statement

The system shall run one local-model loop without an editor: record a desktop or test-source capture in the extension's format with CPU/RAM and GPU samples, send a prompt to a local Ollama model through the MCP bridge, mark prompt sent, first token, response done and the GPU edges, export a clip around them, and print one metadata-only receipt.

Rationale

The correlated capture of LBA-REQ-105 needs VS Code to start and stop. A local model on the machine that holds the screen (first a Windows 11 laptop with an NVIDIA GPU) is measured end to end only when one command starts the capture, prompts the model, cues the GPU rise and clips it (#134 slice 4).

Acceptance Criteria

  • node out/mcp/localModelLoop.js needs no VS Code. It writes run-<uuid>/ under --captures-dir (default: the extension's globalStorage captures folder for the platform) with the extension's capture-meta.json, active-capture-session.json, capture-status.json, frame PNGs, resources.jsonl, gpu.json/gpu.jsonl and capture.json (frames[] index/tMs/image, samples, markers[] with imageGrab).
  • Frames come from the extension's ffmpeg arguments (gdigrab on Windows, x11grab on Xorg) or from --source test (lavfi testsrc in real time) at --fps (default 4); the CPU/RAM and GPU samplers run alongside.
  • After --lead-ms (default 2000) the prompt (and an optional --image PNG) goes to --model at --ollama through the MCP bridge with a streamed /api/chat; tools are offered only from the bridge's default allow-list plus --allow-tool, and only when the model reports the tools capability. "prompt sent", "first token" and "response done" are agent cues on the shared nearest-frame grab.
  • After --tail-ms (default 3000) everything stops, the automatic GPU cues are added, all markers are in time order, and the clip covers the earliest of prompt sent and the first GPU cue minus 1 s to response done plus 1 s inside clips/.
  • One JSON receipt goes to stdout and next to the clip: capture id, model name, digest and capabilities, per-cue instantMs, offset from prompt sent and imageGrab, GPU edges, first-token latency, clip SHA-256, size and duration, frame count, and GPU availability or the reason. It holds no pixels and at most 200 characters of the answer.
  • Unreachable Ollama, a missing model, missing ffmpeg or a refused desktop are reported before a capture starts (exit 3); a capture without frames is marked failed (exit 4); a failed chat (exit 5) or clip (exit 6) still writes the receipt; missing nvidia-smi marks the GPU unavailable and the loop completes.
  • Reference mode (#139 slice 2): --reference openwebui --endpoint <https url> --token-file <path> --reference-model <id> first streams the same prompt through the Open WebUI chat-completions API (OpenAI-compatible SSE), with the cues "reference sent", "reference first token" and "reference done" on the same axis while the GPU sampler runs as the idle control, then runs the local phase. Both sides use temperature 0, --seed (default 42) and --max-tokens (default 256). The receipt adds one comparison block: first-token latency, total time, output count (tokens, or labelled chunks) and tokens/s per side, the GPU utilization and VRAM during the reference window, the local VRAM peak and the GPU edges. The token is read once from an owner-only, non-empty file and sent only as the Authorization: Bearer header. It never appears in argv, output, logs, the receipt or capture.json. The endpoint must be https (plain http only for 127.0.0.1 or localhost). Exit 7 is a failed reference run and 8 a reference timeout. Without these flags the loop is unchanged.
  • Like-for-like reference (#143): the reference preflight records alias (the /api/models entry has a non-empty info.base_model_id), baseModelId, hasTools and hasDefaultFeatures (booleans only, never tool or feature names) in the receipt and comparison.referenceModel; an alias prints one stderr warning naming the base id and --reference-model <base>, without changing the exit code. --no-tools sends the local model no tools key and records toolsOffered: []; with --allow-tool it is a usage error (exit 2); without it the Ollama request is byte-for-byte unchanged. Both sides of comparison hold promptTokens (reference usage.promptTokens; local prompt_eval_count of the final turn), firstTokenMs (first token of any kind, thinking or reasoning included), firstAnswerMs (first content or tool-call token) and tokens/s over first token to done; the local side holds thinkingChars, the reference side reasoningChars. The cue "first token" means the first token of any kind; "answer started" and "reference answer started" mark the first answer token.

Verification

node test/local-model-loop.mjs and node test/local-model-loop-reference.mjs (T-106, including a sentinel token grepped in every output and artifact of a full loop against a fake SSE server); a real loop with a local Ollama, nvidia-smi and ffmpeg on a LINUX workstation is recorded on the pull request. The Windows laptop run is to be proven.

Historical statement (no longer implemented)

Supersession

Change Guidance

TestID

T-106

CodeRef

src/mcp/localModelLoop.ts; src/mcp/ollamaMcpBridge.ts; src/capturePlatform.ts; src/captureAssemble.ts; src/captureHost.ts; src/extension.ts; package.json; test/local-model-loop.mjs; src/mcp/openWebUiReference.ts; test/local-model-loop-reference.mjs; test/extension-activation.mjs; test/ollama-mcp-bridge.mjs; docs/information-for-users/command-reference.md; docs/architecture/adr/ADR-0095-correlated-capture-local-clips.md

RTM Status

Planned

Clone this wiki locally