fix(llm_agent_builder): enforce use_emojis=false, not just true - #72
Open
mateusbellozupko wants to merge 2 commits into
Open
mateusbellozupko wants to merge 2 commits into
mateusbellozupko wants to merge 2 commits into
Conversation
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>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe agent builder now translates the Flow diagram for explicit emoji instruction selectionflowchart 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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
use_emojisagent config toggle only ever added a prompt instruction when set totrue(encouraging emoji use). Whenfalse(or unset), it silently added nothing.false/unset path explicitly adds"Do not use any emojis in your responses, under any circumstance."to the prompt, mirroring the existingtruebranch's approach.Test plan
python3 -m py_compileon the modified file🤖 Generated with Claude Code
Summary by Sourcery
Enforce the agent emoji preference reliably when assembling LLM prompts.
Bug Fixes:
use_emojissetting in both directions by explicitly instructing agents to avoid emojis when the option is false or unset.Enhancements: