Skip to content

Conversation

@fang-tech
Copy link
Contributor

AgentScope-Java Version

[The version of AgentScope-Java you are working on, e.g. 1.0.8, check your pom.xml dependency version or run mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@gemini-code-assist
Copy link

Summary of Changes

Hello @fang-tech, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the customization and flexibility of skill management and code execution within the AgentScope framework. It introduces a powerful builder pattern for configuring code execution environments, allowing developers to precisely control tool availability, working directories, and resource handling. Furthermore, it provides comprehensive tools and documentation to streamline the creation and packaging of new skills, fostering a more robust and extensible agent ecosystem.

Highlights

  • Enhanced Code Execution Configuration: The SkillBox now features a fluent builder API (codeExecution()) for configuring code execution capabilities, offering granular control over enabling shell, read, and write tools, custom working directories, and file filtering.
  • Flexible Skill Resource Management: Skill resources can now be uploaded to a configurable directory, supporting Base64 encoded content and allowing custom file filters to determine which resources are included. The AgentSkill class has been updated to provide generic resource access methods.
  • Customizable Agent Prompts: The AgentSkillPromptProvider now allows for custom instruction headers and skill templates, providing greater flexibility in how agents are prompted to use skills.
  • New Skill Creation Utilities and Documentation: A comprehensive 'skill-creator' example has been added, including Python utility scripts (init_skill.py, package_skill.py, quick_validate.py) and detailed Markdown documentation (SKILL.md, output-patterns.md, workflows.md) to guide users through the skill creation and packaging process.
  • Improved ShellCommandTool and Documentation: The ShellCommandTool now includes getter methods for its configuration, facilitating easier cloning and customization. The documentation has been updated to reflect the new code execution features and tool lifecycle.
Changelog
  • agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java
    • Updated skill configuration logic to use isAutoUploadSkill() and uploadSkillFiles() instead of isCodeExecutionEnabled() and writeSkillScriptsToWorkDir().
  • agentscope-core/src/main/java/io/agentscope/core/skill/AgentSkill.java
    • Removed SCRIPT_EXTENSIONS constant and related script-specific methods (getScriptResources, hasScriptExtension).
    • Added generic resource access methods: getResource(String resourcePath) and getResourcePaths().
  • agentscope-core/src/main/java/io/agentscope/core/skill/AgentSkillPromptProvider.java
    • Introduced fields for custom instruction and template strings.
    • Added constructors to allow injecting custom instruction and template for skill prompts.
    • Updated default skill instruction to include code execution guidance.
    • Modified getSkillSystemPrompt() to use custom instruction and template if provided.
  • agentscope-core/src/main/java/io/agentscope/core/skill/SkillBox.java
    • Replaced enableCodeExecution() methods with a fluent codeExecution() builder for configuring code execution.
    • Introduced workDir, uploadDir, fileFilter, and autoUploadSkill fields for enhanced control over skill file handling.
    • Added setAutoUploadSkill() and isAutoUploadSkill() methods.
    • Implemented ensureUploadDirExists() for managing the skill upload directory.
    • Replaced writeSkillScriptsToWorkDir() with uploadSkillFiles(), which now supports SkillFileFilter and Base64 decoding.
    • Added CodeExecutionBuilder inner class to provide a flexible API for configuring code execution tools (shell, read, write) with custom settings and file filtering.
  • agentscope-core/src/main/java/io/agentscope/core/skill/SkillFileFilter.java
    • Added new functional interface SkillFileFilter for defining custom logic to accept or reject skill resources for upload.
  • agentscope-core/src/main/java/io/agentscope/core/tool/coding/ShellCommandTool.java
    • Added getter methods: getApprovalCallback(), getCommandValidator(), and getBaseDir() to expose internal configuration for cloning and inspection.
  • agentscope-core/src/test/java/io/agentscope/core/skill/AgentSkillTest.java
    • Updated tests to reflect the removal of script-specific resource methods and the addition of generic resource access methods.
  • agentscope-core/src/test/java/io/agentscope/core/skill/SkillBoxTest.java
    • Refactored code execution tests to use the new codeExecution() builder API.
    • Added tests for custom upload directories, file filtering, Base64 decoding, and selective tool enablement.
    • Introduced comprehensive tests for the CodeExecutionBuilder's functionality, including configuration replacement and custom ShellCommandTool cloning.
  • agentscope-core/src/test/java/io/agentscope/core/tool/coding/ShellCommandToolTest.java
    • Added new test cases for the getter methods of ShellCommandTool.
    • Included extensive tests for base directory enforcement across different operating systems and command types.
  • agentscope-examples/quickstart/src/main/java/io/agentscope/examples/quickstart/AgentSkillExample.java
    • Completely refactored the example to demonstrate a 'skill-creator' agent, showcasing the new code execution and skill management features.
    • Removed previous data analysis skill setup and related classes.
    • Configured SkillBox with a custom ShellCommandTool and approval callback using the new builder API.
  • agentscope-examples/quickstart/src/main/resources/skills/skill-creator/LICENSE.txt
    • Added Apache License 2.0 for the new 'skill-creator' skill.
  • agentscope-examples/quickstart/src/main/resources/skills/skill-creator/SKILL.md
    • Added comprehensive Markdown documentation for the 'skill-creator' skill, detailing skill anatomy, core principles, progressive disclosure, and the skill creation process.
  • agentscope-examples/quickstart/src/main/resources/skills/skill-creator/references/output-patterns.md
    • Added documentation on effective output patterns (template and examples) for skill development.
  • agentscope-examples/quickstart/src/main/resources/skills/skill-creator/references/workflows.md
    • Added documentation on workflow patterns (sequential and conditional) for skill development.
  • agentscope-examples/quickstart/src/main/resources/skills/skill-creator/scripts/init_skill.py
    • Added a Python script to initialize a new skill directory with a template SKILL.md and example resource folders.
  • agentscope-examples/quickstart/src/main/resources/skills/skill-creator/scripts/package_skill.py
    • Added a Python script to package a skill folder into a distributable .skill file, including validation.
  • agentscope-examples/quickstart/src/main/resources/skills/skill-creator/scripts/quick_validate.py
    • Added a Python script for quick validation of a skill's SKILL.md frontmatter.
  • docs/en/task/agent-skill.md
    • Updated documentation to include details about the load_skill_through_path tool and its parameters.
    • Added a new section on 'Code Execution Capabilities' explaining the new builder pattern for configuring code execution tools.
    • Included information on the lifecycle of progressively disclosed tools.
  • docs/zh/task/agent-skill.md
    • Updated Chinese documentation with the same details as the English version regarding load_skill_through_path, code execution capabilities, and tool lifecycle.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant improvements to the skill execution customization. The refactoring of SkillBox to use a CodeExecutionBuilder provides a much more flexible and fluent API for configuring code execution environments. The simplification of AgentSkill and the added customizability to AgentSkillPromptProvider are also welcome changes. The new example for creating skills is very comprehensive and does a great job of showcasing the new features. The test coverage for the new functionality is excellent. I have a couple of suggestions to improve code conciseness and adherence to best practices.


Always be thorough in your analysis and explain your reasoning clearly.
""";
scanner.close();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Closing a Scanner that wraps System.in also closes the underlying System.in stream. This is generally discouraged because it can prevent other parts of an application from reading from standard input. While it's acceptable in this simple example that exits after the chat, it's a good practice to avoid closing scanners that wrap System.in. The JVM will handle closing the stream on exit.

@fang-tech fang-tech force-pushed the feat/skill/support-more-customization-to-codeExecution branch from 2f8d242 to 04aa83d Compare February 3, 2026 08:04
@codecov
Copy link

codecov bot commented Feb 3, 2026

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the Skill system’s “code execution” support to be more customizable and introduces a new example “skill-creator” skill + tooling.

Changes:

  • Reworked SkillBox code execution into a fluent builder (selectively enable shell/read/write, configure workDir/uploadDir, customize ShellCommandTool, and upload skill files).
  • Added new skill-creator bundled resources (SKILL.md, references, packaging/validation/init scripts) and updated docs (EN/ZH) to describe new capabilities.
  • Added/updated tests around ShellCommandTool configuration/getters and SkillBox code execution/upload behavior, plus updated the quickstart example.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
docs/zh/task/agent-skill.md Documents unified skill loading + tool lifecycle + code execution capabilities (ZH).
docs/en/task/agent-skill.md Documents unified skill loading + tool lifecycle + code execution capabilities (EN).
agentscope-examples/quickstart/src/main/resources/skills/skill-creator/scripts/quick_validate.py Adds a minimal skill validator script for SKILL.md frontmatter.
agentscope-examples/quickstart/src/main/resources/skills/skill-creator/scripts/package_skill.py Adds a packager script to create distributable .skill archives.
agentscope-examples/quickstart/src/main/resources/skills/skill-creator/scripts/init_skill.py Adds a skill initializer script to generate a template skill folder.
agentscope-examples/quickstart/src/main/resources/skills/skill-creator/references/workflows.md Adds workflow-pattern guidance for skill authors.
agentscope-examples/quickstart/src/main/resources/skills/skill-creator/references/output-patterns.md Adds output-format pattern guidance for skill authors.
agentscope-examples/quickstart/src/main/resources/skills/skill-creator/SKILL.md Introduces the “skill-creator” skill content.
agentscope-examples/quickstart/src/main/resources/skills/skill-creator/LICENSE.txt Adds license text for the bundled skill.
agentscope-examples/quickstart/src/main/java/io/agentscope/examples/quickstart/AgentSkillExample.java Updates the example to load/use the skill-creator skill and enable code execution tools.
agentscope-core/src/test/java/io/agentscope/core/tool/coding/ShellCommandToolTest.java Adds tests for new ShellCommandTool getters and baseDir behavior.
agentscope-core/src/test/java/io/agentscope/core/skill/SkillBoxTest.java Updates/extends tests for new SkillBox code execution builder and upload behavior.
agentscope-core/src/test/java/io/agentscope/core/skill/AgentSkillTest.java Updates tests to match new AgentSkill resource-path APIs.
agentscope-core/src/main/java/io/agentscope/core/tool/coding/ShellCommandTool.java Adds getters needed to clone ShellCommandTool configuration.
agentscope-core/src/main/java/io/agentscope/core/skill/SkillFileFilter.java Introduces a filter interface for deciding which skill resources get uploaded.
agentscope-core/src/main/java/io/agentscope/core/skill/SkillBox.java Implements code execution builder, upload directory handling, filtering, base64 decoding, and auto-upload.
agentscope-core/src/main/java/io/agentscope/core/skill/AgentSkillPromptProvider.java Allows custom prompt instruction/template and adds code execution guidance text.
agentscope-core/src/main/java/io/agentscope/core/skill/AgentSkill.java Adds resource path/content accessors and removes script-only filtering.
agentscope-core/src/main/java/io/agentscope/core/ReActAgent.java Updates agent skill integration to upload skill files when auto-upload is enabled.
Comments suppressed due to low confidence (1)

agentscope-core/src/main/java/io/agentscope/core/skill/SkillBox.java:1151

  • When code execution is enabled without an explicit workDir, workDirStr is null and ReadFileTool/WriteFileTool are constructed without a baseDir restriction. In the current ReadFileTool/WriteFileTool implementation, a null baseDir means no filesystem restriction, which defeats the sandbox and allows reading/writing arbitrary paths. Consider creating a temporary workDir during enable() (not lazily) and always passing that directory to shell/read/write tools, or otherwise ensuring baseDir is never null for these tools.
            String workDirStr = skillBox.workDir != null ? skillBox.workDir.toString() : null;

            boolean shellEnabled = false;

            // Shell Tool - check if withShell() was called
            if (withShellCalled) {
                ShellCommandTool shellTool;
                if (customShellTool != null) {
                    // Clone custom tool with workDir override
                    shellTool = cloneShellToolWithWorkDir(customShellTool, workDirStr);
                } else {
                    // Create default shell tool
                    shellTool =
                            new ShellCommandTool(
                                    workDirStr,
                                    Set.of("python", "python3", "node", "nodejs"),
                                    null);
                }
                skillBox.toolkit
                        .registration()
                        .agentTool(shellTool)
                        .group("skill_code_execution_tool_group")
                        .apply();
                shellEnabled = true;
            }

            // Read Tool
            if (enableRead) {
                ReadFileTool readTool = new ReadFileTool(workDirStr);
                skillBox.toolkit
                        .registration()
                        .tool(readTool)
                        .group("skill_code_execution_tool_group")
                        .apply();
            }

            // Write Tool
            if (enableWrite) {
                WriteFileTool writeTool = new WriteFileTool(workDirStr);
                skillBox.toolkit
                        .registration()
                        .tool(writeTool)
                        .group("skill_code_execution_tool_group")
                        .apply();

Comment on lines +787 to +790
public void uploadSkillFiles() {
Path targetDir = ensureUploadDirExists();
SkillFileFilter filter = fileFilter != null ? fileFilter : SkillFileFilter.acceptAll();
int fileCount = 0;
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uploadSkillFiles() calls ensureUploadDirExists() up-front, which can create a temp workDir + register a shutdown hook even if there are no skills/resources (or everything is filtered out). To avoid unnecessary filesystem side effects, consider lazily creating the upload directory only when you’re about to write the first accepted resource.

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +48
private static final String SKILL_NAME = "skill-creator";
private static final String RESOURCES_DIR =
"agentscope-examples/quickstart/src/main/resources/skills";
private static final String OUTPUT_DIR = "agentscope-examples/quickstart/target/skill-output";
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example hard-codes paths assuming the repo layout (agentscope-examples/quickstart/src/main/resources/...). That will break when running from a different working directory or from a packaged artifact. Consider resolving the skills directory via classpath (e.g., JarSkillRepositoryAdapter) or at least making the base path configurable via args/env.

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +71
ShellCommandTool shellCommandTool =
new ShellCommandTool(
Set.of("python", "ls", "cat"),
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example shell whitelist includes Unix-only commands (ls, cat), so it will fail on Windows. If this example is intended to be cross-platform, consider using OS-conditional allowed commands (e.g., dir/type on Windows) or document that it’s Unix-only.

Suggested change
ShellCommandTool shellCommandTool =
new ShellCommandTool(
Set.of("python", "ls", "cat"),
String osName = System.getProperty("os.name").toLowerCase();
Set<String> allowedCommands =
osName.contains("win")
? Set.of("python", "dir", "type")
: Set.of("python", "ls", "cat");
ShellCommandTool shellCommandTool =
new ShellCommandTool(
allowedCommands,

Copilot uses AI. Check for mistakes.
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.

1 participant