Step 2 ยท How to use your agent

~10 min
1 Setup 2 Hello 3 Data 4 Analyze 5 CNN 6 Think

First, unlearn one habit

You don't have to click, type, or run everything yourself. Stop being your own hands.

The agent has tools โ€” it can read files, write code, run commands, and fetch web pages on your computer. You just describe what you want. "I need to open the file, read it, then write a script..." โ†’ "Analyze this dataset and plot it."

What the agent can do for you

๐Ÿ“ Read & search filesopen files, grep your data, inspect folders
e.g. "what keys are in this npz?"
โœ๏ธ Write & edit codecreate scripts, fix bugs, refactor
e.g. "write a training script"
โ–ถ๏ธ Run commandsexecute python, install packages, test
e.g. "run it and show me the output"
๐Ÿ–ผ Show you resultsopen figures, explain plots
e.g. "show me the histogram"
๐ŸŒ Fetch web pagescheck docs, download data
e.g. "get the download link"
๐Ÿ’ฌ Iterate with youtake feedback, redo work
e.g. "make it faster" / "I expected X"

How it works โ€” the loop

Two loops, one idea. Left: how you work with the agent. Right: the geophysical inversion you already know. They are the same loop.

โ‘  AI agent workflow

โ†บ
YOU โ€” write the prompt
the model parameters
โ–ผ the agent works
AGENT
plans โ†’ calls tools โ†’ runs
โ–ผ result
RESULT
code ยท figures ยท numbers
โ–ผ you check
YOU judge
is this what I wanted?
bad โ†’ feedback
good โ†’ done โœ“

โ‘ก Geophysical inversion

โ†บ
model parameters m
= your prompt
โ–ผ forward modeling
dpred = G(m)
= the agent
โ–ผ predicted data
dpred
= agent's result
โ–ผ compare with observed
misfit โ€–dobs โˆ’ dpredโ€–
= you, the loss function
misfit โ†’ update m
converged โ†’ done โœ“

You are the loss function. The agent is the forward model. It proposes, you evaluate (loss), and your feedback updates the "model" โ€” the prompt โ€” until the result converges.

Try it

Run these two prompts one after another, inside opencode:

Create a file hello.py that prints "Hello from my AI agent!" and the current date. Then run it and show me the output.
Create a folder called exploration. Write a script that generates 1000 random numbers, plots a histogram, and saves it as exploration/histogram.png. Run it and show me the figure.

Handy keys & commands

Key / commandWhat it does
Type your prompt, then EnterThe agent starts working (watch it call tools!)
EscInterrupt the agent (it runs too long / wrong direction)
@filenameAttach a file to your prompt ("look at @data.npz")
/modelsSwitch the model
/helpList all commands
/undoRevert the last change it made
Prompt tip: context (what the data is) + task (what to do) + constraints (format, limits). Precise prompts give precise code โ€” you will see this in Steps 4โ€“5.