LLM Applications in Practice: Coding Assistance, RAG, and AI Agents
As LLM usage grows, development teams need to focus on applications with clear business value. This article explains how to implement AI coding assistance, RAG-based enterprise knowledge search, and agent-driven workflows, with practical guidance on API integration, retrieval evaluation, data privacy, and execution safeguards.
Recent data published by several AI platforms indicates a clear increase in large language model (LLM) usage. Reporting periods and measurement methods vary, so this article does not cite growth multiples that cannot be verified.
Rising usage suggests that LLMs are becoming part of everyday business workflows. For developers and enterprise engineering teams, the priority is to identify frequently used applications that deliver real business value. Three relatively mature approaches stand out: coding assistance, enterprise knowledge question answering with RAG, and agent-driven workflow orchestration.
1. Implementing AI Coding Assistance
Software developers spend considerable time writing boilerplate, creating unit tests, reviewing code, and consulting documentation. LLMs can handle some of this repetitive work, allowing developers to focus on business logic and system design.
Where to Start
Integrating a model through an IDE extension or a CI/CD pipeline enables context-aware code completion, code comment generation, refactoring suggestions, and unit test generation.
These tasks have well-defined inputs and outputs that are relatively easy to verify, making them suitable for initial pilots. After writing a core business function, for example, a developer can ask the model to generate tests for edge cases, then review and run the proposed tests.
Code Example
The following example uses an LLM API to generate unit tests for a Python function. It includes timeouts, retry backoff, HTTP status checks, and response-format validation as a starting point for integration.
import osimport timeimport requestsAPI_URL = os.getenv("LLM_API_URL", "https://api.example-llm.com/v1/chat/completions")API_KEY = os.getenv("LLM_API_KEY") # Read from the environment; do not hard-code secretsdef call_llm(prompt, max_retries=3, timeout=30):if not API_KEY:raise RuntimeError("The LLM_API_KEY environment variable is not set")headers = {"Content-Type": "application/json","Authorization": f"Bearer {API_KEY}",}payload = {"model": "general-llm-v1","messages": [{"role": "user", "content": prompt}],"temperature": 0.2, # Lower temperature for more consistent output}for attempt in range(1, max_retries + 1):try:resp = requests.post(API_URL, headers=headers, json=payload, timeout=timeout)except (requests.Timeout, requests.ConnectionError):if attempt == max_retries:raisetime.sleep(2 ** attempt)continue# Retry rate limits and server errors; raise other errors immediatelyif resp.status_code in (429, 500, 502, 503, 504):if attempt == max_retries:resp.raise_for_status()time.sleep(2 ** attempt)continueresp.raise_for_status()try:return resp.json()["choices"][0]["message"]["content"]except (KeyError, IndexError, ValueError) as e:raise RuntimeError(f"Unexpected response format: {resp.text[:200]}") from edef generate_unit_tests(function_code):prompt = ("Write comprehensive unit tests for the following Python function ""using the unittest framework. Cover normal inputs, edge cases, ""and exceptions:\n\n" + function_code)return call_llm(prompt)target_code = """def calculate_discount(price, discount_rate):if discount_rate < 0 or discount_rate > 1:raise ValueError("Invalid discount rate")return price * (1 - discount_rate)"""if __name__ == "__main__":print(generate_unit_tests(target_code))
The API endpoint and model name in this example are placeholders.
Review and Data Handling
Model-generated tests should not be merged directly into the main branch. Teams need to run them, verify that their assertions reflect actual business rules, and check that they do not depend on external environments.
Generated code may also contain sensitive information. Before sending source code to an external model service, review the company’s data classification policies to determine what may be shared.
2. Building Enterprise Knowledge Q&A with RAG
General-purpose models have limited knowledge of private enterprise data and specialized industry information. As a result, they may hallucinate or provide irrelevant answers. Direct fine-tuning can be costly, and incorporating updated knowledge may require further training.
Retrieval-Augmented Generation (RAG) takes a different approach: retrieve relevant material from an enterprise knowledge base first, then ask the model to answer using that material. When the knowledge changes, the index can be updated without modifying the model itself.
The Two Stages of RAG
- Offline indexing: Parse documents such as PDF, Word, and HTML files, clean the extracted text, and split it into chunks. Use an embedding model to convert the chunks into vectors, then store them in a vector database. Original files can be kept in object storage, while embedding jobs are processed asynchronously through a message queue to support retries and scaling.
- Online retrieval: Convert the user’s question into a vector and retrieve the top-K most relevant text chunks from the database. Combine those chunks with the question in a prompt, then send it to the model to generate an answer.
Key Parameters to Tune
- Chunk size: A common starting range is 300–800 characters, with 10%–20% overlap between adjacent chunks to reduce the chance of splitting important sentences. These character-based ranges reflect the original Chinese-language context; evaluate their suitability for your corpus.
- Embedding model: Choose models with strong evaluation results for the language of your documents. For Chinese-language corpora, prioritize models evaluated on Chinese text, and compare candidates using your own business questions.
- Top-K: Start by testing values from 3 to 8. Too few results may omit the answer; too many can introduce noise and increase token costs.
- Reranking: Apply a ranking model after retrieval to reorder the candidates. This can often improve the relevance of the highest-ranked results.
Evaluating Quality
Create a labeled evaluation set containing tens to hundreds of question-answer pairs, and identify the correct document passages for each question.
Use Recall@K to measure whether retrieval finds the relevant content. Then use human reviewers or model-based scoring to assess whether the final answer is faithful to the retrieved material.
Rerun the evaluation set whenever you change chunking, the embedding model, or Top-K.
Data Privacy Boundaries
RAG does not, by itself, guarantee that data stays within your organization’s environment. When an external model service is used, retrieved text chunks are sent to the provider as part of the prompt. Those chunks may contain customer information or internal policies.
Common safeguards include:
- Masking sensitive fields.
- Using data classification rules to determine which content may be sent to external models.
- Choosing a private deployment or dedicated instance.
- Signing data processing agreements.
- Keeping API call audit logs.
3. Orchestrating Business Workflows with AI Agents
While the first two applications primarily generate text, agents can invoke external systems to perform actions.
Developers provide tool definitions to the model, typically using JSON Schema to describe each tool’s function and parameters. Given a user instruction, the model selects a tool and returns its name and arguments. The business application performs the actual execution, then sends the result back to the model for a natural-language response.
Typical Use Cases
- Intelligent operations: When a monitoring alert fires, an agent retrieves logs and invokes diagnostic scripts. Within explicitly authorized limits, it may also scale resources or isolate a failed node.
- Customer support and ticketing: An agent checks an order’s status. If it cannot resolve the issue directly, it calls a ticketing API to create a ticket and assign it to the appropriate owner.
Core Principle: Treat Model Output as Untrusted
Tool names and arguments returned by a model are proposals, not executable instructions. The business application must validate them before taking action.
Never concatenate model output directly into SQL statements, shell commands, or HTTP requests.
Predeployment Checklist
- Tool allowlist: Expose only necessary tools, and give each tool separate credentials with the minimum required permissions.
- Argument validation: Validate types and ranges against the JSON Schema, then apply business rules such as transaction limits and permitted resource scopes.
- Execution limits: Cap the number of tool-call rounds per task and set an overall timeout to prevent loops.
- Idempotency and retries: Attach idempotency keys to write operations so retries do not create duplicate orders or tickets.
- Human confirmation: Require explicit human approval for irreversible actions such as deleting data, transferring funds, changing permissions, or deploying to production.
- Sandboxing and isolation: Run tools that execute code or manipulate files in isolated environments.
- Audit logs: Record each model request, tool-call arguments, execution result, and responsible operator to support traceability and incident reviews.
Conclusion
Growing LLM usage reflects the increasing adoption of coding assistance, RAG-based knowledge Q&A, and agent-driven workflow orchestration.
Coding assistance is generally the lowest-risk starting point and is well suited to pilot projects. RAG is useful for enterprise knowledge retrieval, but retrieval quality and the handling of data sent outside the organization need to be addressed first. Agents offer the greatest potential benefit among these three approaches, but also carry the highest risk. Permission controls and human approval requirements should be designed before workflow features are built.
When selecting a cloud platform, focus on compute stability, inference latency, vector retrieval capabilities, and compliance certifications. Validate these capabilities with your own business data rather than relying solely on advertised metrics.
