Skip to content

fix(llm_agent_builder): enforce use_emojis=false, not just true - #72

Open
mateusbellozupko wants to merge 2 commits into
evolution-foundation:mainfrom
mateusbellozupko:fix/enforce-use-emojis-false
Open

mateusbellozupko wants to merge 2 commits into
evolution-foundation:mainfrom
mateusbellozupko:fix/enforce-use-emojis-false

Conversation

@mateusbellozupko

@mateusbellozupko mateusbellozupko commented Sep 22, 2026 •

Copy link
Copy Markdown

Summary

  • The use_emojis agent config toggle only ever added a prompt instruction when set to true (encouraging emoji use). When false (or unset), it silently added nothing.
  • This meant disabling the toggle had no actual effect on the model's behavior — emoji suppression relied entirely on the agent's own free-text instruction (if any) or the model's own default tendencies, both of which are unreliable.
  • Now the false/unset path explicitly adds "Do not use any emojis in your responses, under any circumstance." to the prompt, mirroring the existing true branch's approach.

Test plan

  • python3 -m py_compile on the modified file
  • No existing unit tests cover this function's prompt assembly; manual review of the added instruction text

🤖 Generated with Claude Code

Summary by Sourcery

Enforce the agent emoji preference reliably when assembling LLM prompts.

Bug Fixes:

  • Enforce the use_emojis setting in both directions by explicitly instructing agents to avoid emojis when the option is false or unset.

Enhancements:

  • Normalize string and boolean configuration values so disabled settings are not mistakenly treated as enabled.

The use_emojis config toggle only ever injected a prompt instruction
when set to true (encouraging emoji use); when false it silently added
nothing, leaving emoji suppression entirely up to the agent's own
free-text instruction or the model's default behavior. Operators
turning the toggle off saw no effect. Now the false/unset path
explicitly instructs the model not to use emojis.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The agent builder now translates the use_emojis configuration into an explicit prompt instruction for either behavior, preventing false or unset values from silently relying on model defaults or free-text instructions.

Flow diagram for explicit emoji instruction selection

flowchart TD
    A["_create_llm_agent"] --> B["Read agent.config.use_emojis"]
    B --> C{use_emojis is true?}
    C -->|Yes| D["Append instruction to use emojis"]
    C -->|No or unset| E["Append instruction to not use emojis"]
    D --> F["Assemble agent prompt"]
    E --> F
Loading

File-Level Changes

Change Details Files
Make the emoji preference enforceable in both enabled and disabled states during prompt assembly.
  • Continue adding a positive emoji-use instruction when use_emojis is truthy.
  • Add an explicit prohibition when use_emojis is false or unset.
  • Clarify in comments why both branches are required.
src/services/adk/agents/llm_agent_builder.py

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

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

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/services/adk/agents/llm_agent_builder.py" line_range="790" />
<code_context>
+        # instruction (or the model's default tendencies) to suppress emojis,
+        # silently failing to enforce the toggle when the operator turned it off.
         use_emojis = agent.config.get("use_emojis")
         if use_emojis:
             agent_config_sections.append(
                 "Use emojis in your responses to make communication more friendly and engaging. Incorporate appropriate emojis naturally throughout your messages."
</code_context>
<issue_to_address>
**issue (bug_risk):** A serialized configuration value such as the string `"false"` is truthy in Python, so the builder selects the emoji-enabling instruction instead of the disabling instruction. `AgentBase.config` accepts `Any` and the JSON configuration is not validated or normalized to a boolean.

**Triggers:** When an API client or persisted configuration supplies `use_emojis` as a string rather than a native JSON boolean.

**Suggested fix:** Normalize or strictly compare the value before branching, for example by accepting only `use_emojis is True` for the enabling branch and treating all other values as disabled, or by validating the config as a boolean at its boundary.

```suggestion
        if use_emojis is True:
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/services/adk/agents/llm_agent_builder.py:790


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/services/adk/agents/llm_agent_builder.py
A stringified "false" from persisted JSON config is truthy in Python,
so the builder was enabling emojis for a config that explicitly
disabled them. Normalize to a strict boolean first.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

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