Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

LSP Context Injection

Feature flag: lsp-context (included in --features full)

LSP Context Injection automatically adds compiler-derived information to the agent’s context after certain tool calls — without the LLM needing to issue explicit tool requests.

What It Does

Three hooks fire automatically during a conversation:

HookTriggerWhat gets injected
DiagnosticsAfter write_fileCompiler errors and warnings for the saved file
Hover (opt-in)After read_fileType signatures for key symbols in the file
ReferencesBefore rename_symbolAll call sites of the symbol being renamed

The injected data appears as a [lsp ...] prefixed message in the conversation history — the same pattern used by semantic recall and graph facts. A per-turn token_budget cap prevents runaway context growth.

Why It Matters

Without this feature, the agent has to explicitly call get_diagnostics, get_hover, or get_references after every file operation. With LSP Context Injection enabled, the feedback loop is automatic:

  1. Agent writes a file.
  2. Zeph fetches diagnostics from the language server.
  3. Errors appear as the next turn’s context — the agent fixes them immediately.

No extra round-trips. No “check for errors” prompt needed.

Prerequisites

  • mcpls configured as an MCP server (see LSP Code Intelligence)
  • lsp-context feature enabled (already included in the full feature set)

Enabling

# For a single session
zeph --lsp-context

# Or set permanently in config.toml
[agent.lsp]
enabled = true

The interactive wizard (zeph --init) prompts for this setting after the mcpls step.

Graceful Degradation

When mcpls is unavailable, all hooks silently skip. The agent continues working normally — no errors are shown, no functionality is lost. Individual failures are logged at debug level only.

Configuration and Details

Full configuration reference, token budget tuning, and TUI status command: LSP Context Injection → guides/lsp.md

For IDE-proxied LSP via ACP (Zed, Helix, VS Code): ACP LSP Extension → guides/lsp.md