BV
Bala Santosh Velchicherla Cloud & Applications Engineer
Architecture Blueprint // 01

Autonomous Local AI Agent: Private Tool Calling & Telegram Bot Automation via Llama 3.1

Architect: Bala Santosh Velchicherla Runtime: Meta Llama 3.1 8B (Q4_K_M) Hardware: Intel Iris Xe (16GB RAM) Privacy: 100% Local / Zero Egress

1. Executive Architectural Summary

Enterprise adoption of generative AI typically faces three fundamental barriers: data sovereignty/privacy risks, unpredictable cloud API token expenses, and complex client interfaces.

This prototype demonstrates an end-to-end autonomous edge architecture where a conversational trigger dispatched from a handheld mobile client (Telegram Bot) passes through a local gateway (AnythingLLM), reaches a locally hosted quantized model (Meta Llama 3.1 8B Instruct hosted on LM Studio), and executes autonomous actions (such as sending an email via the Gmail API) with complete privacy and zero commercial API bills.

100% Private
Zero prompt leakage to third-party cloud LLM providers
€0.00 / mo
Runs entirely on consumer silicon with no subscription fees
Autonomous
Native function calling and multi-step tool execution

2. Verified System Output & Production Telemetry

The composite verification below proves simultaneous execution across LM Studio's local inference runtime (Intel Iris Xe shared memory), AnythingLLM agent workflow, mobile Telegram client, and verified delivery inside Google Gmail:

Architecture proof of local Llama 3.1 agent execution with Telegram bot and Gmail API dispatch
Host: 192.168.1.203:1234 Model: Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf GPU Backend: DirectML (Intel Iris Xe)

3. Hardware Profile & Memory Allocation

Running modern 8-billion parameter models traditionally demands expensive discrete graphics cards (NVIDIA RTX with >12GB VRAM). In this deployment, the workload runs entirely on integrated consumer hardware by leveraging unified RAM architecture and GGUF quantization:

Component Configuration Operational Role
Processor / GPU Intel(R) Iris(R) Xe Graphics DirectML matrix calculation & KV-cache computation
System RAM 16.0 GB DDR4 / LPDDR4x Unified shared memory pool (Model weights + OS buffer)
Model Quantization Q4_K_M (4-bit medium) Reduces footprint from ~16GB (FP16) down to ~4.92GB with minimal perplexity degradation
Inference Throughput ~14.5 to 18.2 tokens/sec Comfortable real-time conversational streaming and tool parsing

4. Step-by-Step Architecture Pipeline

Phase 01 // Ingress Trigger Telegram Bot API

Mobile Handshake via @San2boxer_bot

The operator sends natural language text via the Telegram mobile client:

"Send a new email to bsvelchicherla@gmail.com saying lets catch up for padal tomorrow evening"

The Telegram Bot Gateway forwards the payload via webhooks to the local AnythingLLM daemon.

Phase 02 // Agent Orchestration AnythingLLM Runtime

Intent Classification & Tool Schema Injection

AnythingLLM acts as the agentic middleware. It loads the system prompt, attaches available function signatures (e.g. gmail-send-email), and constructs the prompt context for the local engine.

Phase 03 // Local Inference LM Studio (:1234 REST API)

Structured JSON Tool Call Generation

Hosted locally at http://192.168.1.203:1234/v1, Meta Llama 3.1 8B analyzes the request and produces an execution call instead of plain conversation:

// LM Studio Tool Call Response
{ "name": "gmail-send-email", "arguments": { "recipient": "bsvelchicherla@gmail.com", "subject": "Catch up for padel tomorrow evening", "body": "Hi Bala, lets catch up for padal tomorrow evening!" } }
Phase 04 // Action Execution Google Gmail API

Autonomous Dispatch & Notification

The agent runtime intercepts the JSON response, calls the authorized Gmail API credentials, and dispatches the email. The recipient's smartphone receives an instant push notification, and the bot confirms completion to the user on Telegram.

5. Enterprise Security & Guardrail Considerations

Zero-Trust AI Guardrails

  • Local Isolation: LM Studio runs strictly on a local non-routable subnet (192.168.1.0/24), barring any unsolicited inbound external traffic.
  • Least-Privilege Scoping: OAuth tokens for Google Gmail API are restricted exclusively to https://www.googleapis.com/auth/gmail.send with zero inbox-reading capabilities, preventing data exposure.
  • Prompt Injection Mitigation: Strict system prompt delimitation prevents external attackers from hijacking the tool execution payload via indirect context poisoning.