use-case

Choosing and calling coding models

Direct answerSelect coding models by patch correctness, test pass rate, tool success, latency, and cost on real repositories, not marketplace copy or a single benchmark.

Updated · Reviewed

Define the coding task first

Completion, single-file Q&A, repository changes, debugging, and long-running agents are different workloads. Define visible files, tools, languages, test commands, execution time, and network permission before selecting a model with the required context and tools.

  1. Supply only the code and constraints needed for the task.
  2. Ask the model to locate evidence before proposing a minimal patch.
  3. Run formatters, static checks, and tests in isolation.
  4. Feed failures back with bounded loops and token budgets.
  5. Require human review for security, migrations, and irreversible operations.

API shape

Simple generation can use Chat Completions or Responses. File search, shell, and editing require structured tool calls with validated arguments. A model proposing a command does not grant execution authority; enforce path, timeout, and network boundaries in the tool layer.

Evaluation

Build a fixed set from real defects and track patch application, test pass rate, first-pass success, retries, latency, and total cost. Safe refusal and recognition of incomplete requirements are correct outcomes.

Common failures

Context pollution, test leakage, dependency mismatch, and blind trust in generated code are often more important than model choice. Treat diffs, tests, and runtime evidence—not the model's completion claim—as acceptance.

Use cases

  • Completion and refactoring
  • Repository diagnosis
  • Long-running coding agents

API protocols

  • /v1/responses
  • /v1/chat/completions
  • /v1/messages

FAQ

Should coding use Chat, Responses, or tool calls?

A one-shot explanation or code draft can use the supported Chat or Responses endpoint. Reading files, editing code, or running tests should use structured tools. Protocol migration must also adapt tool results and streaming fields, not only the URL.

May I execute a shell command returned by the model directly?

No. The model only proposes an action. The tool layer must constrain the working directory, command allowlist, network, timeout, and resources, with human approval for irreversible deletion, migration, or release operations.

How should I evaluate a coding model beyond whether its code looks plausible?

Use real repository defects and track patch application, test pass rate, first-pass success, tool failures, retries, latency, and total cost. Safe refusal and detection of incomplete requirements are also correct outcomes.

Should I upload the entire repository and secret files for more context?

No. Provide only files and dependency facts needed for the task and exclude secrets, production data, and unrelated directories. Repository agents still need least privilege, isolated execution, and bounded loops to prevent leakage and runaway token use.

Official sources

  1. OpenAI Models Official
  2. Claude Models Official