Files
langchain4j--langchain4j/docs/docs/integrations/code-execution-engines/local.md
T
wehub-resource-sync a2578d7ff1
snapshot_release / snapshot_release (push) Has been cancelled
Documentation: build and deploy / deploy (push) Has been cancelled
langchain4j-github-bot.yml lint / langchain4j-github-bot.yml validation (push) Has been cancelled
Java CI / compile_and_unit_test (17) (push) Has been cancelled
Java CI / compile_and_unit_test (21) (push) Has been cancelled
Java CI / compile_and_unit_test (25) (push) Has been cancelled
Split Package Detection / check-split-packages (push) Has been cancelled
Java CI / integration_test (21) (push) Has been cancelled
Java CI / compliance (push) Has been cancelled
Java CI / spotless (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:38:45 +08:00

2.8 KiB

sidebar_position
sidebar_position
4

Local

CommandLineExecutionEngine uses the local computer env to execute provided command line code. There are CommandLineTool and LocalScriptExecutionTool two implemented tools, that can be useful for Desktop Automation or Computer-Use Agents (such as File Management, Application Control). You can control your computer using natural language, something like:

  • set my mac output volume 50
  • list all running applications in my mac
  • tell a story and then read it out loud
  • tell a story about moon and save it into a text file
  • ...

:::danger ⚠️ Security Warning: High-Risk Code Execution

Attention! It might be dangerous to execute the code in a production online serving environment. It needs to be executed through security sandbox environment if used in online serving.

Do NOT use in production environments! :::

Maven Dependency

<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-community-code-execution-engine-local</artifactId>
    <version>${latest version here}</version>
</dependency>

APIs

  • CommandLineExecutionEngine
  • CommandLineTool
  • LocalScriptExecutionTool

Examples

        LocalScriptExecutionTool tool = new LocalScriptExecutionTool();

        Assistant assistant = AiServices.builder(Assistant.class)
                .chatModel(model)
                .tools(tool)
                .chatMemory(MessageWindowChatMemory.withMaxMessages(10))
                .build();

        String answer = assistant.chat("list all running applications in my mac");
        System.out.println(answer);