Skip to content

fix(skills): prevent empty responses after load_skill#6226

Open
lwangverizon wants to merge 1 commit into
google:mainfrom
lwangverizon:fix/skill-load-empty-response
Open

fix(skills): prevent empty responses after load_skill#6226
lwangverizon wants to merge 1 commit into
google:mainfrom
lwangverizon:fix/skill-load-empty-response

Conversation

@lwangverizon

Copy link
Copy Markdown
Contributor

fix(skills): prevent empty responses after load_skill

Fixes #6225

Problem

When an agent uses the skill tools, ADK appends a skill system instruction to the
prompt (_build_skill_system_instruction in
src/google/adk/tools/skill_toolset.py). With Gemini models, we observed a
significant rate of empty model responses right after a load_skill call — the
model loads the skill and ends its turn with no visible output.

We saw this as a spike in empty responses in a Verizon production environment running
ADK + Gemini, most acutely for tool-heavy skills whose next correct action after
loading is to call more tools rather than reply.

Root cause

Rule 2 told the model to follow loaded instructions "before replying to the user".
Gemini reads this as license to treat the load_skill tool call as the whole turn
and stop. Nothing in the instruction states that load_skill is non-terminal.

Change

_build_skill_system_instruction only — covers both DEFAULT_SKILL_SYSTEM_INSTRUCTION
and the per-toolset prefixed variant:

  1. Reword rule 2 to drop the "before replying" framing:

    Once you have read the instructions, follow them exactly as documented. For
    example, if the instruction lists multiple steps, please make sure you complete
    all of them in order, and only then reply to the user.

  2. Add rule 7 (continue-after-load guard):

    Loading a skill only retrieves its instructions; it does NOT complete your turn.
    After a load_skill call returns, continue in the SAME turn: call whatever tools
    the skill's steps require (search, data retrieval, render), then write your reply.
    Never end your turn with an empty response right after loading a skill.

No signature or behavior change; rules stay contiguous and the prefix substitution
is preserved (rule 7 uses {p}load_skill like the other rules).

Result

After deploying this guidance in production, the empty-response rate for Gemini after
skill loading dropped substantially.

Tests

Adds focused tests in tests/unittests/tools/test_skill_toolset.py:

  • test_system_instruction_marks_load_skill_as_non_terminal — rule 7 present.
  • test_system_instruction_rule_2_avoids_before_replying_framing — rule 2 no longer
    says "before replying".
  • test_prefixed_system_instruction_includes_continue_after_load_rule — prefixed
    variant carries rule 7 with the prefix.

Existing tests reference DEFAULT_SKILL_SYSTEM_INSTRUCTION by constant (not hardcoded
text), so they are unaffected.

Backwards compatibility

Prompt-text-only change. No public API, signature, or default-behavior change.

The skill system instruction's rule 2 told the model to follow loaded
skill instructions "before replying to the user". Some models (notably
Gemini) read this as license to treat the load_skill tool call as the
entire turn and stop with no visible output, producing empty responses.
This was most acute for tool-heavy skills, whose next correct action
after load_skill is to call more tools rather than reply.

Two changes to _build_skill_system_instruction:
- Reword rule 2 to drop the "before replying" framing.
- Add rule 7 stating that load_skill only retrieves instructions and
  does NOT complete the turn; the model must continue in the same turn
  (calling whatever tools the skill requires) and never end with an
  empty response right after loading a skill.

Verified in a production environment: the empty-response rate for
Gemini after skill loading dropped substantially with this guidance.

Adds tests asserting the new prompt guarantees on both the default and
prefixed system instruction.
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.

Empty model responses after load_skill with Gemini (skill system instruction rule 2)

1 participant