Phantom Tools follow the same interface as regular tools but instead of automatic execution, they return the tool call details to your application — giving you full control over when and how the tool is executed.
What are Phantom Tools?
When the LLM calls a regular tool, LarAgent automatically executes it and feeds the result back to the LLM. Phantom Tools break this cycle — they return the tool call details to your application, allowing you to:- Handle execution externally (different service, API, etc.)
- Request user confirmation before proceeding
- Expose tool calls through your own API
- Queue execution for background processing
Creating Phantom Tools
At Runtime
In Agent Class
Define phantom tools in theregisterTools() method:
Handling Phantom Tool Calls
When the LLM decides to call a phantom tool, the agent returns an array withtool_calls instead of a text response (or ToolCallMessage when using ->returnMessage()):
Multiple Phantom Tool Calls
When parallel tool calls are enabled, the LLM may request multiple phantom tools at once:Use Cases
Phantom Tools where created to support user provided external tools while exposing Agents via API, but they can be useful in many scenarios
External Services
Hand off execution to external APIs or microservices that require special authentication or handling.
User Confirmation
Pause for user approval before executing sensitive or irreversible actions.
API Exposure
Make tool calls available through your API for frontend or mobile app handling.
Async Processing
Queue tool execution for background processing with job queues.
User Confirmation Example
Background Processing Example
Mixing Regular and Phantom Tools
You can use both regular and phantom tools in the same agent:Using returnMessage() for Type-Safe Access
For more control, usereturnMessage() to get a ToolCallMessage instance instead of an array:
Phantom Tool Properties
Phantom tools support the same property definitions as regular tools:With Enum Constraints
Next Steps
Tool Configuration
Configure tool choice, parallel execution, and runtime management.
Attribute Tools
Create tools using the #[Tool] attribute.
Tool Classes & Inline
Build reusable tool classes or create tools dynamically.
Responses
Learn about handling agent responses.

