How AgentScript works: Code-based agent execution
mainUnlike traditional Re-act agents that perform iterative tool calls via LLM loops, AgentScript prompts an LLM to generate a plan expressed as a subset of JavaScript (AgentScript).
The Workflow:
- Define Runtime: Set up tools and optionally input/output variables.
- Define Task: Provide a prompt for the agent to execute.
- Code Generation: The LLM generates AgentScript code representing the execution plan.
- AST Parsing: The generated code is parsed into an Abstract Syntax Tree (AST).
- Safe Execution: The AST is executed in a dedicated, safe interpreter (not directly in Node.js). This allows for features like execution pausing, serialization for state persistence, and human-in-the-loop interactivity.