python-agent-harness 1.5.7.4__tar.gz → 1.5.7.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_agent_harness-1.5.7.4/python_agent_harness.egg-info → python_agent_harness-1.5.7.6}/PKG-INFO +15 -13
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/README.md +14 -12
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/pyproject.toml +7 -2
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/__init__.py +1 -1
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/subagent.py +2 -2
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/token_estimator.py +1 -13
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/cli.py +34 -27
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/controller.py +13 -9
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/restore.py +7 -2
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/server.py +0 -21
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/io/persistence.py +55 -4
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/__init__.py +2 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/agent.md +0 -9
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/core.py +109 -63
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/subagent.md +1 -14
- python_agent_harness-1.5.7.6/python_agent_harness/prompts/tool-usage-policy.md +9 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/session/commands.py +38 -26
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/session/config.py +103 -111
- python_agent_harness-1.5.7.6/python_agent_harness/session/config_template.json +102 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/session/session.py +107 -63
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/commands.py +70 -12
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/core.py +18 -3
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/input.py +9 -7
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/mouse.py +0 -20
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6/python_agent_harness.egg-info}/PKG-INFO +15 -13
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/SOURCES.txt +2 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/LICENSE +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/__main__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/__init__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/agent.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/context_manager.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/models.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/planmode.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/tool_runner.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/__init__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/headless.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/view.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/io/__init__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/io/attachments.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/io/diffrender.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/io/text_filter.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/llm/__init__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/llm/client.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/mcp/__init__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/mcp/client.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/mcp/config.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/mcp/manager.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/agents/reviewer.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/build-switch.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/commands/explain.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/compact.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/initialize.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/plan-mode.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/plan.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/review.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/summary.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/task-completion-rules.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/title.md +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/session/__init__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/session/hooks.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/__init__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/agent_tool.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/base.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/bash.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/diffapply.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/edit.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/edit_mac.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/filesystem.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/glob.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/glob_mac.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/grep.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/grep_mac.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/mcp.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/planexit.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/question.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/read.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/skill.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/todo.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/write.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/__init__.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/render.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/dependency_links.txt +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/entry_points.txt +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/requires.txt +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/top_level.txt +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/setup.cfg +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/tests/test_invariants.py +0 -0
- {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/tests/test_scenarios.py +0 -0
{python_agent_harness-1.5.7.4/python_agent_harness.egg-info → python_agent_harness-1.5.7.6}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-agent-harness
|
|
3
|
-
Version: 1.5.7.
|
|
3
|
+
Version: 1.5.7.6
|
|
4
4
|
Summary: A lightweight, hackable mini-OpenCode written in Python.
|
|
5
5
|
Author-email: Huming Chen <chenhuming@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -79,8 +79,8 @@ Edit `~/.config/python-agent-harness/config.json` and set your `base_url`, `api_
|
|
|
79
79
|
- **Persistent sessions** — auto-saved after every response to `~/.local/share/python-agent-harness/sessions/`, with LLM-generated titles and `/restore --latest` / `/sessions`.
|
|
80
80
|
- **Focused TUI** — Rich-based with pinned status bar, Todos panel, inline diff rendering, and a `prompt_toolkit` editor with history and completion. `Esc+Enter` submits, `Ctrl-D` quits, `Ctrl-C` cancels.
|
|
81
81
|
- **MCP support** — optional via `[mcp]` extra. MCP tools become ordinary agent tools (`mcp__<server>__<tool>`). Supports `stdio`, `streamable-http`, and `sse` transports.
|
|
82
|
-
- **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md` (extendable via `paths.
|
|
83
|
-
- **Custom agents** — switch the main agent's system prompt at runtime with `/agent`. Agent files live in `prompts/agents/*.md` (extendable via `paths.
|
|
82
|
+
- **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md` (extendable via `paths.command_paths`).
|
|
83
|
+
- **Custom agents** — switch the main agent's system prompt at runtime with `/agent`. Agent files live in `prompts/agents/*.md` (extendable via `paths.agent_paths`) and support `name:` and `exclude_tools:` frontmatter.
|
|
84
84
|
- **Hooks** — shell commands on `tool.before` / `tool.after` / `agent.start` / `agent.end`: block risky tool calls, feed linter output back to the model, add per-turn context, notify on completion. See [Hooks](#hooks).
|
|
85
85
|
- **Embeddable runtime boundaries** — `headless --json` for one-shot CI/scripting; `serve` for hosting apps (resident process, bidirectional protocol: multi-turn memory, mid-run Q&A, protocol-level cancel).
|
|
86
86
|
|
|
@@ -126,17 +126,18 @@ A persistent, bidirectional runtime for hosting applications. Keeps the `Control
|
|
|
126
126
|
| `/save` | Save the current session |
|
|
127
127
|
| `/sessions` | List saved sessions |
|
|
128
128
|
| `/restore [path\|title\|--latest\|latest]` | Restore a session (substring search) |
|
|
129
|
-
| `/clear` |
|
|
129
|
+
| `/clear` | Wipe the conversation but keep the session file (the next save overwrites it) |
|
|
130
|
+
| `/new` | Start a new session in a new file; the current one is saved first (with auto-save on) and stays restorable |
|
|
130
131
|
| `/model [name]` | Switch LLM profiles; `default` restores original |
|
|
131
132
|
| `/agent [name]` | Switch agent prompt; `default` restores built-in |
|
|
132
133
|
| `/help` | List available commands |
|
|
133
134
|
| `/exit` | Quit |
|
|
134
135
|
|
|
135
|
-
Custom commands from `prompts/commands/*.md` and `paths.
|
|
136
|
+
Custom commands from `prompts/commands/*.md` and `paths.command_paths` are always registered (TUI only). A command file **replaces** the command of the same name — builtin or bundled (precedence: configured > bundled > builtin), except `/exit`, which cannot be shadowed. `/help` lists the overrides.
|
|
136
137
|
|
|
137
138
|
### Custom agents
|
|
138
139
|
|
|
139
|
-
Agent files are markdown (`.md`) in `prompts/agents/`. Files in `paths.
|
|
140
|
+
Agent files are markdown (`.md`) in `prompts/agents/`. Files in `paths.agent_paths` are merged on top (a same-named configured agent wins; the rest stay available). Each becomes a switchable profile via `/agent`, except `default`, which cannot be shadowed. Optional YAML frontmatter:
|
|
140
141
|
|
|
141
142
|
- `name:` — override the agent name (defaults to file stem)
|
|
142
143
|
- `exclude_tools:` — list of tool names to hide. Matches by exact name, glob (`mcp__git__*`), or `__`-delimited prefix (`mcp__git` hides `mcp__git__list_repos` but `Write` does NOT hide `TodoWrite`).
|
|
@@ -168,10 +169,10 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
|
|
|
168
169
|
"max_nudges": 1
|
|
169
170
|
},
|
|
170
171
|
"paths": {
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"
|
|
174
|
-
"
|
|
172
|
+
"context_paths": null,
|
|
173
|
+
"skill_paths": null,
|
|
174
|
+
"agent_paths": null,
|
|
175
|
+
"command_paths": null
|
|
175
176
|
},
|
|
176
177
|
"mcp": {
|
|
177
178
|
"servers": {
|
|
@@ -196,9 +197,10 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
|
|
|
196
197
|
- **`context_windows`** — per-model context-window overrides (tokens). Keys are model names or substrings; first match wins. Overrides `CONTEXT_WINDOWS` in `config.py`.
|
|
197
198
|
- **`supervision.max_nudges`** — completion-supervision budget: how many times the harness nudges the model back to work when it stops with a terminal answer. The budget is **per tool round** (it resets on every tool round), so the effective cap is `max_nudges × tool rounds`. Default `1`, which suits a model that rarely stops early; raise it for a weaker model that keeps stopping before the work is done, or set `0` to disable supervision. Each nudge costs one extra LLM round (a full history re-send), so a high value is expensive.
|
|
198
199
|
- **`subagent_llm`** — LLM config for `Agent` tool. Unset values inherit from `llm`. Set `profile` to reuse a `models` entry. Precedence: profile > `subagent_llm` > `llm` > env vars.
|
|
199
|
-
- **`default_agent`** — agent name to use at session start (must exist in the discovered agent set: bundled `prompts/agents/` plus `paths.
|
|
200
|
-
- **`paths.
|
|
201
|
-
- **`paths.
|
|
200
|
+
- **`default_agent`** — agent name to use at session start (must exist in the discovered agent set: bundled `prompts/agents/` plus `paths.agent_paths`). `null` = built-in default.
|
|
201
|
+
- **`paths.context_paths` / `paths.skill_paths`** — locations for context files and skills. Default: project-local `contexts/` and `skills/`.
|
|
202
|
+
- **`paths.agent_paths` / `paths.command_paths`** — extra directories for custom agents and slash commands, **merged** on top of the bundled `prompts/agents/` and `prompts/commands/`: a same-named configured file wins, everything else stays available. (`context_paths`/`skill_paths` instead *replace* the project-local default.)
|
|
203
|
+
- **Every `paths.*` value is a single path or a list of paths** — absolute paths and `~` supported. With a list, all directories are used and an earlier one wins over a later one for the same name.
|
|
202
204
|
- **`mcp.servers`** — MCP server config (requires `[mcp]` extra). Each supports `transport`, `command`, `args`, `env`, `url`, `headers`, `parallel`, `timeout`, `enabled`.
|
|
203
205
|
- **`headless` / `serve`** — optional budget limits: `max_rounds` (LLM rounds) and `timeout` (wall-clock seconds). `--max-rounds` / `--timeout` override per call; `<= 0` or `null` disables. Unset = unlimited.
|
|
204
206
|
- **`hooks`** — shell-command hooks; see [Hooks](#hooks).
|
|
@@ -45,8 +45,8 @@ Edit `~/.config/python-agent-harness/config.json` and set your `base_url`, `api_
|
|
|
45
45
|
- **Persistent sessions** — auto-saved after every response to `~/.local/share/python-agent-harness/sessions/`, with LLM-generated titles and `/restore --latest` / `/sessions`.
|
|
46
46
|
- **Focused TUI** — Rich-based with pinned status bar, Todos panel, inline diff rendering, and a `prompt_toolkit` editor with history and completion. `Esc+Enter` submits, `Ctrl-D` quits, `Ctrl-C` cancels.
|
|
47
47
|
- **MCP support** — optional via `[mcp]` extra. MCP tools become ordinary agent tools (`mcp__<server>__<tool>`). Supports `stdio`, `streamable-http`, and `sse` transports.
|
|
48
|
-
- **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md` (extendable via `paths.
|
|
49
|
-
- **Custom agents** — switch the main agent's system prompt at runtime with `/agent`. Agent files live in `prompts/agents/*.md` (extendable via `paths.
|
|
48
|
+
- **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md` (extendable via `paths.command_paths`).
|
|
49
|
+
- **Custom agents** — switch the main agent's system prompt at runtime with `/agent`. Agent files live in `prompts/agents/*.md` (extendable via `paths.agent_paths`) and support `name:` and `exclude_tools:` frontmatter.
|
|
50
50
|
- **Hooks** — shell commands on `tool.before` / `tool.after` / `agent.start` / `agent.end`: block risky tool calls, feed linter output back to the model, add per-turn context, notify on completion. See [Hooks](#hooks).
|
|
51
51
|
- **Embeddable runtime boundaries** — `headless --json` for one-shot CI/scripting; `serve` for hosting apps (resident process, bidirectional protocol: multi-turn memory, mid-run Q&A, protocol-level cancel).
|
|
52
52
|
|
|
@@ -92,17 +92,18 @@ A persistent, bidirectional runtime for hosting applications. Keeps the `Control
|
|
|
92
92
|
| `/save` | Save the current session |
|
|
93
93
|
| `/sessions` | List saved sessions |
|
|
94
94
|
| `/restore [path\|title\|--latest\|latest]` | Restore a session (substring search) |
|
|
95
|
-
| `/clear` |
|
|
95
|
+
| `/clear` | Wipe the conversation but keep the session file (the next save overwrites it) |
|
|
96
|
+
| `/new` | Start a new session in a new file; the current one is saved first (with auto-save on) and stays restorable |
|
|
96
97
|
| `/model [name]` | Switch LLM profiles; `default` restores original |
|
|
97
98
|
| `/agent [name]` | Switch agent prompt; `default` restores built-in |
|
|
98
99
|
| `/help` | List available commands |
|
|
99
100
|
| `/exit` | Quit |
|
|
100
101
|
|
|
101
|
-
Custom commands from `prompts/commands/*.md` and `paths.
|
|
102
|
+
Custom commands from `prompts/commands/*.md` and `paths.command_paths` are always registered (TUI only). A command file **replaces** the command of the same name — builtin or bundled (precedence: configured > bundled > builtin), except `/exit`, which cannot be shadowed. `/help` lists the overrides.
|
|
102
103
|
|
|
103
104
|
### Custom agents
|
|
104
105
|
|
|
105
|
-
Agent files are markdown (`.md`) in `prompts/agents/`. Files in `paths.
|
|
106
|
+
Agent files are markdown (`.md`) in `prompts/agents/`. Files in `paths.agent_paths` are merged on top (a same-named configured agent wins; the rest stay available). Each becomes a switchable profile via `/agent`, except `default`, which cannot be shadowed. Optional YAML frontmatter:
|
|
106
107
|
|
|
107
108
|
- `name:` — override the agent name (defaults to file stem)
|
|
108
109
|
- `exclude_tools:` — list of tool names to hide. Matches by exact name, glob (`mcp__git__*`), or `__`-delimited prefix (`mcp__git` hides `mcp__git__list_repos` but `Write` does NOT hide `TodoWrite`).
|
|
@@ -134,10 +135,10 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
|
|
|
134
135
|
"max_nudges": 1
|
|
135
136
|
},
|
|
136
137
|
"paths": {
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
138
|
+
"context_paths": null,
|
|
139
|
+
"skill_paths": null,
|
|
140
|
+
"agent_paths": null,
|
|
141
|
+
"command_paths": null
|
|
141
142
|
},
|
|
142
143
|
"mcp": {
|
|
143
144
|
"servers": {
|
|
@@ -162,9 +163,10 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
|
|
|
162
163
|
- **`context_windows`** — per-model context-window overrides (tokens). Keys are model names or substrings; first match wins. Overrides `CONTEXT_WINDOWS` in `config.py`.
|
|
163
164
|
- **`supervision.max_nudges`** — completion-supervision budget: how many times the harness nudges the model back to work when it stops with a terminal answer. The budget is **per tool round** (it resets on every tool round), so the effective cap is `max_nudges × tool rounds`. Default `1`, which suits a model that rarely stops early; raise it for a weaker model that keeps stopping before the work is done, or set `0` to disable supervision. Each nudge costs one extra LLM round (a full history re-send), so a high value is expensive.
|
|
164
165
|
- **`subagent_llm`** — LLM config for `Agent` tool. Unset values inherit from `llm`. Set `profile` to reuse a `models` entry. Precedence: profile > `subagent_llm` > `llm` > env vars.
|
|
165
|
-
- **`default_agent`** — agent name to use at session start (must exist in the discovered agent set: bundled `prompts/agents/` plus `paths.
|
|
166
|
-
- **`paths.
|
|
167
|
-
- **`paths.
|
|
166
|
+
- **`default_agent`** — agent name to use at session start (must exist in the discovered agent set: bundled `prompts/agents/` plus `paths.agent_paths`). `null` = built-in default.
|
|
167
|
+
- **`paths.context_paths` / `paths.skill_paths`** — locations for context files and skills. Default: project-local `contexts/` and `skills/`.
|
|
168
|
+
- **`paths.agent_paths` / `paths.command_paths`** — extra directories for custom agents and slash commands, **merged** on top of the bundled `prompts/agents/` and `prompts/commands/`: a same-named configured file wins, everything else stays available. (`context_paths`/`skill_paths` instead *replace* the project-local default.)
|
|
169
|
+
- **Every `paths.*` value is a single path or a list of paths** — absolute paths and `~` supported. With a list, all directories are used and an earlier one wins over a later one for the same name.
|
|
168
170
|
- **`mcp.servers`** — MCP server config (requires `[mcp]` extra). Each supports `transport`, `command`, `args`, `env`, `url`, `headers`, `parallel`, `timeout`, `enabled`.
|
|
169
171
|
- **`headless` / `serve`** — optional budget limits: `max_rounds` (LLM rounds) and `timeout` (wall-clock seconds). `--max-rounds` / `--timeout` override per call; `<= 0` or `null` disables. Unset = unlimited.
|
|
170
172
|
- **`hooks`** — shell-command hooks; see [Hooks](#hooks).
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-agent-harness"
|
|
7
|
-
version = "1.5.7.
|
|
7
|
+
version = "1.5.7.6"
|
|
8
8
|
description = "A lightweight, hackable mini-OpenCode written in Python."
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "Huming Chen", email = "chenhuming@gmail.com"}
|
|
@@ -63,7 +63,12 @@ python-agent-harness = "python_agent_harness.entry.cli:main"
|
|
|
63
63
|
include = ["python_agent_harness*"]
|
|
64
64
|
|
|
65
65
|
[tool.setuptools.package-data]
|
|
66
|
-
python_agent_harness = [
|
|
66
|
+
python_agent_harness = [
|
|
67
|
+
"prompts/*.md",
|
|
68
|
+
"prompts/commands/*.md",
|
|
69
|
+
"prompts/agents/*.md",
|
|
70
|
+
"session/config_template.json",
|
|
71
|
+
]
|
|
67
72
|
|
|
68
73
|
[tool.ruff]
|
|
69
74
|
line-length = 100
|
{python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/core/subagent.py
RENAMED
|
@@ -29,10 +29,10 @@ def _subagent_system_prompt(session: object) -> str | None:
|
|
|
29
29
|
return own
|
|
30
30
|
registry = getattr(session, "registry", None)
|
|
31
31
|
tool_instructions = registry.tool_instructions() if registry else None
|
|
32
|
-
|
|
32
|
+
skill_dirs = getattr(session, "_skill_dirs", None)
|
|
33
33
|
return load_agent_prompt(
|
|
34
34
|
config.DEFAULT_SUBAGENT_PROMPT_FILE,
|
|
35
|
-
|
|
35
|
+
skill_dirs=skill_dirs,
|
|
36
36
|
tool_instructions=tool_instructions,
|
|
37
37
|
excluded_tools=config.SUBAGENT_EXCLUDED_TOOLS,
|
|
38
38
|
)
|
|
@@ -14,19 +14,7 @@ import re
|
|
|
14
14
|
from ..session import config
|
|
15
15
|
from .models import extract_reasoning
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
def is_cjk_char(c: str) -> bool:
|
|
19
|
-
"""Return True if C is a CJK or full-width character."""
|
|
20
|
-
cp = ord(c)
|
|
21
|
-
return (
|
|
22
|
-
0x3000 <= cp <= 0x9FFF # CJK + kana + punctuation
|
|
23
|
-
or 0xF900 <= cp <= 0xFAFF # CJK compat ideographs
|
|
24
|
-
or 0xFF00 <= cp <= 0xFFEF # full-width forms
|
|
25
|
-
or 0x20000 <= cp <= 0x2FA1F # CJK extensions B-F
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
# The same ranges as `is_cjk_char`, as a single compiled character class.
|
|
17
|
+
# The CJK/full-width ranges, as a single compiled character class.
|
|
30
18
|
# Scanning for CJK runs in C (the regex engine) instead of a per-character
|
|
31
19
|
# Python loop, so large payloads count CJK chars much faster.
|
|
32
20
|
_CJK_RE = re.compile(r"[\u3000-\u9fff\uf900-\ufaff\uff00-\uffef\U00020000-\U0002fa1f]")
|
{python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/cli.py
RENAMED
|
@@ -8,7 +8,7 @@ Commands:
|
|
|
8
8
|
runs repeatedly, answer mid-run questions, cancel
|
|
9
9
|
config [--init] show effective LLM config / write a template file
|
|
10
10
|
|
|
11
|
-
Custom commands (prompts/commands/*.md, or paths.
|
|
11
|
+
Custom commands (prompts/commands/*.md, or paths.command_paths) — like init, review,
|
|
12
12
|
sessions, restore and summary/explain — are TUI slash commands only;
|
|
13
13
|
they are NOT registered as CLI subcommands.
|
|
14
14
|
|
|
@@ -89,27 +89,27 @@ def make_session(
|
|
|
89
89
|
# path, and a separate sub-agent log would fragment debugging
|
|
90
90
|
subagent_client.log_path = client.log_path
|
|
91
91
|
from ..prompts import assemble_agent_prompt, load_agent_prompt
|
|
92
|
-
from ..session.session import
|
|
92
|
+
from ..session.session import find_skill_dirs
|
|
93
93
|
|
|
94
94
|
abs_project = os.path.abspath(os.path.expanduser(project_dir))
|
|
95
|
-
|
|
95
|
+
skill_dirs = find_skill_dirs(abs_project, paths.get("skill_paths"))
|
|
96
96
|
registry = default_registry()
|
|
97
97
|
tool_instructions = registry.tool_instructions()
|
|
98
98
|
system_prompt = assemble_agent_prompt(
|
|
99
99
|
abs_project,
|
|
100
100
|
load_agent_prompt(
|
|
101
101
|
config.DEFAULT_AGENT_PROMPT_FILE,
|
|
102
|
-
|
|
102
|
+
skill_dirs=skill_dirs,
|
|
103
103
|
tool_instructions=tool_instructions,
|
|
104
104
|
),
|
|
105
|
-
|
|
105
|
+
context_paths=paths.get("context_paths"),
|
|
106
106
|
)
|
|
107
107
|
# sub-agents get ONLY their own system prompt — no parent project
|
|
108
108
|
# context and no task-completion rules injected. Tool instructions
|
|
109
109
|
# are filtered to exclude tools sub-agents cannot use.
|
|
110
110
|
subagent_system_prompt = load_agent_prompt(
|
|
111
111
|
config.DEFAULT_SUBAGENT_PROMPT_FILE,
|
|
112
|
-
|
|
112
|
+
skill_dirs=skill_dirs,
|
|
113
113
|
tool_instructions=tool_instructions,
|
|
114
114
|
excluded_tools=config.SUBAGENT_EXCLUDED_TOOLS,
|
|
115
115
|
)
|
|
@@ -145,10 +145,10 @@ def make_session(
|
|
|
145
145
|
),
|
|
146
146
|
subagent_supports_image_input=subagent_overrides.get("supports_image_input"),
|
|
147
147
|
registry=registry,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
context_paths=paths.get("context_paths"),
|
|
149
|
+
skill_paths=paths.get("skill_paths"),
|
|
150
|
+
agent_paths=paths.get("agent_paths"),
|
|
151
|
+
command_paths=paths.get("command_paths"),
|
|
152
152
|
mcp=mcp_config,
|
|
153
153
|
model_profiles=model_profiles,
|
|
154
154
|
default_agent=default_agent,
|
|
@@ -156,6 +156,7 @@ def make_session(
|
|
|
156
156
|
config_path=config_path,
|
|
157
157
|
)
|
|
158
158
|
session.install_hooks(hook_specs)
|
|
159
|
+
session.startup_warnings.extend(config.legacy_paths_warnings(config_path))
|
|
159
160
|
if default_agent and default_agent != RESERVED_AGENT_NAME:
|
|
160
161
|
ok, msg = session.switch_agent(default_agent)
|
|
161
162
|
if not ok:
|
|
@@ -278,13 +279,13 @@ def cmd_serve(args: argparse.Namespace) -> int:
|
|
|
278
279
|
|
|
279
280
|
|
|
280
281
|
def cmd_config(args: argparse.Namespace) -> int:
|
|
281
|
-
path = config._config_path(args.path)
|
|
282
|
+
path = config._config_path(args.path or getattr(args, "config", None))
|
|
282
283
|
if args.init:
|
|
283
284
|
# 0o700 dir / 0o600 file: the config holds the API key, so it must
|
|
284
285
|
# not be group/world-readable (mode applies to a NEW leaf dir only;
|
|
285
286
|
# an existing directory keeps its permissions).
|
|
286
287
|
path.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
287
|
-
template = config.
|
|
288
|
+
template = config.render_config_template(path)
|
|
288
289
|
try:
|
|
289
290
|
# O_EXCL: create-only, atomically -- no exists()/write race, and
|
|
290
291
|
# a pre-planted symlink at PATH is refused instead of followed.
|
|
@@ -296,10 +297,10 @@ def cmd_config(args: argparse.Namespace) -> int:
|
|
|
296
297
|
f.write(template)
|
|
297
298
|
print(f"wrote config template: {path}")
|
|
298
299
|
return 0
|
|
299
|
-
settings = config.load_llm_config(
|
|
300
|
-
subagent_settings = config.load_subagent_llm_config(
|
|
301
|
-
paths = config.load_paths_config(
|
|
302
|
-
mcp_config = config.load_mcp_config(
|
|
300
|
+
settings = config.load_llm_config(path)
|
|
301
|
+
subagent_settings = config.load_subagent_llm_config(path, main=settings)
|
|
302
|
+
paths = config.load_paths_config(path)
|
|
303
|
+
mcp_config = config.load_mcp_config(path)
|
|
303
304
|
print(f"config file: {path}")
|
|
304
305
|
if not path.exists():
|
|
305
306
|
print("(file does not exist yet — run `python-agent-harness config --init` to create it)")
|
|
@@ -311,10 +312,16 @@ def cmd_config(args: argparse.Namespace) -> int:
|
|
|
311
312
|
print(f"reasoning_effort: {settings['reasoning_effort']}")
|
|
312
313
|
print(f"stream: {settings['stream']}")
|
|
313
314
|
print(f"timeout: {settings['timeout']}")
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
for key, unset in (
|
|
316
|
+
("context_paths", "(default: <project>/contexts)"),
|
|
317
|
+
("skill_paths", "(default: <project>/skills)"),
|
|
318
|
+
("agent_paths", "(unset: bundled prompts/agents only)"),
|
|
319
|
+
("command_paths", "(unset: bundled prompts/commands only)"),
|
|
320
|
+
):
|
|
321
|
+
dirs = paths[key]
|
|
322
|
+
print(f"{key}: {', '.join(dirs) if dirs else unset}")
|
|
323
|
+
for warning in config.legacy_paths_warnings(path):
|
|
324
|
+
print(f"warning: {warning}")
|
|
318
325
|
if mcp_config.servers:
|
|
319
326
|
for name, server in mcp_config.servers.items():
|
|
320
327
|
status = "enabled" if server.enabled else "disabled"
|
|
@@ -330,7 +337,7 @@ def cmd_config(args: argparse.Namespace) -> int:
|
|
|
330
337
|
else:
|
|
331
338
|
print('mcp: (none configured — add an "mcp" section to the config file)')
|
|
332
339
|
try:
|
|
333
|
-
hooks = config.load_hooks(
|
|
340
|
+
hooks = config.load_hooks(path)
|
|
334
341
|
except ValueError as e:
|
|
335
342
|
print(f"hooks: INVALID — {e}")
|
|
336
343
|
else:
|
|
@@ -353,7 +360,7 @@ def cmd_config(args: argparse.Namespace) -> int:
|
|
|
353
360
|
f"reasoning_effort={subagent_settings['reasoning_effort']} "
|
|
354
361
|
f"stream={subagent_settings['stream']} timeout={subagent_settings['timeout']}"
|
|
355
362
|
)
|
|
356
|
-
model_profiles = config.load_models_config(
|
|
363
|
+
model_profiles = config.load_models_config(path)
|
|
357
364
|
if model_profiles:
|
|
358
365
|
print("models:")
|
|
359
366
|
for name, profile in sorted(model_profiles.items()):
|
|
@@ -362,17 +369,17 @@ def cmd_config(args: argparse.Namespace) -> int:
|
|
|
362
369
|
print(f" {name}: model={model_name}, base_url={base_url}")
|
|
363
370
|
else:
|
|
364
371
|
print("models: (none configured — add a 'models' section to use /model)")
|
|
365
|
-
context_windows = config.load_context_windows_config(
|
|
372
|
+
context_windows = config.load_context_windows_config(path)
|
|
366
373
|
if context_windows:
|
|
367
374
|
print("context_windows:")
|
|
368
375
|
for pattern, size in context_windows:
|
|
369
376
|
print(f" {pattern}: {size}")
|
|
370
377
|
else:
|
|
371
378
|
print("context_windows: (none configured — built-in table in config.py applies)")
|
|
372
|
-
default_agent = config.load_default_agent(
|
|
379
|
+
default_agent = config.load_default_agent(path)
|
|
373
380
|
print(f"default_agent: {default_agent or '(default: agent.md)'}")
|
|
374
|
-
print(f"supervision.max_nudges: {config.load_max_nudges(
|
|
375
|
-
max_rounds, timeout = config.load_headless_limits(
|
|
381
|
+
print(f"supervision.max_nudges: {config.load_max_nudges(path)}")
|
|
382
|
+
max_rounds, timeout = config.load_headless_limits(path)
|
|
376
383
|
if max_rounds is None and timeout is None:
|
|
377
384
|
print(
|
|
378
385
|
"headless: (unlimited — set headless.max_rounds/timeout or use --max-rounds/--timeout)"
|
|
@@ -381,7 +388,7 @@ def cmd_config(args: argparse.Namespace) -> int:
|
|
|
381
388
|
print(
|
|
382
389
|
f"headless: max_rounds={max_rounds or '(unlimited)'}, timeout={timeout or '(unlimited)'}s"
|
|
383
390
|
)
|
|
384
|
-
serve_rounds, serve_timeout = config.load_serve_limits(
|
|
391
|
+
serve_rounds, serve_timeout = config.load_serve_limits(path)
|
|
385
392
|
if serve_rounds is None and serve_timeout is None:
|
|
386
393
|
print("serve: (unlimited — set serve.max_rounds/timeout or use --max-rounds/--timeout)")
|
|
387
394
|
else:
|
|
@@ -208,16 +208,16 @@ class Controller:
|
|
|
208
208
|
return self.session.config_path
|
|
209
209
|
|
|
210
210
|
@property
|
|
211
|
-
def
|
|
212
|
-
return self.session.
|
|
211
|
+
def configured_context_paths(self) -> config.PathsArg:
|
|
212
|
+
return self.session._configured_context_paths
|
|
213
213
|
|
|
214
214
|
@property
|
|
215
|
-
def
|
|
216
|
-
return self.session.
|
|
215
|
+
def configured_agent_paths(self) -> config.PathsArg:
|
|
216
|
+
return self.session._configured_agent_paths
|
|
217
217
|
|
|
218
218
|
@property
|
|
219
|
-
def
|
|
220
|
-
return self.session.
|
|
219
|
+
def configured_command_paths(self) -> config.PathsArg:
|
|
220
|
+
return self.session._configured_command_paths
|
|
221
221
|
|
|
222
222
|
@property
|
|
223
223
|
def startup_warnings(self) -> list[str]:
|
|
@@ -271,10 +271,14 @@ class Controller:
|
|
|
271
271
|
|
|
272
272
|
def clear_conversation(self) -> None:
|
|
273
273
|
"""Reset the conversation to empty (a new run generation)."""
|
|
274
|
-
self.session.
|
|
275
|
-
self.session.last_messages = []
|
|
274
|
+
self.session.clear_conversation()
|
|
276
275
|
self.conversation_history = []
|
|
277
|
-
|
|
276
|
+
|
|
277
|
+
def new_session(self) -> str | None:
|
|
278
|
+
"""Save the current session and start a fresh one; return the saved path."""
|
|
279
|
+
saved = self.session.reset_conversation()
|
|
280
|
+
self.conversation_history = []
|
|
281
|
+
return saved
|
|
278
282
|
|
|
279
283
|
# ------------------------------------------------------------------
|
|
280
284
|
# run lifecycle
|
{python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/restore.py
RENAMED
|
@@ -138,8 +138,15 @@ def apply_saved_session(controller: Controller, saved: SavedSession, report: Rep
|
|
|
138
138
|
``last_messages`` (what the views render). ``run_generation`` is
|
|
139
139
|
bumped so a worker still winding down from a cancelled run cannot
|
|
140
140
|
clobber the restored history with its salvaged one.
|
|
141
|
+
|
|
142
|
+
The replaced session's state (queued prompts, plan mode, todos,
|
|
143
|
+
context ratio, save state) is cleared first, as /clear does, which
|
|
144
|
+
also bumps ``run_generation``; the store reset drops a title request
|
|
145
|
+
still in flight for it.
|
|
141
146
|
"""
|
|
147
|
+
controller.clear_conversation()
|
|
142
148
|
store = controller.store
|
|
149
|
+
store.reset()
|
|
143
150
|
store.round_times = saved.round_times
|
|
144
151
|
store.file_path = saved.path
|
|
145
152
|
title = persistence.title_from_filename(saved.path)
|
|
@@ -147,7 +154,5 @@ def apply_saved_session(controller: Controller, saved: SavedSession, report: Rep
|
|
|
147
154
|
store.title = title
|
|
148
155
|
restore_agent(controller, saved.meta.get(AGENT_KEY), report)
|
|
149
156
|
restore_model(controller, saved.meta.get(MODEL_KEY), report)
|
|
150
|
-
controller.run_generation += 1
|
|
151
157
|
controller.conversation_history = list(saved.messages)
|
|
152
158
|
controller.last_messages = list(saved.messages)
|
|
153
|
-
controller.clear_todos()
|
{python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/server.py
RENAMED
|
@@ -409,18 +409,6 @@ class ServerView(JsonlView):
|
|
|
409
409
|
if state is not None:
|
|
410
410
|
state.event.set()
|
|
411
411
|
|
|
412
|
-
def reset_for_run(self, run_id: str | None) -> None:
|
|
413
|
-
"""Re-arm the view for a new run: fresh seq counter, new run_id."""
|
|
414
|
-
with self._lock:
|
|
415
|
-
self._buffer = []
|
|
416
|
-
self._seq = 0
|
|
417
|
-
self._sealed = False
|
|
418
|
-
self._cancelled.clear()
|
|
419
|
-
self.run_id = run_id
|
|
420
|
-
self._deltas.reset()
|
|
421
|
-
with self._pending_lock:
|
|
422
|
-
self._abandoned = False
|
|
423
|
-
|
|
424
412
|
# -- HeadlessView overrides -------------------------------------------------
|
|
425
413
|
|
|
426
414
|
def confirm(self, prompt: str) -> bool:
|
|
@@ -450,15 +438,6 @@ class ServerView(JsonlView):
|
|
|
450
438
|
)
|
|
451
439
|
return self._wait_answer(state)
|
|
452
440
|
|
|
453
|
-
# -- test seam ------------------------------------------------------------
|
|
454
|
-
|
|
455
|
-
def take_pending(self) -> _AskState | None:
|
|
456
|
-
"""Detach the pending ask state (test inspection hook)."""
|
|
457
|
-
with self._pending_lock:
|
|
458
|
-
state = self._pending
|
|
459
|
-
self._pending = None
|
|
460
|
-
return state
|
|
461
|
-
|
|
462
441
|
|
|
463
442
|
class AgentServer:
|
|
464
443
|
"""Request loop over stdin/stdout driving a resident Controller.
|
{python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/io/persistence.py
RENAMED
|
@@ -125,6 +125,7 @@ class SessionPersistence:
|
|
|
125
125
|
self.file_path: str | None = None
|
|
126
126
|
self.title_pending = False
|
|
127
127
|
self._first_user_msg: str | None = None
|
|
128
|
+
self._generation = 0
|
|
128
129
|
# wall-clock start times of each round, persisted in the
|
|
129
130
|
# metadata block so restored sessions keep their round
|
|
130
131
|
# timestamps (populated by the TUI on each run)
|
|
@@ -160,6 +161,53 @@ class SessionPersistence:
|
|
|
160
161
|
self.file_path = self._unique_path(f"{proj_name}_{stamp}")
|
|
161
162
|
return self.file_path
|
|
162
163
|
|
|
164
|
+
def reset(self) -> None:
|
|
165
|
+
"""Forget the current session file so the next save starts a new one.
|
|
166
|
+
|
|
167
|
+
The file on disk stays restorable; the generation bump drops any
|
|
168
|
+
title request still in flight for the closed session.
|
|
169
|
+
"""
|
|
170
|
+
with self._io_lock:
|
|
171
|
+
self._generation += 1
|
|
172
|
+
self.file_path = None
|
|
173
|
+
self.title = None
|
|
174
|
+
self.title_pending = False
|
|
175
|
+
self._first_user_msg = None
|
|
176
|
+
self.round_times = []
|
|
177
|
+
|
|
178
|
+
def clear_conversation_state(self) -> None:
|
|
179
|
+
"""Drop per-conversation state but keep the file and title (/clear).
|
|
180
|
+
|
|
181
|
+
The generation bump stops an in-flight title request from
|
|
182
|
+
renaming the file after the cleared conversation.
|
|
183
|
+
"""
|
|
184
|
+
with self._io_lock:
|
|
185
|
+
self._generation += 1
|
|
186
|
+
self._first_user_msg = None
|
|
187
|
+
self.round_times = []
|
|
188
|
+
|
|
189
|
+
def generation(self) -> int:
|
|
190
|
+
return self._generation
|
|
191
|
+
|
|
192
|
+
def begin_title_request(self) -> tuple[int, str] | None:
|
|
193
|
+
"""Claim the one-shot title request: (generation, first message), or None.
|
|
194
|
+
|
|
195
|
+
Atomic with ``reset``: a reset landing between reading the
|
|
196
|
+
generation and setting ``title_pending`` would otherwise leave the
|
|
197
|
+
new session's flag stuck True (never titled).
|
|
198
|
+
"""
|
|
199
|
+
with self._io_lock:
|
|
200
|
+
if self.title or self.title_pending or not self._first_user_msg:
|
|
201
|
+
return None
|
|
202
|
+
self.title_pending = True
|
|
203
|
+
return self._generation, self._first_user_msg
|
|
204
|
+
|
|
205
|
+
def clear_title_pending(self, generation: int) -> None:
|
|
206
|
+
"""Clear ``title_pending`` only if GENERATION is still current."""
|
|
207
|
+
with self._io_lock:
|
|
208
|
+
if generation == self._generation:
|
|
209
|
+
self.title_pending = False
|
|
210
|
+
|
|
163
211
|
def remember_first_user_message(self, text: str) -> None:
|
|
164
212
|
if self._first_user_msg is None and len(text.strip()) > 3:
|
|
165
213
|
self._first_user_msg = text.strip()[:500]
|
|
@@ -216,11 +264,14 @@ class SessionPersistence:
|
|
|
216
264
|
os.replace(tmp, path)
|
|
217
265
|
return path
|
|
218
266
|
|
|
219
|
-
def apply_title(self, title: str) -> None:
|
|
220
|
-
"""Rename the session file to <title>_<TS>.md (never overwriting).
|
|
221
|
-
|
|
222
|
-
|
|
267
|
+
def apply_title(self, title: str, generation: int | None = None) -> None:
|
|
268
|
+
"""Rename the session file to <title>_<TS>.md (never overwriting).
|
|
269
|
+
|
|
270
|
+
A GENERATION that is no longer current (session reset) drops the title.
|
|
271
|
+
"""
|
|
223
272
|
with self._io_lock:
|
|
273
|
+
if generation is not None and generation != self._generation:
|
|
274
|
+
return
|
|
224
275
|
title = sanitize_title(title)
|
|
225
276
|
if not title:
|
|
226
277
|
return
|
|
@@ -9,6 +9,7 @@ from .core import ( # noqa: F401
|
|
|
9
9
|
_SKILLS_FALLBACK,
|
|
10
10
|
_SKILLS_PLACEHOLDER_RE,
|
|
11
11
|
_TOOL_INSTRUCTIONS_PLACEHOLDER_RE,
|
|
12
|
+
_TOOL_USAGE_POLICY_FILE,
|
|
12
13
|
AGENTS_DIR,
|
|
13
14
|
PROMPTS_DIR,
|
|
14
15
|
RESERVED_AGENT_NAME,
|
|
@@ -32,6 +33,7 @@ from .core import ( # noqa: F401
|
|
|
32
33
|
discover_skills,
|
|
33
34
|
find_agents_md_files,
|
|
34
35
|
index_skills,
|
|
36
|
+
inject_tool_guidance,
|
|
35
37
|
load_agent_prompt,
|
|
36
38
|
load_context_files,
|
|
37
39
|
load_task_completion_rules,
|
{python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/agent.md
RENAMED
|
@@ -62,15 +62,6 @@ The user will primarily request you perform software engineering tasks. This inc
|
|
|
62
62
|
- NEVER commit changes unless the user explicitly asks you to.
|
|
63
63
|
- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.
|
|
64
64
|
|
|
65
|
-
# Tool usage policy
|
|
66
|
-
- For file searches, prefer the Agent tool to reduce context usage.
|
|
67
|
-
- For independent tasks, prefer running multiple Agent tools in parallel.
|
|
68
|
-
- For multiple bash commands, issue all tool calls in one message so they run in parallel.
|
|
69
|
-
- Batch independent tool calls in a single response to maximize parallelism.
|
|
70
|
-
|
|
71
|
-
# Tool usage instructions
|
|
72
|
-
{{TOOL_INSTRUCTIONS}}
|
|
73
|
-
|
|
74
65
|
# Code References
|
|
75
66
|
When referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.
|
|
76
67
|
|