Run your first agent
This guide starts the daemon, gives one agent a small task in a git repository, and reads the result. It takes about one minute and costs about one US cent.
You need: jcode and ztcl (Install), AWS credentials for Bedrock, and Linux for the level process.
1. Start the daemon
Run the daemon in the background, with its output in a log file:
jcode serve > jcode.log 2>&1 &
cat jcode.log
jcode 0.1.0: http://localhost:7717/ state /home/you/.local/state/jcode
one-time code for the first passkey: 78986f0ca2
The code is for the web page (Sign in with a passkey). The command line uses the token file of the state folder and needs no code.
2. Make a work folder
The agent works in one folder. A git repository lets you see its changes:
mkdir hello && cd hello && git init -q -b main
printf '#!/bin/sh\n# Prints a greeting.\necho "hello"\n' > hello.sh
chmod +x hello.sh
git add . && git commit -qm init
cd ..
3. Write the brief
The brief is the task, in a text file:
printf 'Change hello.sh so that it takes a name as its first argument and prints "hello, NAME". With no argument it prints "hello, world". Run it to check both cases, then finish with a short report.\n' > brief.md
4. Start the agent
jcode start --dir hello --model us.amazon.ergo-1.0 --brief brief.md --isolation process --run all
a1
start prints the id of the agent. --run all gives the agent the run tool with a shell. --isolation process keeps each command in a sandbox: it can change only the work folder, and it has no network.
5. Wait and read
jcode wait a1 --timeout 300
jcode read a1
a1 done process turns 5/40 tokens 4730 (in3429 out266 cr0 cw1035) us.amazon.ergo-1.0 /home/you/hello | the agent gave its report
1 brief: Change hello.sh so that it takes a name as its first argument and prints "hello, NAME". With no argument it prints "hello, world". Run it to check both cases, …
2 tool: list_files {"path":"."}
3 result: ok: hello.sh
4 tool: read_file {"path":"hello.sh"}
5 result: ok: #!/bin/sh # Prints a greeting. echo "hello"
6 tool: write_file {"path":"hello.sh","content":"#!/bin/sh\n# Prints a greeting.\nif [ -n \"$1\" ]; then\n echo \"hello, $1\"\nelse\n echo \"hello, world\"\nfi\n…
7 result: ok: wrote 105 characters to hello.sh
8 tool: run {"command":"sh hello.sh Alice; sh hello.sh"}
9 result: ok: exit 0 hello, Alice hello, world
10 report: Updated hello.sh to greet the first argument: `sh hello.sh Alice` prints "hello, Alice", and `sh hello.sh` (no argument) prints "hello, world". Both cases veri…
Each line is one entry of the transcript: its number, its kind, and its text, cut to one line. read a1 --full prints the full text.
6. See the changes and the cost
jcode diff a1
jcode cost a1
-echo "hello"
+if [ -n "$1" ]; then
+ echo "hello, $1"
+else
+ echo "hello, world"
+fi
| Item | Tokens | USD |
|---|---:|---:|
| input | 3429 | 0.0038 |
| output | 266 | 0.0009 |
| cache read | 0 | 0.0000 |
| cache write | 1035 | 0.0014 |
| **Total** | | **0.0061** |
The agent changed the files of the work folder, and it made no commit. Read the diff, then commit the change yourself.
7. Open the web page
Open http://localhost:7717/. The page asks for the one-time code of step 1, and then adds a passkey (Sign in with a passkey).