Introduction¶
The built-in Code Mode of DeepSeek Harness does not retain state between runs, which is a limitation for complex workflows that require context. dsh-py-codeact addresses this by providing a persistent IPython session as the model’s action space.
What This Is¶
This is a Python-based CodeAct agent loop plugin maintained by CNSeniorious000. It bridges DeepSeek Harness tools into a persistent IPython session, allowing the model to execute Python code there and retain variable state.
Core Features¶
- CodeAct agent loop: Runs the agent within Harness.
- Persistent state: Variables in the session (such as
df) remain available in subsequent cells. - Tool bridging: Provides Harness tools through the
__dsh__.toolsmodule. - Native IPython support: Supports magic commands,
transform_cell, top-levelawait, and execution history. - REPL introspection: Use
?to view docstrings and signatures. - MCP integration: Supports MCP tools.
Installation and Enablement¶
The plugin repository is on GitHub: https://github.com/CNSeniorious000/dsh-py-codeact. The license is MIT.
Typical Usage¶
# 读取 CSV 并连接数据框
from __dsh__.tools import read, glob
import pandas as pd, io
paths = await glob(pattern="data/*.csv")
frames = [pd.read_csv(io.StringIO(await read(file_path=p))) for p in paths]
df = pd.concat(frames)
# 后续单元格:df 变量仍然存在
df.groupby("region").revenue.sum().nlargest(3)
Use Cases and Notes¶
This plugin is suitable for CodeAct workflows that require preserving variable state across execution steps. It has its own process, so it does not implement the CodeRuntime backend interface. Because it maintains a persistent kernel, real-time interpreter state cannot be reconstructed by replaying the session, but the logs record all cell source code and tool calls.
Summary¶
dsh-py-codeact provides a way to develop agents using a persistent IPython session. For more details, see the catalog or the GitHub repository.