python-agent-harness 1.5.7.4__tar.gz → 1.5.7.5__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.
Files changed (87) hide show
  1. {python_agent_harness-1.5.7.4/python_agent_harness.egg-info → python_agent_harness-1.5.7.5}/PKG-INFO +1 -1
  2. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/pyproject.toml +1 -1
  3. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/__init__.py +1 -1
  4. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/__init__.py +1 -0
  5. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/agent.md +0 -9
  6. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/core.py +26 -14
  7. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/subagent.md +1 -14
  8. python_agent_harness-1.5.7.5/python_agent_harness/prompts/tool-usage-policy.md +9 -0
  9. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5/python_agent_harness.egg-info}/PKG-INFO +1 -1
  10. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness.egg-info/SOURCES.txt +1 -0
  11. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/LICENSE +0 -0
  12. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/README.md +0 -0
  13. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/__main__.py +0 -0
  14. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/core/__init__.py +0 -0
  15. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/core/agent.py +0 -0
  16. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/core/context_manager.py +0 -0
  17. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/core/models.py +0 -0
  18. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/core/planmode.py +0 -0
  19. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/core/subagent.py +0 -0
  20. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/core/token_estimator.py +0 -0
  21. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/core/tool_runner.py +0 -0
  22. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/entry/__init__.py +0 -0
  23. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/entry/cli.py +0 -0
  24. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/entry/controller.py +0 -0
  25. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/entry/headless.py +0 -0
  26. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/entry/restore.py +0 -0
  27. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/entry/server.py +0 -0
  28. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/entry/view.py +0 -0
  29. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/io/__init__.py +0 -0
  30. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/io/attachments.py +0 -0
  31. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/io/diffrender.py +0 -0
  32. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/io/persistence.py +0 -0
  33. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/io/text_filter.py +0 -0
  34. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/llm/__init__.py +0 -0
  35. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/llm/client.py +0 -0
  36. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/mcp/__init__.py +0 -0
  37. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/mcp/client.py +0 -0
  38. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/mcp/config.py +0 -0
  39. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/mcp/manager.py +0 -0
  40. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/agents/reviewer.md +0 -0
  41. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/build-switch.md +0 -0
  42. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/commands/explain.md +0 -0
  43. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/compact.md +0 -0
  44. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/initialize.md +0 -0
  45. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/plan-mode.md +0 -0
  46. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/plan.md +0 -0
  47. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/review.md +0 -0
  48. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/summary.md +0 -0
  49. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/task-completion-rules.md +0 -0
  50. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/prompts/title.md +0 -0
  51. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/session/__init__.py +0 -0
  52. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/session/commands.py +0 -0
  53. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/session/config.py +0 -0
  54. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/session/hooks.py +0 -0
  55. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/session/session.py +0 -0
  56. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/__init__.py +0 -0
  57. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/agent_tool.py +0 -0
  58. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/base.py +0 -0
  59. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/bash.py +0 -0
  60. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/diffapply.py +0 -0
  61. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/edit.py +0 -0
  62. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/edit_mac.py +0 -0
  63. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/filesystem.py +0 -0
  64. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/glob.py +0 -0
  65. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/glob_mac.py +0 -0
  66. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/grep.py +0 -0
  67. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/grep_mac.py +0 -0
  68. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/mcp.py +0 -0
  69. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/planexit.py +0 -0
  70. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/question.py +0 -0
  71. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/read.py +0 -0
  72. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/skill.py +0 -0
  73. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/todo.py +0 -0
  74. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tools/write.py +0 -0
  75. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tui/__init__.py +0 -0
  76. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tui/commands.py +0 -0
  77. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tui/core.py +0 -0
  78. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tui/input.py +0 -0
  79. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tui/mouse.py +0 -0
  80. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness/tui/render.py +0 -0
  81. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness.egg-info/dependency_links.txt +0 -0
  82. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness.egg-info/entry_points.txt +0 -0
  83. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness.egg-info/requires.txt +0 -0
  84. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/python_agent_harness.egg-info/top_level.txt +0 -0
  85. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/setup.cfg +0 -0
  86. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/tests/test_invariants.py +0 -0
  87. {python_agent_harness-1.5.7.4 → python_agent_harness-1.5.7.5}/tests/test_scenarios.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-agent-harness
3
- Version: 1.5.7.4
3
+ Version: 1.5.7.5
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
@@ -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.4"
7
+ version = "1.5.7.5"
8
8
  description = "A lightweight, hackable mini-OpenCode written in Python."
9
9
  authors = [
10
10
  {name = "Huming Chen", email = "chenhuming@gmail.com"}
@@ -7,7 +7,7 @@ from .mcp.config import MCPConfig, MCPServerConfig
7
7
  from .mcp.manager import MCPManager
8
8
  from .session.session import Session
9
9
 
10
- __version__ = "1.5.7.4"
10
+ __version__ = "1.5.7.5"
11
11
 
12
12
  __all__ = [
13
13
  "Client",
@@ -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,
@@ -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
 
@@ -46,6 +46,7 @@ def read_prompt_file(name: str) -> str:
46
46
  _FRONTMATTER_RE = re.compile(r"\A---\r?\n.*?\r?\n---\r?\n?", re.DOTALL)
47
47
  _SKILLS_PLACEHOLDER_RE = re.compile(r"\{\{\s*SKILLS\s*\}\}")
48
48
  _TOOL_INSTRUCTIONS_PLACEHOLDER_RE = re.compile(r"\{\{\s*TOOL_INSTRUCTIONS\s*\}\}")
49
+ _TOOL_USAGE_POLICY_FILE = PROMPTS_DIR / "tool-usage-policy.md"
49
50
  _SKILLS_FALLBACK = (
50
51
  "Invoke with a skill name and optional args; the tool reports an "
51
52
  "error if no matching skill is found."
@@ -197,17 +198,20 @@ def load_agent_prompt(
197
198
  """Load an opencode-style agent prompt file, or None if unavailable.
198
199
 
199
200
  Strips the YAML frontmatter header (name/description/tools) since
200
- that metadata isn't part of the prompt text, substitutes the
201
- ``{{TOOL_INSTRUCTIONS}}`` placeholder with per-tool instruction
202
- blocks assembled from *tool_instructions* (filtered by
203
- *excluded_tools*), and substitutes the ``{{SKILLS}}`` placeholder
204
- with the discovered skill listing from *skill_dir* (or a static
205
- fallback if no skills are found).
206
-
207
- The ``{{TOOL_INSTRUCTIONS}}`` substitution happens before
208
- ``{{SKILLS}}``: a tool's instructions may itself contain
209
- ``{{SKILLS}}`` (the Skill tool does), so the skills placeholder is
210
- resolved last to catch it wherever it appears.
201
+ that metadata isn't part of the prompt text.
202
+
203
+ Tool guidance is injected uniformly so switching profiles never
204
+ silently drops it: the shared fragment (``tool-usage-policy.md``) is
205
+ always appended, carrying the ``{{TOOL_INSTRUCTIONS}}`` placeholder,
206
+ which is then substituted with per-tool instruction blocks (assembled
207
+ from *tool_instructions*, filtered by *excluded_tools*). The
208
+ ``{{SKILLS}}`` placeholder is substituted with the discovered skill
209
+ listing from *skill_dir* (or a static fallback if no skills are found).
210
+
211
+ ``{{TOOL_INSTRUCTIONS}}`` is resolved before ``{{SKILLS}}``: a tool's
212
+ instructions may itself contain ``{{SKILLS}}`` (the Skill tool does),
213
+ so the skills placeholder is resolved last to catch it wherever it
214
+ appears.
211
215
 
212
216
  Missing files, unreadable files, and empty files all resolve to None
213
217
  so callers can fall back cleanly to no system prompt.
@@ -220,6 +224,14 @@ def load_agent_prompt(
220
224
  except OSError:
221
225
  return None
222
226
  text = strip_frontmatter(text)
227
+ if not text.strip():
228
+ return None
229
+ try:
230
+ fragment = _TOOL_USAGE_POLICY_FILE.read_text(encoding="utf-8").strip()
231
+ except OSError:
232
+ fragment = ""
233
+ if fragment:
234
+ text = text.rstrip() + "\n\n" + fragment
223
235
  tool_blocks = assemble_tool_instructions(tool_instructions, excluded_tools)
224
236
  # Use a lambda replacement to avoid re.sub interpreting backslashes
225
237
  # in tool instruction text (e.g. regex examples like \s, \w) as
@@ -406,9 +418,9 @@ def assemble_agent_prompt(
406
418
  ``subagent._subagent_system_prompt``). ``context_path`` overrides
407
419
  the default context directory discovery.
408
420
 
409
- *agent_prompt* is already fully resolved (``{{TOOL_INSTRUCTIONS}}``
410
- and ``{{SKILLS}}`` substituted by ``load_agent_prompt``); this
411
- function only layers context and rules around it.
421
+ *agent_prompt* is already fully resolved (tool guidance injected and
422
+ ``{{SKILLS}}`` substituted by ``load_agent_prompt``); this function
423
+ only layers context and rules around it.
412
424
  Returns None if every part is empty/missing.
413
425
  """
414
426
  parts: list[str] = []
@@ -13,20 +13,7 @@ You are an autonomous subagent. Your role is to independently complete well-defi
13
13
  - Think about the larger problem - does the task need to be done this way at all?
14
14
  - Investigate thoroughly to find truth before confirming beliefs
15
15
  - If you lack information needed to proceed, make reasonable assumptions based on context
16
-
17
- # Tool usage policy
18
- - You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.
19
-
20
- You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.
21
-
22
- # Tool usage instructions
23
-
24
- **Parallel Tool Execution:**
25
- - Call multiple tools in a single response when tasks are independent
26
- - Never use placeholders or guess missing parameters
27
- - Maximize parallel execution to improve efficiency
28
-
29
- {{TOOL_INSTRUCTIONS}}
16
+ - You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail
30
17
 
31
18
  # Output Requirements
32
19
  - Return a single, comprehensive final response with all results
@@ -0,0 +1,9 @@
1
+ # Tool usage policy
2
+ - For file searches, prefer the Agent tool to reduce context usage.
3
+ - For independent tasks, prefer running multiple Agent tools in parallel.
4
+ - For multiple bash commands, issue all tool calls in one message so they run in parallel.
5
+ - Batch independent tool calls in a single response to maximize parallelism.
6
+
7
+ # Tool usage instructions
8
+ {{TOOL_INSTRUCTIONS}}
9
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-agent-harness
3
- Version: 1.5.7.4
3
+ Version: 1.5.7.5
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
@@ -48,6 +48,7 @@ python_agent_harness/prompts/subagent.md
48
48
  python_agent_harness/prompts/summary.md
49
49
  python_agent_harness/prompts/task-completion-rules.md
50
50
  python_agent_harness/prompts/title.md
51
+ python_agent_harness/prompts/tool-usage-policy.md
51
52
  python_agent_harness/prompts/agents/reviewer.md
52
53
  python_agent_harness/prompts/commands/explain.md
53
54
  python_agent_harness/session/__init__.py