load_skill re-returns full SKILL.md instructions on every call. Is context growth from repeated loads expected? #6997
Replies: 1 comment
|
Your reading of the current implementation is correct. The important distinction is that
A state-only short circuit would therefore be unsafe. ADK compaction replaces covered raw events with a summary, and the default summarizer caps each rendered tool response at 2,000 characters. After that, session state may still say the skill is activated while most of its instructions are no longer visible to the model. Returning “already loaded, see earlier turn” would leave the model unable to recover them. The per-agent namespace also makes sense for the same reason: activation by agent A does not prove that agent B's model context has ever received the instructions. So I would answer the three questions as follows:
There is also relevant prior maintainer feedback on an activated-skill eviction proposal: removing skill tools was rejected because it could invalidate context caching and leave the model referring to tools introduced in earlier turns (#5745). That is not the identical change, but it reinforces that session state and visible conversation history must stay coherent. A small prompt clarification such as “do not reload a skill whose full instructions are still present in the active context; reload if they may have been compacted away” looks safer than a server-side state-only guard. Whether that wording or a context-aware API change is preferred still needs a maintainer decision. |
Uh oh!
There was an error while loading. Please reload this page.
Looking at
SkillToolset/LoadSkillToolingoogle/adk/tools/skill_toolset.py, I want to check whether the current behavior is intentional.LoadSkillTool.run_asyncalways returns the fullskill.instructionsbody in the function response:There's a per-agent
activated_skillslist tracked intool_context.state(_adk_activated_skill_{agent_name}), but it's only consulted in_resolve_additional_tools_from_stateto decide whichadk_additional_toolsto expose — it's never used to short-circuitload_skillitself. So if the model callsload_skillon the same skill twice in a session (e.g. after a context summarization/truncation step upstream, or just because it isn't careful about tracking what it already has), the full SKILL.md content gets duplicated in the conversation history each time.The system instruction (
_DEFAULT_SKILL_SYSTEM_INSTRUCTION) tells the model it "MUST useload_skill" whenever a skill seems relevant, but doesn't say anything like "only if you haven't already loaded it this session" — so the framework seems to rely entirely on the model's own judgment/memory of its history to avoid redundant loads, rather than the toolset enforcing it.Questions:
activated_skillsis namespaced per-agent, so the same skill can get loaded — and its instructions duplicated — once per sub-agent)?load_skillcheckactivated_skillsfirst and return a short "already loaded, see earlier turn" response instead of the full instructions on repeat calls be a welcome contribution, or is there a reason this wasn't done already (e.g. context truncation elsewhere making that check unreliable)?All reactions