Skip to content

Boundary-Aware Context Grounding for A Low-Channel EEG Agent

🕒 Published (v1): 2026-06-25 01:51 UTC · Source: Arxiv · link

Ask a follow-up

Open an assistant pre-loaded with this paper's context.

💬 Ask ChatGPT✦ Ask Claude

TL;DR

NeuraDock Agent is an open-source architecture that constrains an LLM to a hardware-aware, versioned context layer atop a fully deterministic local EEG numerical engine, preventing hallucinated capabilities or unsupported scientific conclusions. A 36-case boundary-awareness benchmark across four context ablations and two models shows that full context grounding raises exact four-way boundary classification from 58.3% to 79.2% and correct, fact-complete, false-claim-free responses from 26.4% to 66.7%.

Problem

General LLMs applied to scientific software conflate four distinct boundaries: what the physical sensor can observe, what the current software implements, what the computed result fields actually mean, and what scientific inferences those results justify. For low-channel EEG (7 channels, posterior-only montage), this produces plausible but physically unsupported interpretations—e.g., recommending frontal alpha asymmetry on a device with no frontal electrodes, or translating an engineering quality flag into a neurological conclusion. Additionally, stochastic code generation inside numerical pipelines introduces reproducibility and liability risks.

Method

The system enforces a strict two-layer separation:

  1. Deterministic local numerical core: reviewed, versioned Python workflows parse EEG recordings, perform QC, execute spectral analysis (Welch PSD, posterior alpha), and write hashed, machine-readable artifacts (results.json, report.md, figures). The LLM cannot execute generated code or modify thresholds.

  2. Hardware-aware language layer: the LLM receives only an allowlisted compact summary (workflow-specific projection that excludes raw samples, per-trial signals, full PSD vectors, dense window arrays) plus a versioned context pack containing the formal 7-channel hardware profile, reviewed workflow registry, result-field semantics, implementation boundaries, scientific limits, and reference cases. Each call records context version and a SHA-256 hash.

The Visual Cognitive Load workflow computes within-recording posterior alpha features: log-alpha power, peak frequency, and normalized right-minus-left asymmetry \(A = \frac{P_R - P_L}{P_R + P_L + \epsilon}\), combined as a weighted composite \(q = 0.65\,\text{clip}(-z_\alpha) + 0.15\,\text{clip}(z_f) + 0.20\,\text{clip}(z_{|A|})\), with robust median/MAD standardization and tertile labeling—explicitly framed as a within-recording relative heuristic, not a validated index.

The boundary-awareness benchmark prespecified 36 cases in 6 categories (electrode observability, implementation capability, result interpretation, quality diagnosis, scientific restraint, workflow integration) evaluated under 4 context ablations (Generic / Hardware / Hardware+Implementation / Full) with 2 model aliases, yielding 288 outputs scored on exact four-way decision accuracy, constraint-source F1, fact recall, unsafe acceptance rate, and over-rejection rate.

Key Contributions

  • Architecture separating deterministic EEG computation from a context-constrained LLM layer, with an explicit allowlisted payload projection and versioned context pack
  • Formal four-way boundary taxonomy (physical / implementation / result / scientific) with a corresponding benchmark measuring both unsafe acceptance and over-conservative rejection
  • Evidence that hardware+implementation context alone achieves a slightly higher strict safe-response rate than full context, motivating selective retrieval over indiscriminate context expansion
  • Documented reproducibility: 12 recordings Ă— 10 repeats and 3 end-to-end pipeline hashes show identical structured outputs in the tested environment
  • Failure isolation guarantee: LLM service failure does not invalidate local numerical artifacts

Results

  • Exact four-way boundary classification: 58.3% (Generic) → 79.2% (Full context), McNemar-tested within each model
  • Strict safe-response rate (correct decision + ≥2/3 required facts + no false claim): 26.4% → 66.7%
  • Rejection of feasible requests (over-refusal): 27.8% → 8.3%
  • Hardware+Implementation context achieved a slightly higher strict safe-response rate than Full context, indicating full context expansion is not uniformly optimal
  • Determinism: all 12 recordings produced identical hashed payloads across 10 repeats; 3 end-to-end runs produced identical result, report, and figure hashes
  • Request-boundary audit confirmed raw EEG exclusion from outgoing payloads for a 649,040-sample recording

Limitations

  • Benchmark cases were developed from the same system being evaluated, not an independent external benchmark; 96 outputs for independent reviewer validation were incomplete at submission
  • Two model aliases (not immutable checkpoint hashes) evaluated on a single date; results may not generalize across providers or versions
  • Reproducibility established only within a single software/hardware environment; cross-platform bitwise reproducibility not established
  • LLM context improvements are measured on a self-constructed question set, introducing potential construct validity issues
  • No frontal or temporal electrodes; posterior-only montage restricts scope of supportable analyses
  • System not HIPAA/GDPR certified; payload minimization does not establish legal de-identification
  • Visual Cognitive Load workflow does not directly consume clean data output from a preceding quality run; PSD workflow lacks trial-batch NPY aggregation

Relevance to Agentic AI / LLM Agents

This paper instantiates a concrete pattern for constrained scientific agents: hard separation between a deterministic tool layer and a language planner, with the LLM's information access governed by an explicit allowlist and versioned context pack rather than unrestricted tool calls. The four-way boundary taxonomy (physical / implementation / result / scientific) is a reusable framework for any domain where LLM agents interface with specialized hardware or software—directly applicable to lab-automation, medical-device, or robotics agents. The finding that selective context (hardware+implementation) can outperform full context is an empirical data point against indiscriminate context stuffing in RAG-based agent designs. The benchmark methodology—measuring both hallucination acceptance and over-refusal, with adversarial cases probing capability boundary recognition—offers a replicable evaluation template for tool-use agents in safety-sensitive domains.