How to see the JSON sent to the model and its answer
This guide shows how to keep, for every call to the model, the exact request mm sent and the exact response the server returned — to check a system prompt, the tool definitions, a sampling key, what another agent received, or what a model really answered. It assumes you already run mm with a configuration file.
Steps
-
Turn the trace on, for one run:
AGENT_TRACE=true mm agent.yamlor for good, in the configuration:
trace: enabled: true dir: .mm/traces # the defaultThe banner ends with
| trace: /abs/path/.mm/traceswhile it is on. -
Ask a question as usual. Each call to the model leaves a pair of files:
.mm/traces/20261007-123237.903-bob-0001.request.json .mm/traces/20261007-123237.903-bob-0001.response-200.sseOne question can make several calls: one per round trip with the tools, plus a compaction summary. The agent's
acp.nameis in each name, so an agent called throughask_agentor/ask— it inheritsAGENT_TRACE— writes its own files beside yours (…-jan-0001…). -
Read the request. It is the body exactly as sent, indented:
jq '{model, temperature, stream_options, chat_template_kwargs}' .mm/traces/*-0001.request.json jq -r '.messages[] | "\(.role): \(.content | tostring | .[0:120])"' .mm/traces/*-0001.request.json jq -r '.tools[].function.name' .mm/traces/*-0001.request.json -
Read the response. A streamed one (
.sse) is the server's lines as they came, onedata: {…}chunk each; rebuild the answer text with:grep '^data: {' .mm/traces/*-0001.response-200.sse | sed 's/^data: //' \ | jq -rj '.choices[0].delta.content // empty'; echoand its reasoning with
.choices[0].delta.reasoning_content, its tool calls with.choices[0].delta.tool_calls, its token counts with.usage(the last chunk). A response that was not streamed is a.jsonfile, indented. An error status is in the name (.response-400.json); a call that got no response at all leaves.response-error.txt. -
Turn it off when you are done: the files hold your prompts, file contents and command outputs in full.
.mm/is git-ignored in this repository; add it to your project's.gitignoretoo.
Variants
- In an editor (ACP). A relative
trace.diris in the session'scwd— the project the editor opened — not in the directory the editor launchedmmfrom. SetAGENT_TRACEin the editor's agent settings (env), ortrace.enabledin the file: the editor does not see your shell's variables. - Somewhere else.
trace.dir: /tmp/mm-tracescollects every project's calls in one place. - Only the agents you ask. Put
trace.enabled: truein that agent's own file instead of usingAGENT_TRACE. - Before the files: what mm adds. The request already carries what mm adds itself —
stream_options.include_usage,return_progressfor a llama.cpp server,chat_template_kwargs.enable_thinking: falseon a summary — so the trace is also how to check those.
See also
- The
tracekeys and the file names: configuration reference AGENT_TRACE: command-line reference- Why reasoning arrives in its own field: Thinking models
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|