Skip to content

Agent Zero AI framework

Strip trailing newlines in read_prompt and parse_prompt

linkliti823b4564aab3
diff --git a/agent.py b/agent.py
index 04dcda128..fa5308c88 100644
--- a/agent.py
+++ b/agent.py
@@ -696,6 +696,8 @@ class Agent:
prompt = files.parse_file(
_prompt_file, _directories=dirs, _agent=self, **kwargs
)
+ if isinstance(prompt, str):
+ prompt = prompt.rstrip("\n")
return prompt
@extension.extensible
@@ -705,6 +707,8 @@ class Agent:
prompt = files.read_prompt_file(file, _directories=dirs, _agent=self, **kwargs)
if files.is_full_json_template(prompt):
prompt = files.remove_code_fences(prompt)
+ if isinstance(prompt, str):
+ prompt = prompt.rstrip("\n")
return prompt
def get_data(self, field: str):
diff --git a/prompts/AGENTS.md b/prompts/AGENTS.md
index ee9503940..8f74aab5d 100644
--- a/prompts/AGENTS.md
+++ b/prompts/AGENTS.md
@@ -25,6 +25,7 @@
`helpers/mcp_handler.py` supplies policy-filtered names, descriptions, and
schemas.
- Summary prompts that compress history should preserve loaded skill names from `skill_instructions` metadata without copying full skill bodies.
+- `Agent.read_prompt` and `Agent.parse_prompt` strip trailing newlines from returned content, so prompt template files may safely keep a final newline. Do not rely on trailing newlines for formatting; render-time joins in `output_text()` already separate turns.
## Work Guidance