fix: add --append-system-prompt to code/chat/run - #3756
fix: add --append-system-prompt to code/chat/run#3756praisonai-triage-agent[bot] wants to merge 2 commits into
Conversation
|
@coderabbitai review |
|
/review |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
|
Warning Review limit reached
Next review available in: 14 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThe PR adds a per-invocation system-prompt suffix for the
Confidence Score: 4/5The PR is not yet safe to merge because a suffix from one in-process invocation can still alter later invocations that did not request it. The warm-runtime loss has been addressed, but the append helper leaves its process-global environment mutation in place; a later command resolves that retained value as its fallback and core agent construction appends it again. Files Needing Attention: src/praisonai-code/praisonai_code/cli/utils/append_prompt.py
|
| Filename | Overview |
|---|---|
| src/praisonai-code/praisonai_code/cli/utils/append_prompt.py | Resolves and exports the suffix, but the previously reported process-environment leakage remains outstanding. |
| src/praisonai-code/praisonai_code/cli/commands/run.py | Forwards the resolved suffix into direct prompt execution and correctly bypasses the warm runtime when it is present. |
| src/praisonai-agents/praisonaiagents/agent/agent.py | Appends the environment-provided suffix during initial system-prompt construction. |
| src/praisonai-agents/praisonaiagents/agent/chat_mixin.py | Appends the suffix after cached and path-scoped prompt content on both chat prompt-building paths. |
| src/praisonai-code/tests/unit/test_run_outcome_exit.py | Adds regression coverage proving suffix-bearing runs bypass the warm runtime while ordinary eligible runs still attach. |
Reviews (7): Last reviewed commit: "fix: keep --append-system-prompt in-proc..." | Re-trigger Greptile
|
@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding. Phase 1: Review per AGENTS.md
Phase 2: FIX Valid Issues Phase 3: Final Verdict |
|
Claude finished @MervinPraison's task —— View job Final Architecture Review — PR #3756
Phase 1 — Architecture review (per AGENTS.md)
Phase 2 — Fixed the valid issueGreptile P1 (VALID): warm-runtime Fix (minimal, mirrors existing gates): exclude the warm-runtime path when the suffix is active, forcing the in-process route that correctly applies it — exactly like the existing Files modified (this branch):
Independent review of other paths: Skipped (correctly out of scope): CodeRabbit/Qodo produced no actionable findings (rate-limited/paused). No Phase 3 — Tests
Verdict: ✅ ApproveSolid, lightweight design that respects the no-Agent-bloat rule and prompt-cache discipline. The one valid architectural gap (warm-runtime bypass) is now fixed and covered by regression tests. Ready to merge. |
|
@claude this PR has merge conflicts with |
|
Claude finished @MervinPraison's task —— View job Rebased PR #3756 onto latest
|
b3f71ca to
1e52e75
Compare
|
Claude finished @MervinPraison's task —— View job CI Failure Fix — PR #3756
Verdict: Pre-existing flake — root-caused, not masked (not a regression from this PR)The two failing tests live in The file was added in #3733 and already carried a dedicated isolation fix (
Fix (minimal, no assertions weakened)
Reproduction proving the mechanism & fix (polluter task on the shared loop, then quiesce + reseed): SDK guardrails
Tests
Files modified
Pushed • View job • Branch: |
|
@claude this PR has merge conflicts with |
|
Claude finished @MervinPraison's task —— View job Rebased PR #3756 onto latest
|
d7b41b8 to
1292978
Compare
| """ | ||
| resolved = resolve_append_system_prompt(value) | ||
| if resolved: | ||
| os.environ[ENV_VAR] = resolved |
There was a problem hiding this comment.
Prompt suffix leaks across invocations
When two CLI commands run sequentially in the same Python process and only the first supplies --append-system-prompt, this assignment leaves the first suffix in os.environ; the second invocation resolves that retained value as its environment fallback, causing its agent to receive instructions that were intended only for the earlier invocation.
Knowledge Base Used: praisonai-code
|
@claude this PR has merge conflicts with |
|
Claude finished @MervinPraison's task —— View job Rebased PR #3756 onto latest
|
1292978 to
ba2d2cb
Compare
|
@claude this PR has merge conflicts with |
|
Claude finished @MervinPraison's task —— View job Rebased PR #3756 onto latest
|
Adds a per-invocation --append-system-prompt flag to the code, chat and run commands. The flag accepts literal text or an @file reference and falls back to the PRAISONAI_APPEND_SYSTEM_PROMPT env var for CI. Kept lightweight: no new Agent constructor param. The CLI exports the resolved value via the env var and the core Agent appends it at the END of the assembled system prompt (both the __init__ prompt and the chat _build_system_prompt path), preserving the prompt-cache prefix (#2993) and never persisting to agent files. Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>
The warm runtime is a separate process that never receives the CLI's PRAISONAI_APPEND_SYSTEM_PROMPT export and reuses a cached agent, so an eligible `run` that forwarded to the daemon silently dropped the appended suffix. Exclude the warm-runtime fast path when the suffix is set so the in-process path (which applies it) is used, mirroring the existing thinking_budget/isolated/instructions gates. Adds regression tests: append-suffix runs never attach warm; ordinary no-save runs still do. Fixes Greptile P1 review on #3743. Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
ba2d2cb to
ef57911
Compare
Fixes #3743
Summary
Adds a per-invocation
--append-system-promptflag to thecode,chatandruncommands, so users can append to the system prompt at launch without editing agent files or YAML:@filereference (file contents are read).PRAISONAI_APPEND_SYSTEM_PROMPTfor CI.Design (lightweight, per AGENTS.md)
Agentconstructor param. The commands resolve the value and exportPRAISONAI_APPEND_SYSTEM_PROMPT; the coreAgentreads that single env var when assembling the system prompt. This one choke point serves all three commands plus YAML/Python without threading a kwarg through the many interactive-TUI/legacy agent-construction sites.Agent.__init__(non-chat path) andchat_mixin._build_system_prompt(chat/messages path, appended after the cached base + glob rules so it stays out of the cache prefix).SessionData.metadatapersistence/resume-reapply. Sessions restore conversation history; the append is a per-invocation knob re-supplied via flag/env each run, so extra session plumbing would be scope creep with no strong consumer.Changes
praisonaiagents/agent/agent.py: append env text to tail ofsystem_prompt(no-op when unset).praisonaiagents/agent/chat_mixin.py:_append_system_prompt_suffixapplied at both return points of_build_system_prompt.praisonai_code/cli/utils/append_prompt.py:resolve_append_system_prompt/apply_append_system_prompthelpers (stdlib only; literal,@file, env fallback).commands/code.py,commands/chat.py,commands/run.py: add the Typer option and wire it in.Tests
New
tests/unit/agent/test_append_system_prompt.py— visible in prompt tail (init + chat build paths), no-op when unset/blank, not persisted to backstory,@fileform, env fallback. 10 passed; related system-prompt/glob-rules/cache tests still green.Generated with Claude Code