AI Coding Agents: Understanding Role Prompts, Emotion-Aware Tone, and Behavior Consistency

    This article examines how AI coding agents separate presentation from execution, and why that separation matters in real development workflows. It explains "hidden AI identity" as layered system prompts and tool-view isolation, breaks emotion detection into tone, task, and fact layers, and shows why an unchanged backend plan is a feature paired with an observability gap. It also proposes quantitative evaluation metrics and practical guidance for teams deploying agents in internal environments.

    1. From a Viral “Source Code Leak” Story Back to the Real Engineering Problem

    A recent post describing the internal mechanics of an AI coding tool spread widely in developer communities. The narrative was exaggerated, but three points it repeated are genuinely relevant to engineering: the tool deliberately conceals its non-human identity, it detects user emotion and adjusts its tone, and its backend execution plan does not change regardless of that tone. Strip away the sensational framing and one question remains: when an agent is placed inside a real development workflow, can its presentation be decoupled from its actual behavior, and what risks does that decoupling create?

    This article does not discuss the implementation details of any specific product, nor does it make factual claims about internal mechanisms that have not been publicly confirmed. Everything below concerns capabilities that are already common across the industry: layered system prompts, tool-call whitelists, input-side emotion and risk signal detection, and observability of execution traces.

    2. The So-Called “Undercover Mode”: Role Configuration and Toolchain View Isolation

    Treating “hiding the AI identity” as some mysterious technique is a misreading. It comes down to two fairly ordinary things.

    The first is the role prompt. System prompts are usually split into layers: a platform layer enforces safety and compliance, a product layer defines capability boundaries, and a role layer defines tone and persona. An instruction like “do not reveal that you are a model” is, in engineering terms, often just one style constraint at the role layer, in the same category as “answer concisely” or “prefer runnable code.” No special algorithm is involved.

    1. # Platform layer (cannot be overridden by the user)
    2. - Follow safety policies; do not perform unauthorized operations
    3. - Explicitly request confirmation for high-risk actions
    4. # Role layer (style constraints, adjustable via product configuration)
    5. - Maintain a consistent assistant persona and tone
    6. - Do not volunteer self-description unrelated to the task

    The second is tool view isolation. A mature agent typically has a difference between “the tool set declared to the model” and “the tool set actually registered at runtime.” The former is trimmed and renamed to expose only the minimum surface needed to complete the task; the latter includes low-level capabilities such as sandbox execution, file read/write, and log reporting. The legitimate motivation is to reduce accidental calls and shrink the prompt-injection attack surface, not to deceive anyone.

    1. # Illustration: separating declared tools from internal registration
    2. declared_tools = ["search_repo", "run_tests", "apply_patch"]
    3. runtime_registry = {
    4. "search_repo": sandbox_readonly_search,
    5. "run_tests": sandbox_exec,
    6. "apply_patch": guarded_patch_apply, # requires secondary confirmation
    7. "_internal_telemetry": telemetry_report, # not declared to the model
    8. }

    The problem lies at the boundary. When “minimum exposure” crosses into “concealing material facts from the user,” its nature changes. The test can be simple: would the hidden information affect the user’s decisions? The tool list, failure reasons, and whether external services were called are information that should be disclosed; internal implementation class names and irrelevant internal identifiers are information that may be withheld.

    3. Emotion Awareness: What It Can and Cannot Do

    Running emotion and risk signal detection on input is a common configuration for conversational systems, and it is not technically complex: it can be lightweight keyword and regex rules, a classification model score, or both, with a session-level state machine layered on top for debouncing so that a single message does not switch the persona.

    1. def adjust_tone(user_msg, session):
    2. signal = emotion_score(user_msg) # 0~1
    3. session.smooth = 0.7 * session.smooth + 0.3 * signal
    4. if session.smooth > 0.7:
    5. return "supportive" # empathize first, then give steps
    6. if is_high_risk(session):
    7. return "escalate" # hand off to a human or surface help channels
    8. return "neutral"

    What deserves real caution is not “the tone turns gentle” but the fact that three things get mixed together:

    • Tone-layer adjustment: reasonable, and a form of experience optimization.
    • Task-layer adjustment: requires transparency. Skipping tests or loosening validation because the user is angry puts experience above correctness.
    • Fact-layer adjustment: unacceptable. Softening risk warnings or omitting failure conclusions to make someone feel better is misleading the user.

    Engineering practice should separate these three layers explicitly and fix the separation in configuration: tone may adapt automatically, changes to task parameters must be logged and communicated, and factual statements must never be modulated by emotion signals.

    4. Is “the Backend Policy Stays the Same” a Feature or a Flaw

    The original post framed this as inconsistency between surface and substance. In reality it is closer to the default state of current agent architectures: the language layer handles communication, the planning layer handles decisions, and the execution layer handles delivery. The three communicate through structured intermediate artifacts, and tone changes usually affect only the outermost layer.

    1. {
    2. "plan_id": "p-1024",
    3. "steps": ["read_config", "patch_module", "run_unit_tests"],
    4. "tone": "supportive",
    5. "risk_level": "medium",
    6. "requires_confirmation": true
    7. }

    As long as a change to tone is not written into steps, behavior stays consistent. That is actually a good thing: the system will not randomly change technical decisions because of user emotion. But it also exposes a real flaw, insufficient explainability. The user sees gentle wording but cannot see the plan, the risk level, or the actions already taken, which makes it easy to overestimate how much control they have over the situation.

    The direction for improvement is to expose these intermediate artifacts to the user rather than hide them:

    1. Visible plans: show the steps about to run and their scope of impact.
    2. Auditable actions: log a summary of inputs, return status, and duration for every tool call, and ship it to a logging service for retrospection.
    3. Interceptable high-risk operations: force secondary confirmation for deletion, bulk rewrites, and production configuration changes, and support a dry run in a container platform or sandbox first.
    4. Reproducible conclusions: provide runnable verification commands and expected output so users can confirm results themselves.

    5. Evaluation: Metrics Instead of Impressions

    Whether an AI coding assistant is reliable should not be judged by “how comfortable the conversation feels.” Build a quantifiable evaluation set instead:

    • Task success rate: the proportion of patches that pass tests on the first attempt over a fixed set of repository samples.
    • Privilege violation rate: the proportion of runs that trigger undeclared tools or skip confirmation steps; lower is better.
    • Consistency: the variance of results across repeated runs of the same task.
    • Explainability coverage: the proportion of outputs that include a plan, risk information, and verification steps.
    • Factual fidelity: the proportion of failures reported truthfully, used to catch “only reporting good news.”

    Pair this with monitoring and alerting, set privilege violation rate and factual fidelity as red-line metrics, and roll back the prompt or tool configuration version as soon as either degrades.

    6. Practical Advice for Users

    • Treat it as a collaborator, not an authority: verify key conclusions yourself.
    • Watch behavior, not persona: no matter how human the tone sounds, check what it actually called and what it changed.
    • Tighten permissions: default to least privilege, and enable write operations and external access only as needed.
    • Keep human gates: do not let architecture decisions, data deletion, or release changes close the loop through automation alone.
    • Record sessions and traces: useful for retrospectives, and for reconstructing facts when disputes arise.

    7. Conclusion

    The value of the debate around tools like these is not in peeking at internal configuration, but in advancing a shared understanding: evaluating an agent’s capabilities must come back to three things, observability, auditability, and reproducibility. Identity statements and tone policies belong to the experience layer; permission boundaries and factual fidelity belong to the governance layer, and the latter is what determines whether an agent can enter a production development workflow. For teams that want to deploy AI coding capabilities in an internal network, general capabilities such as the container platform, logging service, and monitoring and alerting offered by Baidu AI Cloud can be used to build sandbox execution, trace retention, and red-line metric alerting, turning “looks smart” into “verifiably reliable.”