refactor: remove old get_agent_session_state and get_agent_session_memory tools
This commit is contained in:
@@ -3714,82 +3714,6 @@ def list_agent_sessions(
|
||||
)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def get_agent_session_state(
|
||||
agent_work_dir: Annotated[str, "Path to the agent's working directory"],
|
||||
session_id: Annotated[str, "The session ID (e.g., 'session_20260208_143022_abc12345')"],
|
||||
) -> str:
|
||||
"""
|
||||
Load full session state for a specific session.
|
||||
|
||||
Returns complete session data including status, progress, result,
|
||||
metrics, and checkpoint info. Memory values are excluded to prevent
|
||||
context bloat -- use get_agent_session_memory to retrieve memory contents.
|
||||
"""
|
||||
state_path = Path(agent_work_dir) / "sessions" / session_id / "state.json"
|
||||
data = _read_session_json(state_path)
|
||||
if data is None:
|
||||
return json.dumps({"error": f"Session not found: {session_id}"})
|
||||
|
||||
memory = data.get("memory", {})
|
||||
data["memory_keys"] = list(memory.keys()) if isinstance(memory, dict) else []
|
||||
data["memory_size"] = len(memory) if isinstance(memory, dict) else 0
|
||||
data.pop("memory", None)
|
||||
|
||||
return json.dumps(data, indent=2, default=str)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def get_agent_session_memory(
|
||||
agent_work_dir: Annotated[str, "Path to the agent's working directory"],
|
||||
session_id: Annotated[str, "The session ID"],
|
||||
key: Annotated[str, "Specific memory key to retrieve. Empty for all."] = "",
|
||||
) -> str:
|
||||
"""
|
||||
Get memory contents from a session.
|
||||
|
||||
Memory stores intermediate results passed between nodes. Use this
|
||||
to inspect what data was produced during execution.
|
||||
|
||||
If key is provided, returns only that memory key's value.
|
||||
If key is empty, returns all memory keys and their values.
|
||||
"""
|
||||
state_path = Path(agent_work_dir) / "sessions" / session_id / "state.json"
|
||||
data = _read_session_json(state_path)
|
||||
if data is None:
|
||||
return json.dumps({"error": f"Session not found: {session_id}"})
|
||||
|
||||
memory = data.get("memory", {})
|
||||
if not isinstance(memory, dict):
|
||||
memory = {}
|
||||
|
||||
if key:
|
||||
if key not in memory:
|
||||
return json.dumps(
|
||||
{
|
||||
"error": f"Memory key not found: '{key}'",
|
||||
"available_keys": list(memory.keys()),
|
||||
}
|
||||
)
|
||||
value = memory[key]
|
||||
return json.dumps(
|
||||
{
|
||||
"session_id": session_id,
|
||||
"key": key,
|
||||
"value": value,
|
||||
"value_type": type(value).__name__,
|
||||
},
|
||||
indent=2,
|
||||
default=str,
|
||||
)
|
||||
|
||||
return json.dumps(
|
||||
{"session_id": session_id, "memory": memory, "total_keys": len(memory)},
|
||||
indent=2,
|
||||
default=str,
|
||||
)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def list_agent_checkpoints(
|
||||
agent_work_dir: Annotated[str, "Path to the agent's working directory"],
|
||||
|
||||
@@ -37,8 +37,6 @@ Ported from `agent_builder_server.py` lines 3484-3856. Pure filesystem reads —
|
||||
| Tool | Purpose |
|
||||
|------|---------|
|
||||
| `list_agent_sessions(agent_name, status?, limit?)` | List sessions, filterable by status |
|
||||
| `get_agent_session_state(agent_name, session_id)` | Full session state (memory excluded to prevent context bloat) |
|
||||
| `get_agent_session_memory(agent_name, session_id, key?)` | Read memory contents from a session |
|
||||
| `list_agent_checkpoints(agent_name, session_id)` | List checkpoints for debugging |
|
||||
| `get_agent_checkpoint(agent_name, session_id, checkpoint_id?)` | Load a checkpoint's full state |
|
||||
|
||||
@@ -67,7 +65,7 @@ Add all 8 tools after the existing `undo_changes` tool:
|
||||
|
||||
# ── Meta-agent: Session & checkpoint inspection ───────────────
|
||||
# _resolve_hive_agent_path(), _read_session_json(), _scan_agent_sessions(), _truncate_value()
|
||||
# list_agent_sessions(), get_agent_session_state(), get_agent_session_memory()
|
||||
# list_agent_sessions(), list_agent_checkpoints(), get_agent_checkpoint()
|
||||
# list_agent_checkpoints(), get_agent_checkpoint()
|
||||
|
||||
# ── Meta-agent: Test execution ────────────────────────────────
|
||||
|
||||
@@ -43,7 +43,7 @@ Dedicated tool server providing:
|
||||
- **File I/O**: `read_file` (with line numbers, offset/limit), `write_file` (auto-mkdir), `edit_file` (9-strategy fuzzy matching ported from opencode), `list_directory`, `search_files` (regex)
|
||||
- **Shell**: `run_command` (timeout, cwd, output truncation)
|
||||
- **Git**: `undo_changes` (snapshot-based rollback)
|
||||
- **Meta-agent**: `discover_mcp_tools`, `list_agents`, `list_agent_sessions`, `get_agent_session_state`, `get_agent_session_memory`, `list_agent_checkpoints`, `get_agent_checkpoint`, `run_agent_tests`
|
||||
- **Meta-agent**: `discover_mcp_tools`, `list_agents`, `list_agent_sessions`, `list_agent_checkpoints`, `get_agent_checkpoint`, `run_agent_tests`
|
||||
|
||||
All file operations sandboxed to a configurable project root.
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ The agent is deeply integrated with the framework: it can discover available MCP
|
||||
- **`reference/`** — Framework guide, file templates, and anti-patterns docs embedded as agent reference material
|
||||
|
||||
### New: Coder Tools MCP Server (`tools/coder_tools_server.py`)
|
||||
- 1500-line MCP server providing 15 tools: `read_file`, `write_file`, `edit_file` (with opencode-style 9-strategy fuzzy matching), `list_directory`, `search_files`, `run_command`, `undo_changes`, `discover_mcp_tools`, `list_agents`, `list_agent_sessions`, `get_agent_session_state`, `get_agent_session_memory`, `list_agent_checkpoints`, `get_agent_checkpoint`, `run_agent_tests`
|
||||
- 1500-line MCP server providing 13 tools: `read_file`, `write_file`, `edit_file` (with opencode-style 9-strategy fuzzy matching), `list_directory`, `search_files`, `run_command`, `undo_changes`, `discover_mcp_tools`, `list_agents`, `list_agent_sessions`, `list_agent_checkpoints`, `get_agent_checkpoint`, `run_agent_tests`
|
||||
- Path-scoped security: all file operations sandboxed to project root
|
||||
- Git-based undo: automatic snapshots before writes with `undo_changes` rollback
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
# TUI Dashboard Guide
|
||||
|
||||
## Launching the TUI
|
||||
|
||||
There are two ways to launch the TUI dashboard:
|
||||
|
||||
```bash
|
||||
# Browse and select an agent interactively
|
||||
hive tui
|
||||
|
||||
# Launch the TUI for a specific agent
|
||||
hive run exports/my_agent --tui
|
||||
```
|
||||
|
||||
`hive tui` scans both `exports/` and `examples/templates/` for available agents, then presents a selection menu.
|
||||
|
||||
## Dashboard Panels
|
||||
|
||||
The TUI dashboard is divided into four areas:
|
||||
|
||||
- **Status Bar** - Shows the current agent name, execution state, and model in use
|
||||
- **Graph Overview** - Live visualization of the agent's node graph with highlighted active node
|
||||
- **Log Pane** - Scrollable event log streaming node transitions, LLM calls, and tool outputs
|
||||
- **Chat REPL** - Input area for interacting with client-facing nodes (`ask_user()` prompts appear here)
|
||||
|
||||
## Keybindings
|
||||
|
||||
| Key | Action |
|
||||
|---------------|-----------------------|
|
||||
| `Tab` | Next panel |
|
||||
| `Shift+Tab` | Previous panel |
|
||||
| `Ctrl+S` | Save SVG screenshot |
|
||||
| `Ctrl+O` | Command palette |
|
||||
| `Q` | Quit |
|
||||
|
||||
## Panel Cycle Order
|
||||
|
||||
`Tab` cycles: **Log Pane → Graph View → Chat Input**
|
||||
|
||||
## Text Selection
|
||||
|
||||
Textual apps capture the mouse, so normal click-drag selection won't work by default. To select and copy text from any pane:
|
||||
|
||||
1. **Hold `Shift`** while clicking and dragging — this bypasses Textual's mouse capture and lets your terminal handle selection natively.
|
||||
2. Copy with your terminal's shortcut (`Cmd+C` on macOS, `Ctrl+Shift+C` on most Linux terminals).
|
||||
|
||||
## Log Pane Scrolling
|
||||
|
||||
The log pane uses `auto_scroll=False`. New output only scrolls to the bottom when you are already at the bottom of the log. If you've scrolled up to read earlier output, it stays in place.
|
||||
|
||||
## Screenshots
|
||||
|
||||
`Ctrl+S` saves an SVG screenshot to the `screenshots/` directory with a timestamped filename. Open the SVG in any browser to view it.
|
||||
|
||||
## Tips
|
||||
|
||||
- Use `--mock` mode to explore agent execution without spending API credits: `hive run exports/my_agent --tui --mock`
|
||||
- Override the default model with `--model`: `hive run exports/my_agent --model gpt-4o`
|
||||
- Screenshots are saved as SVG files to `screenshots/` and can be opened in any browser
|
||||
@@ -191,7 +191,7 @@ Both events are handled in the cross-graph filter (events from non-active graphs
|
||||
|
||||
## Known Gaps
|
||||
|
||||
**Gap 1 — Resolved.** The queen is now the full `HiveCoderAgent` graph (not a minimal hand-assembled subset). `_load_judge_and_queen` calls `HiveCoderAgent._setup(mock_mode=True)` to load hive-tools MCP, then merges those tools into the worker runtime alongside monitoring tools. When the operator connects via Ctrl+Q, they get `coder_node` with `read_file`, `write_file`, `run_command`, `restart_agent`, `get_agent_session_state`, and all other hive-tools. The `ticket_triage_node` still handles auto-triage on ticket events. `self._queen_agent` is held on the TUI instance to keep the MCP process alive.
|
||||
**Gap 1 — Resolved.** The queen is now the full `HiveCoderAgent` graph (not a minimal hand-assembled subset). `_load_judge_and_queen` calls `HiveCoderAgent._setup(mock_mode=True)` to load hive-tools MCP, then merges those tools into the worker runtime alongside monitoring tools. When the operator connects via Ctrl+Q, they get `coder_node` with `read_file`, `write_file`, `run_command`, `restart_agent`, and all other hive-tools. The `ticket_triage_node` still handles auto-triage on ticket events. `self._queen_agent` is held on the TUI instance to keep the MCP process alive.
|
||||
|
||||
**Gap 2 — LLM-hang detection latency.**
|
||||
If the worker's LLM call hangs (API never returns), no new log entries are written. The judge detects this on its next timer tick (≤2 min). Bounded latency, not zero.
|
||||
|
||||
@@ -726,94 +726,6 @@ def list_agent_sessions(
|
||||
)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def get_agent_session_state(agent_name: str, session_id: str) -> str:
|
||||
"""Load full session state (excluding memory to prevent context bloat).
|
||||
|
||||
Returns status, progress, result, metrics, and checkpoint info.
|
||||
Use get_agent_session_memory to read memory contents separately.
|
||||
|
||||
Args:
|
||||
agent_name: Agent package name (e.g. 'deep_research_agent')
|
||||
session_id: Session ID (e.g. 'session_20260208_143022_abc12345')
|
||||
|
||||
Returns:
|
||||
JSON with full session state
|
||||
"""
|
||||
agent_dir = _resolve_hive_agent_path(agent_name)
|
||||
state_path = agent_dir / "sessions" / session_id / "state.json"
|
||||
data = _read_session_json(state_path)
|
||||
if data is None:
|
||||
return json.dumps({"error": f"Session not found: {session_id}"})
|
||||
|
||||
# Exclude memory values but show keys
|
||||
memory = data.get("memory", {})
|
||||
data["memory_keys"] = list(memory.keys()) if isinstance(memory, dict) else []
|
||||
data["memory_size"] = len(memory) if isinstance(memory, dict) else 0
|
||||
data.pop("memory", None)
|
||||
|
||||
return json.dumps(data, indent=2, default=str)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def get_agent_session_memory(
|
||||
agent_name: str,
|
||||
session_id: str,
|
||||
key: str = "",
|
||||
) -> str:
|
||||
"""Read memory contents from a session.
|
||||
|
||||
Memory stores intermediate results passed between nodes. Use this
|
||||
to inspect what data was produced during execution.
|
||||
|
||||
Args:
|
||||
agent_name: Agent package name
|
||||
session_id: Session ID
|
||||
key: Specific memory key to retrieve. Empty for all keys.
|
||||
|
||||
Returns:
|
||||
JSON with memory contents
|
||||
"""
|
||||
agent_dir = _resolve_hive_agent_path(agent_name)
|
||||
state_path = agent_dir / "sessions" / session_id / "state.json"
|
||||
data = _read_session_json(state_path)
|
||||
if data is None:
|
||||
return json.dumps({"error": f"Session not found: {session_id}"})
|
||||
|
||||
memory = data.get("memory", {})
|
||||
if not isinstance(memory, dict):
|
||||
memory = {}
|
||||
|
||||
if key:
|
||||
if key not in memory:
|
||||
return json.dumps(
|
||||
{
|
||||
"error": f"Memory key not found: '{key}'",
|
||||
"available_keys": list(memory.keys()),
|
||||
}
|
||||
)
|
||||
return json.dumps(
|
||||
{
|
||||
"session_id": session_id,
|
||||
"key": key,
|
||||
"value": memory[key],
|
||||
"value_type": type(memory[key]).__name__,
|
||||
},
|
||||
indent=2,
|
||||
default=str,
|
||||
)
|
||||
|
||||
return json.dumps(
|
||||
{
|
||||
"session_id": session_id,
|
||||
"memory": memory,
|
||||
"total_keys": len(memory),
|
||||
},
|
||||
indent=2,
|
||||
default=str,
|
||||
)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def list_agent_checkpoints(
|
||||
agent_name: str,
|
||||
|
||||
Reference in New Issue
Block a user