Append System Prompt

Steer any agent with a one-off system-prompt suffix — no file or YAML edits

--append-system-prompt appends an arbitrary text suffix to the assembled system prompt for a single invocation — never persisted, and applied at the very end so the cacheable prompt prefix stays intact.

Diagram

Append System Prompt

literal

@file

env fallback

🚩 –append-system-prompt
/ env var

🔎 Resolve

📝 Text

📄 File contents

🌐 PRAISONAI_APPEND_SYSTEM_PROMPT

➕ Base prompt + tail
cache-safe

🤖 Agent

Quick Start

  1. Append literal text
    bash
    praisonai code --append-system-prompt "Always answer in French"
  2. Read the suffix from a file
    bash
    praisonai run "Refactor this module" --append-system-prompt @policy.md
  3. Set the env var (CI-friendly)
    bash
    export PRAISONAI_APPEND_SYSTEM_PROMPT="Be brief. No preamble."
    praisonai chat

How It Works

The CLI resolves the flag value, exports it as PRAISONAI_APPEND_SYSTEM_PROMPT, and the core Agent reads that single env var when it assembles its system prompt. Because every construction path — interactive TUI, one-shot prompt, YAML agents, and Python Agent(...) — funnels through the same env var, the suffix reaches all of them without a new constructor parameter.

Diagram
LLMAgentPRAISONAI_APPEND_SYSTEM_PROMPTCLI (code / chat / run)UserLLMAgentPRAISONAI_APPEND_SYSTEM_PROMPTCLI (code / chat / run)Userpraisonai code –append-system-prompt “…”resolve (literal | @file | env) + exportconstructread oncesuffixappend at END of system prompt (cache-safe)base prompt + appended tailsteered response

The suffix is appended after the stable prompt prefix (and after any path-scoped glob rules), so the cacheable base prompt is preserved and prompt-cache reuse is unaffected. A whitespace-only or unset value is a no-op, and the suffix is never written to any agent definition, YAML, or session backstory.


Choosing a Form

Pick the form that matches how long the guidance should live and how it’s supplied.

Diagram

How do you supply the suffix?

One-off, short text

Multi-line policy

Whole CI / shell job

–append-system-prompt \…\

–append-system-prompt @policy.md

export PRAISONAI_APPEND_SYSTEM_PROMPT=…

OptionTypeDefaultDescription
--append-system-promptstr (literal or @file)NonePer-invocation suffix appended to the system prompt.
PRAISONAI_APPEND_SYSTEM_PROMPT (env)strunsetFallback used when the flag is omitted.

When the value starts with @, the file contents are read (a missing file falls back to treating the raw value as literal text, so a run is never derailed).


Where It Applies

One flag, three commands, same value shape everywhere. Exporting the env var also reaches YAML and Python agents in the same process.

CommandFlagEnv fallback
praisonai code--append-system-promptPRAISONAI_APPEND_SYSTEM_PROMPT
praisonai chat--append-system-promptPRAISONAI_APPEND_SYSTEM_PROMPT
praisonai run--append-system-promptPRAISONAI_APPEND_SYSTEM_PROMPT
YAML / Python—PRAISONAI_APPEND_SYSTEM_PROMPT

Common Patterns

Steer one CLI run in French, no code changes:

bash
praisonai code --append-system-prompt "Always answer in French"

Read the suffix from a policy file:

bash
praisonai run "Refactor this module" --append-system-prompt @policy.md

Set once for a CI job, use across every command:

bash
export PRAISONAI_APPEND_SYSTEM_PROMPT="Reply in strict JSON, no prose."
praisonai chat

Same knob from Python — every Agent constructed after the export picks it up:

python
import os
from praisonaiagents import Agent

os.environ["PRAISONAI_APPEND_SYSTEM_PROMPT"] = "Reply concisely; no bullet points."
agent = Agent(instructions="You are a research assistant")
agent.start("Summarise transformer attention in 3 lines.")

Best Practices

Keep the suffix short

Long suffixes reduce prompt-cache reuse across turns. Prefer a concise steer over a full policy in the flag itself.

Prefer @file for multi-line policies

Reading from a file keeps shell quoting sane and versions the policy alongside your project.

Use the env var in CI

Set PRAISONAI_APPEND_SYSTEM_PROMPT once so the same command runs everywhere without editing each invocation.

Not for persistent behaviour

When the guidance is permanent, put it in YAML or instructions= instead — the suffix disappears when the process exits.


Related