Skip to content

Commit b13dfc6

Browse files
quifoxhemasekhar-p
authored andcommitted
fix(skills): remove unregistered script tool from default instructions
1 parent 9f5d5ce commit b13dfc6

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎core/src/main/java/com/google/adk/tools/skills/SkillToolset.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class SkillToolset implements BaseToolset {
5656
1. If a skill seems relevant to the current user query, you MUST use the `load_skill` tool with `skill_name="<SKILL_NAME>"` to read its full instructions before proceeding.
5757
2. Once you have read the instructions, follow them exactly as documented before replying to the user. For example, If the instruction lists multiple steps, please make sure you complete all of them in order.
5858
3. The `load_skill_resource` tool is for viewing files within a skill's directory (e.g., `references/*`, `assets/*`, `scripts/*`). Do NOT use other tools to access these files.
59-
4. Use `run_skill_script` to run scripts from a skill's `scripts/` directory. Use `load_skill_resource` to view script content first if needed.
6059
""";
6160

6261
private final SkillSource skillSource;

‎core/src/test/java/com/google/adk/tools/skills/SkillToolsetTest.java‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.google.common.truth.Correspondence;
3232
import io.reactivex.rxjava3.core.Flowable;
3333
import java.util.List;
34+
import java.util.regex.Pattern;
3435
import org.junit.Test;
3536
import org.junit.runner.RunWith;
3637
import org.junit.runners.JUnit4;
@@ -140,4 +141,29 @@ public void close() {}
140141
baseToolset.processLlmRequest(LlmRequest.builder(), mock(ToolContext.class)).blockingAwait();
141142
}
142143
}
144+
145+
@Test
146+
public void processLlmRequest_defaultInstructionOnlyMentionsRegisteredTools() throws Exception {
147+
SkillSource skillSource =
148+
InMemorySkillSource.builder()
149+
.skill("test-skill")
150+
.frontmatter(Frontmatter.builder().name("test-skill").description("test skill").build())
151+
.instructions("Test instructions")
152+
.build();
153+
try (SkillToolset toolSet = new SkillToolset(skillSource)) {
154+
LlmRequest.Builder requestBuilder = LlmRequest.builder();
155+
toolSet.processLlmRequest(requestBuilder, mock(ToolContext.class)).blockingAwait();
156+
List<String> availableTools =
157+
toolSet.getTools(null).toList().blockingGet().stream().map(BaseTool::name).toList();
158+
List<String> mentionedTools =
159+
Pattern.compile("`([a-z_]+)`")
160+
.matcher(requestBuilder.build().getSystemInstructions().get(0))
161+
.results()
162+
.map(match -> match.group(1))
163+
.distinct()
164+
.toList();
165+
assertThat(mentionedTools).isNotEmpty();
166+
assertThat(availableTools).containsAtLeastElementsIn(mentionedTools);
167+
}
168+
}
143169
}

0 commit comments

Comments
 (0)