langstage-vscode
Chat with your own LangGraph agent from inside your editor, in the LangStage panel: the extension's own chat view, so it works in VS Code without Copilot, and in Cursor, VSCodium, Windsurf and code-server. Streaming replies, tool-call cards, reasoning, approval cards, and several conversations saved per workspace. (The panel is a preview.)
If the image above doesn't load, the same recording is in this repo:
docs/assets/panel-demo.gif.
Using Copilot? The same agent is also the @langstage chat participant in
Copilot's chat view (below).
Quick install (details in Install):
pip install langstage-vscode(the Python sidecar, in the environment that can import your agent).- Search LangStage in the Extensions view and install it (from the VS Code Marketplace; Cursor, VSCodium and Windsurf install it from Open VSX).
- Open the LangStage view in the activity bar and click Try the demo, or set
langstage.agentSpecto your agent.
Renamed from deepagent-vscode (the old package name now just installs this one;
python -m deepagent_vscodeand the old sidecar command still work).
It has two parts in one repo:
extension/— a TypeScript extension: the LangStage panel (a webview view) and the@langstagechat participant.langstage_vscode/— a small Python stdio sidecar that loads your agent and streams its events. Built onlangstage-core, so it streams the same AG-UI frame vocabulary as the other LangStage stages (langstage,langstage-jupyter,langstage-cli).
┌─ your editor ───────────────────────────────────┐
│ LangStage panel / @langstage (Copilot chat) │
│ │ the extension spawns │
│ ▼ │
│ python -m langstage_vscode (stdio sidecar) │
│ │ NDJSON over stdin/stdout │
│ ▼ │
│ your LangGraph / deepagents agent │
└──────────────────────────────────────────────────┘
Status: preview. The extension is on the VS Code Marketplace and Open VSX (see Install); each release's
.vsixis also on GitHub releases.
Every stage for your LangGraph agent
langstage-vscode is the VS Code stage of the LangStage family: write your agent once — any LangGraph CompiledGraph — and run it on every stage with the same spec string (module:attr or path/to/file.py:attr), the same langstage.toml config file, and the same LANGSTAGE_* environment variables.
| Stage | Package | Try it |
|---|---|---|
| Web app | langstage | langstage run --agent my_agent.py:graph |
| JupyterLab | langstage-jupyter | pip install langstage-jupyter, then the chat sidebar in jupyter lab |
| Terminal | langstage-cli | langstage-cli -a my_agent.py:graph |
| VS Code | langstage-vscode | you are here |
| Reference agent | langstage-hermes | LANGSTAGE_AGENT_SPEC=langstage_hermes.agent:graph on any stage |
| Shared core | langstage-core | AG-UI streaming bridge + config resolver behind every stage |
📖 Full documentation: https://dkedar7.github.io/langstage-docs/
Serve over AG-UI
The sidecar already streams every turn through the in-process AG-UI adapter. Your
agent — any LangGraph CompiledGraph — can also be served over the
AG-UI protocol as a standalone HTTP
endpoint, without changing your agent code:
pip install "langstage-core[agui]"
langstage-agui --agent my_agent.py:graph
Install
Sidecar (Python)
pip install langstage-vscode
Install it into the interpreter langstage.pythonPath points at (see Configure).
The extension (0.6.2+) expects langstage-vscode 0.5.35 or newer there. It still runs an
older one, but warns that some features may not work and offers the upgrade command for
that interpreter (<python> -m pip install -U langstage-vscode); see
the ready handshake. If that interpreter doesn't have langstage-vscode
at all, the panel says so and offers the <python> -m pip install langstage-vscode command
(extension 0.6.3+).
--demo (the keyless echo stub) runs on this base install — since 0.5.0 the base
deps pull the AG-UI runtime, which brings langgraph, so no extra is needed.
Pass --demo=tools for the rich-frame demo that exercises
tool_start/tool_end/reasoning/interrupt keyless — the extension's headline
rendering surface, without an agent or API key (parity with langstage-agui --demo=tools).
Extension
Open the Extensions view (Ctrl+Shift+X / Cmd+Shift+X), search LangStage, and
click Install (VS Code 1.95 or newer). The extension ID is dkedar7.langstage-vscode:
- VS Code installs it from the VS Code Marketplace.
- Cursor, VSCodium, Windsurf (and other Open VSX-based editors) install it from Open VSX.
Or from a terminal (use cursor, codium or windsurf in place of code in those
editors):
code --install-extension dkedar7.langstage-vscode
Fallback: install the VSIX. Each release's .vsix is also attached to its GitHub
release: download langstage-vscode-<version>.vsix from the
latest extension release,
then run Extensions: Install from VSIX… and pick the file, or
code --install-extension langstage-vscode-<version>.vsix. Use this for an offline or
air-gapped machine, or an editor that reaches neither registry.
Every CI run on main also builds a .vsix (the langstage-vscode-vsix artifact of
the CI workflow),
if you want an unreleased build.
Or build the same file yourself:
cd extension
npm install
npm run package # writes langstage-vscode-<version>.vsix
To work on the extension, run npm run compile and press F5 in VS Code (with the
extension/ folder open) to launch an Extension Development Host with the LangStage panel (and @langstage, where
the chat view exists) available.
Configure
In VS Code settings:
| Setting | Description | Default |
|---|---|---|
langstage.agentSpec |
Your agent, as path/to/agent.py:graph or module:graph |
(falls back to LANGSTAGE_AGENT_SPEC / langstage.toml) |
langstage.pythonPath |
Python interpreter that has langstage-vscode installed |
python |
The sidecar resolves its configuration through the family-standard chain —
defaults < langstage.toml (global + project) < LANGSTAGE_* env < CLI
flags — so a project with [agent] spec = "my_agent.py:graph" in its
langstage.toml needs no VS Code setting at all. Inspect the resolved values:
langstage-vscode-sidecar --show-config
A relative path in a langstage.toml ([agent] spec = "agent.py:graph", [workspace] root)
resolves against that file's directory, so the sidecar behaves the same from any
subdirectory of the project; a relative --agent / LANGSTAGE_AGENT_SPEC resolves against the
directory you launched from. A leading ~ expands everywhere, and stray whitespace around the
spec is ignored. A [configurable] table is forwarded verbatim to your graph's
config["configurable"] on every turn and shown by --show-config:
[agent]
spec = "my_agent.py:graph"
[configurable]
model = "claude-sonnet-4-5" # read in a node via config["configurable"]["model"]
--show-config --json lists every config file it read under toml.paths (the global
~/.langstage/config.toml first), and reports a langstage.toml that exists but doesn't parse
as "malformed": true with the parse error, rather than as absent.
Preflight the interpreter and your agent before wiring up chat — --selfcheck
(alias --smoke) loads the configured agent (or the demo stub), asserts it's a
runnable graph, drives one turn, and exits 0 (healthy) / non-zero with a precise
message (add --json for a machine-readable verdict). If that turn pauses on a
human-in-the-loop interrupt instead of replying, the verdict is PAUSED: ("ok": false, "interrupt": true in --json) with exit 2, the code --message uses for a pause.
Such an agent works in the editor: it asks for your decision on its first turn, as an
approval card in the LangStage panel or as decision buttons under @langstage (see
Answering an interrupt). From the CLI, --repl
answers it with :decision <verb>. The --json verdict also carries checkpointer,
the served agent's checkpointer as the ready frame reports it (see
Sidecar protocol):
langstage-vscode-sidecar --selfcheck # validate the runtime via the demo stub
langstage-vscode-sidecar --selfcheck --agent ./my.py:graph # validate the configured agent
With no agent configured, a pass says it only validated the runtime with the demo stub
("demo_fallback": true in --json). If a langstage.toml key that looks like a typo'd
spec was ignored ([agent] specc = ..., an [agents] table), --selfcheck fails and
names the key rather than validating the stub in your agent's place.
--selfcheck answers "is the runtime healthy?"; --message answers "what does my
agent actually say?" — it drives one turn with your prompt and prints the reply, then
exits (no NDJSON + shutdown to hand-craft). Add --json to get the raw event frames
instead of the assembled text:
langstage-vscode-sidecar --demo --message "hello" # prints the reply
langstage-vscode-sidecar --agent ./my.py:graph --message "summarize the repo"
langstage-vscode-sidecar --agent ./my.py:graph --message "hi" --json # raw event frames
Bare --demo is the echo stub (only content frames); --demo=tools serves the
rich-frame demo — a keyless way to see every non-content frame the extension renders,
no agent and no API key. Its trigger phrases route to each frame type:
langstage-vscode-sidecar --demo=tools --message "please use a tool" --json # tool_start/tool_end/extraction
langstage-vscode-sidecar --demo=tools --message "think about it" --json # reasoning frames
langstage-vscode-sidecar --demo=tools --message "ask me first" # HITL interrupt, exits 2
langstage-vscode-sidecar --demo=tools --repl # answer the interrupt inline
--message answers "what does my agent say once?"; --repl answers "does it
remember?" — the multi-turn companion to --message. It reads one prompt per line and
drives a turn, but keeps one long-lived session (a single session_id, so a single
LangGraph thread_id) alive for every turn — the same per-conversation shape the VS Code
extension uses — so your agent's memory persists across turns. That makes the memory
behavior below verifiable from the CLI in ten seconds: tell it your name, ask on the next
line. Exit with Ctrl-D (EOF) or a :quit line; --json streams
the raw event frames instead of the assembled text, just like --message:
langstage-vscode-sidecar --agent ./my.py:graph --repl
> my name is Kedar
...
> what is my name?
...
> :quit
Your agent will recall the first line on the second even if you never compiled in a
checkpointer — within one sidecar process the sidecar auto-attaches an in-memory checkpointer
to any graph that lacks one, so --repl (one process, one session_id) verifies in-process
memory and catches a wrong-session_id mistake before wiring up the extension. What it can't
prove is durable memory: that in-memory state is lost when the process ends, so persistence
across separate processes still needs a persistent checkpointer (see the memory note under
Sidecar protocol).
Both turn-drivers are interrupt-aware. If your agent pauses on a human-in-the-loop
interrupt(...) (the common deepagents / LangGraph approval pattern), the turn is no longer
a silent blank — the pending action and the decisions it allows are surfaced on stderr
(stdout stays the clean reply channel), and one-shot --message exits with a distinct code
2 so an interrupt is scriptable, distinct from a clean reply (0) or an error (1):
$ langstage-vscode-sidecar --agent ./hitl.py:graph --message "do it"
interrupt: agent paused awaiting a decision
action: confirm allowed: reject | edit | respond | approve
resume by sending a `decision` command (add --json to see the full request)
$ echo $?
2
With --json, the raw {"type": "interrupt", ...} frame streams on stdout, so a consumer keys
on it directly.
--repl can also answer the interrupt, completing the interrupt → decision round-trip
without hand-writing the stdio protocol. When a turn ends on an interrupt, the session enters
decision mode: the next line becomes a decision on the same session, so it resumes that
thread's pending interrupt.
$ printf 'do it\napprove\n:quit\n' | langstage-vscode-sidecar --agent ./hitl.py:graph --repl
interrupt: agent paused awaiting a decision
action: confirm allowed: reject | edit | respond | approve
answer it here: `:decision <verb>` (or a bare `<verb>`) using a verb above
payloads: reject [<text>] | edit <json> | respond <text>
resumed with: {'decisions': [{'type': 'approve'}]}
- Type
:decision <verb>(same:-prefixed namespace as:quit), or just the bare verb — a bare verb is only read as a decision while an interrupt is pending; the rest of the timeapproveis ordinary chat text. - The verbs come from that interrupt's own
allowed_decisions, so an approval-only agent offers and accepts exactlyreject | approve(the legacy aliases below are accepted too). Payloads follow the LangChain HITL decisions:approve,reject [<text>],respond <text>,edit <json>(free text becomesmessage, a JSON object is merged in, e.g.edit {"edited_action": {"name": "confirm", "args": {}}}). - While an interrupt is pending, a line that isn't a valid decision is refused on stderr and
re-prompted with the interrupt left pending — it is never silently sent as a new message (which
would just re-interrupt and look accepted) and never swallowed.
:quitis always the way out. --jsoncomposes: the answer line emitsackwith"ref": "decision", so the trace readsready → ack message → interrupt → complete → turn_end → ack decision → content → complete → turn_end. (Both turns emitcomplete— an interrupt turn isinterrupt → complete → turn_end; it is paused, not finished-with-a-reply, so detect the pause via theinterruptframe, not the absence ofcomplete.)--replexit codes:0on a clean session (including an interrupt that was answered),1if the agent could not start at all, and2if the session ends with an interrupt still unanswered — the same "paused awaiting a decision" signal--messageuses.
You can still drive decision over the raw stdio protocol directly
({"type": "decision", "session_id": "...", "decisions": [{"type": "approve"}]}). That is what
the VS Code extension sends when you click a decision button in the chat (see
Answering an interrupt from the chat).
Your agent is any LangGraph CompiledGraph (e.g. from deepagents), exported
under the name in the spec:
# my_agent.py
from deepagents import create_deep_agent
graph = create_deep_agent(...) # -> langstage.agentSpec = "my_agent.py:graph"
Exit codes
The sidecar uses the LangStage family exit codes (core ADR 0007), the same on every surface:
| Code | Meaning |
|---|---|
0 |
success: --selfcheck healthy, --message replied, --repl / the stdio loop ended cleanly, --show-config printed |
1 |
failure: no agent spec, the agent failed to load or isn't a runnable graph (an uncompiled StateGraph, a factory function), an unusable --workspace, an error frame from --message, a failed --selfcheck |
2 |
paused on a human-in-the-loop interrupt (--selfcheck, --message, or --repl ending with one unanswered) |
64 |
usage error: an unknown flag or bad value (--demo=bogus), or conflicting flags (--demo with --agent, --repl with --message) |
2 means only "paused". Usage errors exit 64 rather than argparse's default 2, so a
typo'd flag in a script can't read as a pause.
On the stdio loop, 1 means the sidecar couldn't serve the agent at all (gh #158). An
error frame for a bad command or a failed turn is answered and the loop keeps serving,
so the loop still ends with 0 on shutdown or EOF.
Usage
The LangStage panel (preview)
Extension 0.5.0 added the LangStage panel: the extension's own chat view, in the activity bar (the LangStage icon), or via LangStage: Open the LangStage panel in the command palette. It needs nothing but the editor and the sidecar, so it works with or without Copilot, in VS Code, Cursor, VSCodium, Windsurf and code-server (ADR 0001).

Recorded by npm run record (extension/test/record/): the real panel bundle in the
webview harness, themed like VS Code's Dark Modern, driven through the real host logic
against the real sidecar running --demo=tools. No Copilot, no API key.
- Replies stream in as markdown. Each assistant message (
message_id) is its own block. - Tool calls are collapsible cards with the arguments, the result, the status and the
duration. Reasoning is a collapsed block, apart from the reply. A
write_todosplan is one live Tasks checklist at the top, updated in place. - Stop cancels the turn cooperatively: the agent keeps its memory of the conversation.
- Approvals (0.6.0). When the agent pauses on a human-in-the-loop interrupt, the panel shows an approval card with the action and its arguments, and one button per decision the interrupt allows: Approve, Reject (with an optional reason), Respond (answer in words), Edit (the arguments as JSON, checked before sending), and any custom verb the gra
