DGCDocs
Features/Python code-action (power mode)

a persistent Python interpreter for token-efficient work

Python code-action (power mode)#

An optional power tool, off by default. Turn it on with code_action: true in ~/.dgc/config.json (or a project .dgc/), with /code-action on in the classic or full-screen TUI (a row in the TUI settings screen and a toggle in the VS Code panel do the same), or /code-action off to disable it. When on, DGC advertises a python tool.

What it is#

python runs code in a persistent interpreter tied to your session. Variables, imports, and function definitions persist across tool calls — the model can load data into a variable once and then run computations over it across many turns.

Why it saves tokens#

The usual loop re-reads data into the context on every step. With a persistent interpreter the model loads a file/dataset into a variable one time, then each later call is just a small snippet of code that operates on the already-loaded state. The bulky data never re-enters the prompt — only the code and its (bounded) output do. This is the "code action" / CodeAct pattern.

Behavior#

  • The last statement, if it is a bare expression, has its repr() shown (REPL-style).
  • stdout/stderr printed during a call are captured and returned, redacted and length-bounded like

bash.

  • An exception returns a clean traceback and the interpreter stays alive for the next call.
  • Pass reset: true to restart with a fresh, empty namespace.
  • State also resets when the session ends (or on /new).

Safety#

It executes arbitrary code on your machine — identical risk to bash — so it is gated by the same permission path: it asks in default/acceptEdits mode and is denied in plan mode. Because it is off by default, ordinary users never see it until they explicitly opt in.