AWorld icon indicating copy to clipboard operation
AWorld copied to clipboard

Local tool example could be improved to be more instructive.

Open luxunxiansheng opened this issue 1 year ago • 4 comments

From my understanding, Actions are infered from policy and can be categorized into tools. A tool may have several actions .

Here are some subtle relationships between actions and tools.

But the example code makes me confused (at least for beginners).

If i understand correctly, a file tool with read, write , create or delete action could be better.



class HelloworldAction(ToolAction):
    HELLO_WORLD = ToolActionInfo(
        name="hello_world",
        input_params={
            "goal": ParamInfo(
                name="goal",
                type="str",
                required=True,
                desc="hello world."
            ),
        },
        desc="hello world.")


@ActionFactory.register(name=HelloworldAction.HELLO_WORLD.value.name,
                        desc=HelloworldAction.HELLO_WORLD.value.desc,
                        tool_name="hello_world")
class ExecuteAction(ExecutableAction):
    """Only one action, define it, implemented can be omitted. Act in tool."""
    async def async_act(self, action: ActionModel, **kwargs) -> Tuple[ActionResult, Any]:
        return ActionResult(content="hello world!", keep=True, is_done=True), None


# asyn is True means the tool name is `async_hello_world`
@ToolFactory.register(name="hello_world", desc="hello world tool", asyn=True, supported_action=HelloworldAction)
class HelloWorldTool(TemplateTool):
    """Hello world tool."""

Thanks for your time.

luxunxiansheng avatar Nov 24 '25 09:11 luxunxiansheng

I am really confused by the examples.


if mcp_available and FastMCP:
    # Create a simple MCP server
    app = FastMCP("GorillaFileSystem")

    @app.tool()
    def pwd() -> str:
        """Get current working directory"""
        return current_dir

    @app.tool()
    def ls() -> list:
        """List directory contents"""
        try:
            return os.listdir(current_dir)
        except Exception as e:
            return [f"Error: {e}"]

"pwd" , "ls" and other commands actually are actions ? right ? The mcp file server is regarded as tool ?

luxunxiansheng avatar Nov 24 '25 09:11 luxunxiansheng

"pwd" , "ls" and other commands actually are actions ? right ? The mcp file server is regarded as tool ?

Yes, the GorillaFileSystem MCP server is a tool, and its internal functions can be analogized to the Action of this tool.

rainsonGain avatar Nov 25 '25 01:11 rainsonGain

If i understand correctly, a file tool with read, write , create or delete action could be better.

Yeah, we will improve this example by using more practical examples.

rainsonGain avatar Nov 25 '25 01:11 rainsonGain

@luxunxiansheng @rainsonGain I completely agree with this feedback! I had similar confusion when first learning agent frameworks.

The Core Concept (how I understand it):

  • Tool = A capability container (like a toolbox)
  • Action = A specific operation the tool can perform (like a specific wrench in the toolbox)

So yes, GorillaFileSystem is the Tool, and pwd, ls are Actions within that tool.

Suggested Example Structure for better clarity:

class FileToolAction(ToolAction):
    """Define all possible actions for the file tool"""
    READ = ToolActionInfo(
        name="read",
        input_params={
            "path": ParamInfo(name="path", type="str", required=True, desc="File path to read")
        },
        desc="Read content from a file"
    )
    WRITE = ToolActionInfo(
        name="write",
        input_params={
            "path": ParamInfo(name="path", type="str", required=True),
            "content": ParamInfo(name="content", type="str", required=True)
        },
        desc="Write content to a file"
    )
    LIST = ToolActionInfo(
        name="list",
        input_params={
            "dir": ParamInfo(name="dir", type="str", required=False, desc="Directory to list")
        },
        desc="List files in directory"
    )

@ToolFactory.register(
    name="file_system",
    desc="File system operations tool",
    supported_action=FileToolAction
)
class FileSystemTool(TemplateTool):
    """A practical file system tool with multiple actions"""
    pass

Educational Progression that might help beginners:

  1. Step 1: Single-action tool (simplest)
  2. Step 2: Multi-action tool (like the file example above)
  3. Step 3: MCP-integrated tool (real-world scenario)

I've been working on similar educational examples in my agent-examples repo - focusing on common multi-agent patterns like HITL workflows, context handoff, and goal-driven coordination. It might serve as a complementary reference for designing progressive learning examples.

The key insight for beginners is: Tool = What you CAN do, Action = What you CHOOSE to do.

Hope this helps! 🚀

Lumi-artLife avatar Feb 10 '26 22:02 Lumi-artLife