Skip to main content

Overview

The Agent-Centric Tools module provides tools that route file operations and code intelligence through LSP (Language Server Protocol) and ACP (Agent Communication Protocol), making the Agent the central orchestrator for all actions. This ensures:
  • Plan → Approve → Apply → Verify flow for file modifications
  • LSP-powered code intelligence with fallback to regex
  • Full action tracking via ACP sessions
  • Multi-agent safe operations with proper attribution

Installation

The agent-centric tools are included in the praisonai package:
pip install praisonai

Quick Start

import asyncio
from praisonai.cli.features import (
    create_agent_centric_tools,
    InteractiveRuntime,
    RuntimeConfig
)
from praisonaiagents import Agent

async def main():
    # 1. Create runtime with ACP enabled
    config = RuntimeConfig(
        workspace="./my_project",
        lsp_enabled=True,
        acp_enabled=True,
        approval_mode="auto"  # or "manual" or "scoped"
    )
    runtime = InteractiveRuntime(config)
    await runtime.start()
    
    # 2. Create agent-centric tools
    tools = create_agent_centric_tools(runtime)
    
    # 3. Create Agent with LSP/ACP-powered tools
    agent = Agent(
        name="FileAgent",
        instructions="You help create and manage files. Use acp_create_file to create files.",
        tools=tools,
        verbose=True
    )
    
    # 4. Agent will use ACP for file operations
    result = agent.start("Create a Python file called hello.py with a hello function")
    print(result)
    
    await runtime.stop()

asyncio.run(main())

Available Tools

ACP-Powered File Tools

ToolDescriptionRisk Level
acp_create_fileCreate file with plan/approve/apply/verifyMedium
acp_edit_fileEdit file with ACP trackingMedium
acp_delete_fileDelete file (requires approval)High
acp_execute_commandExecute shell command with trackingHigh

LSP-Powered Code Intelligence

ToolDescriptionFallback
lsp_list_symbolsList symbols in fileRegex extraction
lsp_find_definitionFind symbol definitionGrep search
lsp_find_referencesFind symbol referencesGrep search
lsp_get_diagnosticsGet errors/warningsN/A

Read-Only Tools

ToolDescription
read_fileRead file content
list_filesList directory contents

Tool Details

acp_create_file

Creates a file through the ACP orchestration pipeline:
def acp_create_file(filepath: str, content: str) -> str:
    """
    Create a file through ACP with plan/approve/apply/verify flow.
    
    Args:
        filepath: Path to the file to create (relative to workspace)
        content: Content to write to the file
        
    Returns:
        JSON string with result including plan status and verification
    """
Example Response:
{
  "success": true,
  "file_created": "hello.py",
  "plan_id": "plan_1767198057_1",
  "status": "verified",
  "verified": true
}

lsp_list_symbols

Lists all symbols in a file using LSP (with regex fallback):
def lsp_list_symbols(file_path: str) -> str:
    """
    List all symbols (functions, classes, methods) in a file using LSP.
    
    Falls back to regex-based extraction if LSP is unavailable.
    
    Args:
        file_path: Path to the file to analyze
        
    Returns:
        JSON string with list of symbols and their locations
    """
Example Response:
{
  "intent": "list_symbols",
  "success": true,
  "lsp_used": false,
  "fallback_used": true,
  "data": [
    {"name": "hello", "kind": "function", "line": 1},
    {"name": "MyClass", "kind": "class", "line": 10}
  ],
  "citations": [{"file": "hello.py", "type": "symbols", "count": 2}]
}

Approval Modes

The approval_mode parameter controls how file modifications are approved:
ModeBehavior
manualAll modifications require explicit approval
autoAll modifications are auto-approved
scopedSafe operations auto-approved, dangerous require approval
config = RuntimeConfig(
    workspace="./project",
    acp_enabled=True,
    approval_mode="scoped"  # Auto-approve safe, manual for dangerous
)

Architecture

User Prompt


┌─────────────────────────────────────────────────────────────┐
│  Agent (CENTRAL ORCHESTRATOR)                               │
│                                                             │
│  Tools powered by LSP/ACP:                                 │
│  ├── acp_create_file() → ActionOrchestrator                │
│  ├── acp_edit_file() → ActionOrchestrator                  │
│  ├── lsp_list_symbols() → CodeIntelligenceRouter           │
│  └── lsp_find_definition() → CodeIntelligenceRouter        │
└─────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────┐
│  ActionOrchestrator                                         │
│  Plan → Approve → Apply → Verify                           │
└─────────────────────────────────────────────────────────────┘


File Operations (with ACP tracking + verification)

Operational Notes

Performance

  • All imports are lazy-loaded
  • LSP client starts only when lsp_enabled=True
  • ACP session is lightweight (in-process)

Dependencies

  • praisonaiagents - Core agent functionality
  • pylsp (optional) - For LSP code intelligence

Production Caveats

  • LSP requires language server to be installed (e.g., pylsp for Python)
  • If LSP unavailable, falls back to regex-based symbol extraction
  • ACP tracking is in-memory; use external storage for persistence