How to Paste Error Messages When Asking GLM About Code

2026-11-15 · Prompt Optimization

For the same error, some people paste just "it's broken, how do I fix it," while others paste the complete stack trace and environment details. The former takes three or four rounds of back-and-forth; the latter often gets a working fix in one. GLM-5's coding ability is solid, but it can only see what you paste—how you share the error directly determines the quality of the answer. Here's a set of practices you can apply right away.

1. Paste the Whole Error, Not Just the Last Line

Many people copy only the last line, like TypeError: cannot read property 'x' of undefined. But the real clues are usually in the stack trace: which line triggered it, and which of your own functions the call chain passed through. The right move is to paste from the first line to the last, including the full stack—Traceback (most recent call last) or the at ... frames. Wrap it in a code block (triple backticks) so GLM doesn't mangle line breaks and indentation.

Two other common pitfalls:

  • Text beats screenshots. Paths and line numbers often get blurry in terminal screenshots; copy plain text instead.
  • Include warnings too. Sometimes a DeprecationWarning is the early sign of the actual problem.

2. Add the "Environment Trio"

The same error can have completely different causes on Python 3.9 vs 3.12; on the browser side it depends on your framework version. Always include three things:

1. Language and version: e.g., Python 3.11.6 / Node 20.x; 2. Key dependency versions: only the libraries involved in the error, like pytorch 2.x or react 18 (check with pip show <pkg> or npm ls <pkg>); 3. Runtime environment: local Windows / Linux / macOS, Docker, or the API-calling side (if calling an API on the BigModel platform, include your request parameters).

3. Provide a Minimal Repro, Not the Whole Project

Don't dump a 500-line file. An ideal minimal repro is stripped down to the shortest code that still triggers the error—usually 10–30 lines. Mark the erroring line (most languages show line numbers; a note like "line 7 errors" works). If you can't minimize it, paste the function involved plus its call entry point, and summarize the rest in one sentence.

4. A Copy-Paste Question Template

This template covers everything above—just fill in the blanks:

I'm debugging an error in my code. Please help me find the cause and fix it.

[Environment]
- Language/version: Python 3.11 (replace with your actual version)
- Key dependencies: requests 2.31, pydantic 2.x (only list what's relevant)
- Runtime: local macOS / Docker / calling the BigModel API

[What I'm trying to do]
One sentence, e.g.: call an HTTP endpoint and parse the JSON response.

[Minimal reproducible code]

python # Error occurs on line 7 def fetch(url): r = requests.get(url) return r.json()["data"]["items"]

[Full error message]

Traceback (most recent call last): File "main.py", line 7, in fetch return r.json()["data"]["items"] KeyError: 'items'

[What I've tried]
1. Printed r.json() and confirmed the response has no items field.

Please: 1) explain the cause; 2) provide fixed code; 3) if multiple causes are possible, rank them by likelihood.

That last "rank by likelihood" line matters—it pushes GLM to lay out its reasoning instead of handing you a single guess.

5. Follow-Ups and an API / Agent Scenario Template

If the first round doesn't solve it, don't start a new topic—add fresh clues in the same conversation. When the error comes from calling a GLM-series API, or from an agent / tool-calling setup, use this template:

I hit an error while calling a GLM-series API. Please help me analyze it.

[Request info]
- Model name: <the model you actually used; refer to the official docs' model list>
- How: HTTP / official SDK (specify the language)
- Request payload:

json { "model": "<your model name>", "messages": [{"role": "user", "content": "hello"}], "tools": <remove this line if unused> }

[Full response]

<Paste the HTTP status code and response body verbatim, including error code and message>

Please: 1) determine whether it's a parameter issue, an auth issue, or a server-side issue; 2) provide a corrected request example.

Note: for details like model names and parameter formats, defer to the official BigModel documentation—don't guess if you're unsure.

With these two template cards, giving "full error + environment + minimal repro + what you've tried" in one shot, GLM can usually deliver a workable fix in a single round—saving far more time in back-and-forth than it takes to organize the information.

本文为使用方法整理,内容选自网上公开资料,供参考;本站为非官方资讯站,产品能力以官方页面为准。