Studio: capture and read your own session
Learning objectives
Explain the loop behind one real coding-agent session (LO1). Keep what you observed separate from what you infer, and change your decision when verification gives you new evidence (LO9). This studio gives you material for A1, due this week.
Work individually. A peer or the instructor may question one of your citations, but the task, the capture and the explanation stay your own. Bring the coding agent the course provides, two terminals and an editor you can use with the keyboard. All records and checks are plain text. Use the safety practices in Tools and model access.
Minimal example
The course team wrote this task. The candidate below looks right and handles status strings without extra spaces. Generate: propose a whitespace repair based on the written requirement. Verify: first run the unchanged check, which shows the missing behavior. Then run it again after the candidate changes. Keep both results.
Hands-on exercise
Prepare a fresh draft directory
Run these ordinary commands from the root of your course checkout. They create only public files made up for this task. The task needs no installation and no third-party sign-in.
mkdir week01-studio
cat > week01-studio/status_label.py <<'PY'
def status_label(raw):
return {"ok": "passed", "fail": "failed"}.get(raw.lower(), "unknown")
PY
cat > week01-studio/check_status.py <<'PY'
from status_label import status_label
cases = [("ok", "passed"), (" OK ", "passed"),
("\tfAiL\n", "failed"), ("cancelled", "unknown")]
for raw, expected in cases:
assert status_label(raw) == expected, (raw, expected, status_label(raw))
print("PASS: four status cases")
PY
python3 week01-studio/check_status.py
Expected baseline: a nonzero exit and an assertion that names " OK ", with
expected passed and actual unknown. This is the forced failure that your agent
session must keep. You do not need to make the model fail in some unpredictable way.
Keep a copy of the two files as they are now, outside the directory the agent will work in:
mkdir week01-studio-before
cp week01-studio/*.py week01-studio-before/
Capture one real session
Before you launch the agent in week01-studio, write down your predictions:
- the first tool it will use;
- what the failed check will return;
- what recovery you expect;
- what ends the loop;
- how many model requests the agent will send; and
- which request, tool call or stop condition you expect to be easy to misread.
A1 asks for the last two. Start the agent in week01-studio, not in the root of the
checkout. The checkout must already be inside your dedicated course directory or
container. That place holds no employer or cloud credentials. Never put a key in a
prompt, repository, screenshot or recording.
Record the requests the agent sends, not only what it shows on screen. Open a second
terminal at the root of your course checkout. Check the course recorder, then start
it. Replace https://api.example.com with your agent's usual API base URL, which you
find in its documentation:
python3 practice/a1/recorder.py selfcheck
python3 practice/a1/recorder.py record --upstream https://api.example.com --log-dir ../a1-capture
The self-check prints six PASS lines. If any line says FAIL, stop and ask for help.
The recorder listens on 127.0.0.1 only. It passes requests and replies through
unchanged and writes no headers. In the bodies, it replaces strings that look like
keys with [REDACTED]. Until you have checked its log, treat it like a file that
holds credentials (setup). Change
the agent's base-URL setting to http://127.0.0.1:8765, the address the recorder
prints. Then start the agent with the seat or credit you were given. The A1 page
explains each step. If you cannot point the agent at the recorder, use the
A1 fallback and
write down why.
Keep the visible session as well. Use the agent's session export or its visible transcript feature. Before you begin, check that you can save the record. Give the agent this task:
Work only in this draft directory. For string statuses, ignore surrounding whitespace and ASCII letter case; map ok to passed, fail to failed and everything else to unknown. First run python3 check_status.py and retain its failing output. Repair status_label.py without changing check_status.py. Run the same check again, then explain what you changed and what the result covers.
Read each proposed command before you approve it. Keep the baseline failure inside
the capture, with its command, exit status and output. The recorder prints one line
per exchange, such as #1 POST /v1/... -> 200. If no such line appears after the
agent has replied, the agent is not using the recorder. When the agent stops, press
Ctrl+C in the recorder's terminal and remove the base-URL setting. Export the session
in its supported format to a private directory of your own. The full export stays
there, outside week01-studio and outside what you hand in. A1 takes only the
excerpt or redacted transcript that your report cites. If the agent cannot export,
copy the visible messages in order into session.txt. Keep the role labels and the
call/result identifiers when they are shown. Record the agent's name and version, the
date and the task. Leave credentials and private data out of any excerpt you submit.
Read and revise
| Studio segment | Action | Evidence |
|---|---|---|
| Opening | Prepare files and save predictions before generation | Task and unchanged prediction |
| Capture | Agent runs the failing check, repairs, checks again, through the recorder | Capture log, original session and both results |
| Dissection | Count requests, system text and tools; read calls and results | Capture summary and the table below with citations |
| Verification checkpoint | Run the check yourself and inspect the changed file | Current result and bounded diff |
| Revision | Peer or instructor challenges one citation; revise it | Corrected claim and decision line |
Ask for help as soon as the seat, the recording or the first check is blocked. If it is still blocked halfway through the session, switch to the text participation exercise. Mark the evidence from the real run as missing; do not fill it in.
Make one row per recorded request or visible event:
| Location | Instruction/context visible | Tools/call arguments | Returned result | Continue or stop | Observed claim | Inference and a possible check |
|---|---|---|---|---|---|---|
Summarize the capture, using the file name the recorder printed:
python3 practice/a1/recorder.py summary ../a1-capture/capture-TIMESTAMP.jsonl
python3 practice/a1/recorder.py summary ../a1-capture/capture-TIMESTAMP.jsonl --request 1
The first command gives one row per exchange. The rows for requests with messages are the model requests. The second command gives the size of the system text and the list of tools for one request. Choose the request that carries your task. The summary prints no message text. To read the system text and each tool's description, open the log in your editor. Then group the tools by kind with the table on the A1 page. Count requests separately from tool calls, because one request can carry several calls. Then:
- match each result to its call;
- inspect how the agent recovered after the forced failure;
- find the request that carried the failure back to the model; and
- find the check that supports the final message.
If you used a fallback, say which parts of the request were not visible. A published prompt file does not prove that your session sent that prompt.
Practice with the read-only viewer and the supplied hand-authored record:
python3 lectures/week-02/session/show_session.py \
lectures/week-02/session/sample-session.jsonl --request 4
You can read an agent's own export directly as text. Use the viewer on your export only if the export is in one of the viewer's supported formats (course-session or course-trajectory). Do not invent a header or make up hidden request fields to make another format fit.
Verification
From the root of your course checkout, verify the candidate in the actual studio directory:
python3 week01-studio/check_status.py
Expected after repair: zero exit and PASS: four status cases. A passing
result covers these four cases only. It does not prove the function is right for all
strings or callers.
Then compare both files with the copies you kept before the agent started:
diff week01-studio-before/check_status.py week01-studio/check_status.py
diff -u week01-studio-before/status_label.py week01-studio/status_label.py
Expected: the first command prints nothing, so the check file is unchanged. The
second shows what changed in the candidate. Removed lines are marked - and added
lines are marked +. That output is your bounded diff: it shows only the change to
the candidate file. diff exits with status 1 when the files differ. Use the diff to
confirm that the candidate only normalizes the input before the lookup.
For the separate live-loop exercise, use the completed draft controller:
python3 week01-loop/verify_loop.py
The original lectures/week-02/fixture/loop.py is an unfinished starter. A check on
it tests neither your repaired studio candidate nor your copied controller.
From the studio to A1
A1 is one report.json plus the files it cites. They go in a submission directory
of your own, outside the course checkout. Run these two lines from the root of your
course checkout. They make that directory next to the checkout and copy the starter
into it:
mkdir ../week01-a1
cp practice/a1/starter/report.json ../week01-a1/report.json
Save the two capture summaries there. They hold counts and tool names, not message text:
python3 practice/a1/recorder.py summary ../a1-capture/capture-TIMESTAMP.jsonl > ../week01-a1/capture-summary.txt
python3 practice/a1/recorder.py summary ../a1-capture/capture-TIMESTAMP.jsonl --request 1 >> ../week01-a1/capture-summary.txt
In the second line, use the request number you chose. In week01-a1, put only the
plain-text files that the report cites:
- the capture summary;
- your redacted session excerpt;
- the baseline failing output;
- the output of your own passing rerun; and
- your prediction, as you first wrote it.
The capture log stays in ../a1-capture. The check accepts only paths inside
week01-a1. You do not need any unrelated session history. Leave assignment and
session_kind as supplied, and fill in the other fields:
Field in report.json |
What goes in it |
|---|---|
agent |
The agent's name, version and visible configuration |
capture |
method is recorder, or the fallback you used with its reason; requests is the summary's count of requests with messages; system_prompt_chars and the tools total come from the request you chose, and by_kind is your grouping; evidence holds the ID of capture-summary.txt |
evidence |
One row per file: an id, its path relative to week01-a1 (for example session-excerpt.txt) and, as observation, what the file shows |
behaviours |
One entry per Observed claim and one per Inference from your table: the claim as behaviour, a label of observed or inferred, and as evidence a list holding the ID of the excerpt that shows it |
forced_failure |
The baseline run: intervention is the padded case that was in check_status.py before the agent started, evidence a list holding the ID of the failing output, recovery_or_stop what the agent did next |
explanation |
Your short explanation, with who challenged a citation, the date and what you corrected; if nobody could, your self-review date |
ai_use_note |
Your one AI-use note, or its ID |
decision |
action is exactly one of accept, narrow, recheck, stop; because is a list of evidence IDs; next names the next check |
Then run the public check from the root of your course checkout:
python3 practice/a1/check.py ../week01-a1
Until the record is complete, it prints one RECHECK: line for each missing item
and exits with status 1. When nothing is missing, it prints
PASS: record is internally consistent; inspect the evidence yourself. and exits
with status 0. The check reads only the shape of the record, not whether the content
is right. The A1 page has the task, the criteria and
an outline of the whole record. If it lists a field that this table does not, follow
the A1 page.
Common mistakes
| Mistake | How to notice it | Correction |
|---|---|---|
| Only saving the successful run | No forced failure in the session | Capture the baseline before repair |
| Checking the wrong directory | Command targets the original fixture | Check the candidate you actually changed |
| Claiming hidden instructions were seen | Fallback record omits system messages | State the visibility limit |
| Counting every exchange as a model request | Summary rows without messages | Count requests with messages only |
| Handing in the capture log | Log file or screenshot of it in the submission | Cite the summary and checked excerpts; keep the log private |
| Citing a final claim as a tool result | No command, call ID or result at the citation | Find the corresponding observation |
| Letting the agent weaken the check | Check file changed | Restore it, inspect the candidate and rerun |
| Relabelling an inference as observed | Citation does not contain the claim | Change the label or obtain another observation |
Text participation
If you cannot capture a session, dissect the sample with the same table. Its header
says course-made-sample. It is practice evidence, not your real agent session.
Predict how the agent recovers after the failed edit, reveal the next request, and
revise your explanation. Complete the real capture later through supported access.
If an observation is missing, record it as missing; do not invent it.