Read back what an agent ran¶
Draft: not yet validated
The AI assistant that drafted this tutorial ran steps 1 to 3 in MESA JupyterLab on 2026-11-19 (OpenCode 1.19.4), on a session it started with one command rather than in the OpenCode screen. Nobody has yet followed the page as a reader would. Tell us what you find.
While an agent works, its tool calls scroll past. Afterwards you may need to say exactly which tools it called and on what. OpenCode keeps each conversation as a session that you can write to a file.
You will: have a file with one agent session in it, and a printed list of every tool call in that session.
Time: 5 to 10 minutes. You need: to have finished
Sign in and start an AI agent in a MESA app in this app
session. If the agent is still open, type /exit first.
Steps¶
-
In the terminal, list the sessions:
opencode session listYou should see: a table with the columns
Session ID,TitleandUpdated, and one row for each conversation. An ID starts withses_. The agent wrote the title itself. -
Export the session to a file. Put your own ID in place of
ses_...:opencode export ses_... > ~/work/agent-run.jsonYou should see:
Exporting session:and the ID. The fileagent-run.jsonis now in theworkfolder. -
Print the tool calls. Paste all seven lines at once and press Enter:
python3 - <<'PY' import json run = json.load(open("/home/jovyan/work/agent-run.json")) for message in run["messages"]: for part in message["parts"]: if part["type"] == "tool": print(part["tool"], part["state"]["status"], part["state"]["input"]) PYYou should see: one line for each call, in the order they were made. For the question in the earlier tutorial, the run that was checked printed:
mesa_ds_list_allowed_directories completed {} mesa_ds_list_directory completed {'path': '/iplant/home/gctest01'}Your path has your own username, and your agent may have taken another route.
-
Read each line as three facts: the tool, whether it finished, and what it was given.
You should see: no line you cannot account for. A tool whose name has
write,deleteormovein it would mean the agent changed something.
Check it worked¶
The printed lines match the calls you saw on screen while the agent worked, and every folder or file the agent's answer mentions appears in the input of some line. An answer that names something no call touched did not come from your data.
If it didn't¶
The table in step 1 is empty. Sessions do not outlive the app. Run the agent again in this app session, then list again.
Step 3 prints nothing. The agent answered without calling a tool. That is worth knowing: see How an agent reaches data: tools and MCP.
KeyError in step 3. The file's layout differs from OpenCode 1.19.4, which this
page was written against. Tell us.
Next¶
- Keep a log of AI-assisted steps: the printed lines are the evidence for a row's "What it answered".
- The export holds everything the agent read, word for word. Treat it like the data
itself before you share it.
opencode export --sanitizereplaces the text and the inputs with placeholders and keeps the tool names. - Files in
workdo not outlive the app. To keep this one, see Save your work where it survives the session. - Reference: AI agents in the MESA apps.
Not yet validated by a person in MESA JupyterLab. Drafted with AI assistance on 2026-11-19 from the commands' own help text in the app; steps 1 to 3 were run in MESA JupyterLab that day.
Machine-readable versions of this page: Markdown twin · raw source on GitHub · llms.txt · llms-full.txt (whole site). See For AI agents.