Skip to content

patch: system_instruction#10

Merged
JohnRichard4096 merged 2 commits intomainfrom
patch/system
Feb 17, 2026
Merged

patch: system_instruction#10
JohnRichard4096 merged 2 commits intomainfrom
patch/system

Conversation

@JohnRichard4096
Copy link
Copy Markdown
Member

@JohnRichard4096 JohnRichard4096 commented Feb 17, 2026

Summary by Sourcery

Update chat manager system instructions handling and bump project patch version.

Enhancements:

  • Clarify that conversation summaries in the schema description are provided only when available and adjust how system instructions are injected into the prompt.
  • Change summary injection to be conditional on memory abstraction being enabled instead of always emitting empty summary tags.

Build:

  • Bump project version from 0.4.2 to 0.4.2.1.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Feb 17, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the chatmanager system instruction prompt to always embed the character configuration and to conditionally include conversation summaries only when memory abstraction is enabled, and bumps the project patch version.

Sequence diagram for updated system instruction prompt construction

sequenceDiagram
    participant ChatManager
    participant Config
    participant ConfigLLM as ConfigLLM
    participant ConversationData

    ChatManager->>ChatManager: _run()
    ChatManager->>Config: get llm
    Config->>ConfigLLM: return llm
    ChatManager->>ConfigLLM: read enable_memory_abstract
    alt enable_memory_abstract is true
        ChatManager->>ConversationData: read abstract
        ConversationData-->>ChatManager: abstract
        ChatManager->>ChatManager: build prompt with SYSTEM_INSTRUCTIONS and SUMMARY
    else enable_memory_abstract is false
        ChatManager->>ChatManager: build prompt with SYSTEM_INSTRUCTIONS only
    end
    ChatManager-->>ChatManager: send prompt to LLM
Loading

Updated class diagram for ChatManager prompt construction logic

classDiagram
    class ChatManager {
        dict train
        _run()
    }

    class Config {
        ConfigLLM llm
    }

    class ConfigLLM {
        bool enable_memory_abstract
    }

    class ConversationData {
        string abstract
    }

    ChatManager --> Config : uses
    ChatManager --> ConversationData : reads
    Config --> ConfigLLM : has
Loading

File-Level Changes

Change Details Files
Refine construction of system prompt to embed character instructions explicitly and gate summary injection on configuration.
  • Clarified the description of the tag to indicate it may be absent when not provided.
  • Inlined self.train["content"] inside the <SYSTEM_INSTRUCTIONS> section of the generated prompt so the character setting is always included.
  • Changed summary block construction to only append ... when config.llm.enable_memory_abstract is true, avoiding empty summary tags when disabled.
src/amrita_core/chatmanager.py
Increment project patch version to reflect prompt behavior change.
  • Bumped amrita_core version from 0.4.2 to 0.4.2.1 in project metadata.
  • Updated lockfile metadata to stay consistent with the new version.
pyproject.toml
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The conditional omission of the block when enable_memory_abstract is false may break any downstream logic or prompts that currently assume the tags are always present (even if empty); consider keeping empty tags if consumers rely on their presence.
  • Accessing self.train["content"] without a default or guard will raise if the key is missing or None; consider using self.train.get("content", "") or validating this earlier to avoid runtime errors.
  • The interpolated summary string adds a trailing space (f"\n{data.abstract} \n"); consider trimming or normalizing this to avoid subtle formatting issues in the final prompt.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The conditional omission of the <SUMMARY> block when `enable_memory_abstract` is false may break any downstream logic or prompts that currently assume the tags are always present (even if empty); consider keeping empty tags if consumers rely on their presence.
- Accessing `self.train["content"]` without a default or guard will raise if the key is missing or `None`; consider using `self.train.get("content", "")` or validating this earlier to avoid runtime errors.
- The interpolated summary string adds a trailing space (`f"\n{data.abstract} \n"`); consider trimming or normalizing this to avoid subtle formatting issues in the final prompt.

## Individual Comments

### Comment 1
<location> `src/amrita_core/chatmanager.py:571` </location>
<code_context>
+            + "Your character setting is in the <SYSTEM_INSTRUCTIONS> tags, and the summary of previous conversations is in the <SUMMARY> tags (if provided)."
             + "\n</SCHEMA>\n"
             + "<SYSTEM_INSTRUCTIONS>\n"
+            + self.train["content"]
             + "\n</SYSTEM_INSTRUCTIONS>"
-            + f"\n<SUMMARY>\n{data.abstract if config.llm.enable_memory_abstract else ''}\n</SUMMARY>"
</code_context>

<issue_to_address>
**🚨 suggestion (security):** Consider whether logging `self.train["content"]` is appropriate given it may contain sensitive system instructions.

Because this value is embedded directly into `<SYSTEM_INSTRUCTIONS>`, the `logger.debug(self.train["content"])` call will log those instructions verbatim and could expose sensitive context depending on your logging setup. Consider removing this log, gating it behind a stricter debug flag, or sanitizing/truncating the content before logging.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/amrita_core/chatmanager.py
@JohnRichard4096 JohnRichard4096 merged commit e475b4f into main Feb 17, 2026
2 checks passed
@JohnRichard4096 JohnRichard4096 deleted the patch/system branch February 17, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant