AI Coding Assistants in Practice: Generation Speed, and Choosing Between Cloud and Local Deployment

    This article walks through a real disk-cleanup scenario to show how to evaluate an AI coding assistant. It covers three key metrics (time to first token, generation throughput, and instruction following), a reusable prompt with a corrected Python disk-analysis script, common cloud API problems with a troubleshooting checklist, the costs and benefits of local deployment, and a practical hybrid selection framework for choosing between cloud and local models.

    1. Why Generation Speed and Stability Matter

    When developers use an AI coding assistant, the most immediate impressions come from two things: how long the model takes before it starts producing code, and how smooth the output is once it starts. Some models perform extensive internal reasoning before answering, so the first token arrives slowly. Some cloud services see throughput drop during peak hours, causing choppy streaming output or even mid-stream disconnections.

    Three metrics tell you whether a coding assistant works well:

    • Time to first token (TTFT): the time from sending a request to receiving the first token.
    • Generation throughput: how many tokens the model outputs per second.
    • Instruction following: whether the model delivers exactly what the prompt asks for.

    For a well-defined task like “write a disk analysis script,” the ideal result is runnable code returned directly, not a preamble of “let me think about this.”

    This article uses a real disk-cleanup scenario to illustrate these issues, and provides a reusable prompt, corrected code, a comparison of cloud and local deployment, and troubleshooting steps.

    2. Generating a Disk Analysis Script with a One-Sentence Prompt

    2.1 How to Write the Prompt

    An effective prompt usually contains three parts: the goal, the constraints, and the output format. Here is an example:

    1. Write a Python script that scans all subdirectories and files under a given directory, sorts them by disk usage from largest to smallest, prints the top 20 entries, and shows sizes in human-readable units (KB, MB, GB). Skip directories without read permission and report them, without stopping.

    This prompt includes the goal (find the largest entries), the constraints (sort order, skip errors), and the output format (top 20, readable units). Compared with just writing “help me find large files,” it leaves the model less to guess and reduces the number of follow-up revisions.

    2.2 Generated Result and Its Limitations

    In testing, a fast-responding model produced a complete script quickly with no extra explanation. However, reviewing the code revealed that the initial version only counted subdirectories of the current directory and ignored regular files in the current directory itself. It also did not handle permission errors or symbolic links, so hitting an unreadable directory would raise an exception and stop the run.

    This shows that generated code that runs does not necessarily satisfy the prompt. The prompt said “all subdirectories and files,” so the code should cover exactly that. Users need to check the output against each requirement instead of accepting it just because it executes.

    2.3 The Corrected Script

    The following version adds file counting, exception handling, and does not follow symbolic links, avoiding circular references and scanning content outside the target directory.

    1. import os
    2. import sys
    3. def human_size(num_bytes):
    4. for unit in ["B", "KB", "MB", "GB"]:
    5. if num_bytes < 1024:
    6. return f"{num_bytes:.2f} {unit}"
    7. num_bytes /= 1024
    8. return f"{num_bytes:.2f} TB"
    9. def dir_size(path, errors):
    10. total = 0
    11. try:
    12. with os.scandir(path) as it:
    13. for entry in it:
    14. try:
    15. if entry.is_symlink():
    16. continue
    17. if entry.is_file(follow_symlinks=False):
    18. total += entry.stat(follow_symlinks=False).st_size
    19. elif entry.is_dir(follow_symlinks=False):
    20. total += dir_size(entry.path, errors)
    21. except OSError as e:
    22. errors.append((entry.path, str(e)))
    23. except OSError as e:
    24. errors.append((path, str(e)))
    25. return total
    26. def main(root=".", top_n=20):
    27. errors = []
    28. items = []
    29. try:
    30. with os.scandir(root) as it:
    31. for entry in it:
    32. try:
    33. if entry.is_symlink():
    34. continue
    35. if entry.is_dir(follow_symlinks=False):
    36. size = dir_size(entry.path, errors)
    37. is_dir = True
    38. elif entry.is_file(follow_symlinks=False):
    39. size = entry.stat(follow_symlinks=False).st_size
    40. is_dir = False
    41. else:
    42. continue
    43. items.append((entry.name, size, is_dir))
    44. except OSError as e:
    45. errors.append((entry.path, str(e)))
    46. except OSError as e:
    47. print(f"Cannot read directory {root}: {e}")
    48. return
    49. items.sort(key=lambda x: x[1], reverse=True)
    50. print(f"{'Name':40} {'Type':6} {'Size':>12}")
    51. for name, size, is_dir in items[:top_n]:
    52. kind = "dir" if is_dir else "file"
    53. print(f"{name:40} {kind:6} {human_size(size):>12}")
    54. if errors:
    55. print(f"\n{len(errors)} entries could not be read and were skipped. First 10:")
    56. for path, msg in errors[:10]:
    57. print(f" {path}: {msg}")
    58. if __name__ == "__main__":
    59. main(sys.argv[1] if len(sys.argv) > 1 else ".")

    This version still has boundaries. It uses recursion, so extremely deep directory trees may exceed Python’s recursion limit. It also counts only apparent file size, not actual disk usage with hard links. For precise disk usage, use lower-level tools or a dedicated library.

    2.4 How to Run It

    The script uses only the Python standard library, so no third-party packages are needed. Python 3.8 or later is recommended:

    1. python3 disk_top.py /path/to/dir

    Without arguments, the script analyzes the current directory. It only reads file information and does not delete or modify anything. Before running it on a large directory, test it on a small one to confirm the output matches expectations. The code in this article was verified only in the author’s test environment; behavior on other platforms should be confirmed independently.

    2.5 Timing Observations

    The author observed that generating this simple script took about 10 seconds. This is a single observation, not a statistical result. Generation speed depends on the model, network, prompt length, and server load, so it cannot be extrapolated to other tasks. The author did not time writing the same script by hand, so no accurate speed multiplier can be given. A more useful reference is the review time after generation, because this example shows that fixing coverage and exception handling still requires manual work.

    3. Common Cloud API Problems and Troubleshooting

    Cloud APIs typically exhibit three types of problems in interactive coding:

    1. Shared resource contention. On free or low-cost tiers, or during peak usage hours, each request gets less compute, and output speed drops.
    2. Network and timeout issues. During long connections or streaming, an overloaded server may drop the connection.
    3. Quota limits. Some platforms limit throughput or request counts for non-paying users, which is easy to trigger during long sessions.

    When calling a cloud model from an IDE plugin, the author once observed output speed drop to about 30 tokens per second, with occasional disconnections. This figure comes from a single observation; results vary by model and time of day.

    When you hit similar problems, troubleshoot in this order:

    1. Record TTFT and output rate; measure about ten times in a row to observe the variance.
    2. Switch to another endpoint or region from the same provider and compare results.
    3. Enable streaming output to determine whether the server is slow or the plugin waits for the full response before displaying anything.
    4. Set a reasonable timeout and retry failed requests a limited number of times; avoid waiting indefinitely.
    5. Reduce the context you send, keeping only files and code relevant to the current task.
    6. Track failure rates. If failures cluster at certain hours, adjust your usage schedule.
    7. Prepare a fallback for critical work, such as switching to another provider or a local model.

    As a rule of thumb, TTFT under 1 second and generation above 50 tokens per second provide a good interactive experience, but these numbers are only references. Each team should run its own tests with its own network and tasks to define acceptable thresholds.

    4. The Costs and Benefits of Local Deployment

    The biggest advantage of local deployment is control. Network latency and cloud queuing do not affect local inference, and code never leaves your machine. For teams working with internal code or sensitive data, this often matters more than speed. Local models can also be fine-tuned to a team’s coding style, though fine-tuning itself requires data and maintenance effort.

    The costs are equally clear. Local models are usually weaker than flagship cloud models, especially at understanding the context of large projects. Users must manage model files, dependencies, drivers, and VRAM themselves. Model updates are manual; there is no automatic access to new versions as with cloud services.

    On hardware, a quantized 7B-parameter open-source model can run on a consumer GPU. Actual speed depends on the quantization method, context length, concurrent requests, and hardware model. CPU inference is usually much slower than GPU and suits offline tasks with relaxed latency requirements. Before buying a GPU, test the target model on real tasks rather than relying on theoretical figures from vendors or the community.

    5. A Hybrid Strategy for Cloud and Local

    Most teams do not need to choose exclusively between cloud and local. A more practical approach is to split tasks by type. The table below offers a starting framework; adjust the thresholds to your situation:

    Factor Prefer Cloud Prefer Local
    Task complexity Cross-module refactoring, architecture design Single-file scripts, simple completions
    Context length Understanding a large project Only a few files involved
    Privacy level Public or sanitizable code Core internal code, sensitive data
    Latency requirement Can tolerate a few seconds of waiting Needs immediate response
    Budget Pay-per-use works better Can afford hardware and maintenance
    Fallback strategy Switch to local when cloud is down Call cloud when local quality falls short

    With a hybrid setup, define clear triggers for switching. For example, if the local model’s generated code fails tests twice in a row, hand the task to the cloud. Conversely, if the cloud service times out or hits rate limits, temporarily use the local model for simple tasks. Written-down switching rules keep the whole team consistent instead of letting each member improvise.

    6. FAQ

    What GPU do I need to run a 7B model locally? VRAM is the key factor. A quantized 7B model uses far less VRAM than full precision, but the exact requirement depends on the quantization format and context length. Check the target model’s documentation and test on real hardware.

    How do I troubleshoot an unstable API? First determine whether the problem is the network, server-side rate limiting, or the plugin itself. Call the API directly with the same request, bypassing the plugin, and compare the results. The troubleshooting steps in Section 3 apply here as well.

    How should I choose between cloud and local? Evaluate four dimensions: task type, privacy requirements, latency requirements, and budget. If the task is complex and the code can be shared, prefer the cloud. If sensitive code is involved, or you need stable offline use, local deployment is a better fit. Combining both is usually the most pragmatic solution.

    How do I disable a model’s reasoning process? Methods vary by provider. Some models offer parameters to control reasoning depth or disable it entirely; others require a system prompt that instructs the model to output code directly. Consult the official documentation of your service, and compare outputs using the same set of prompts.

    7. Conclusion

    The value of an AI coding assistant lies in reducing the friction between an idea and working code. Write prompts that state the goal, constraints, and output format; check generated code against each requirement, without skipping coverage or exception handling. Cloud APIs suit complex tasks and large contexts; local deployment suits privacy-sensitive work and scenarios that need stable offline use. When combining both, define switching rules in advance and benchmark with your own tasks. Only then does AI become a reliable assistant rather than a burden of repeated waiting and patching.