Using the CLI Plugin0:00
In the previous lesson we set up a small view app using Ralf, but if you're like me, you may dislike the fact that you're not seeing the model work as it's going. This is because we boot the model in print mode using the -p flag. There's an official plugin available from Entropic that adds a Ralf loop skill into the interactive CLI and you can install it from the marketplace and then run it as follows. We can say Ralf loop, Ralf loop will mention or prompt and I will say 10 iterations. And when we run the loop this way, we're just in the interactive shell so we
iterations. And when we run the loop this way, we're just in the interactive shell so we can see the model work and follow along. And if you get a permission request like we see here on screen, we can interactively allow or deny this request. And while this looks great from the surface, there's a fundamental difference between this plugin and running it via our script. The plugin by Entropic runs the loop inside the context window.
Plugin Memory Tradeoffs0:58
script. The plugin by Entropic runs the loop inside the context window. This means that between every single iteration we won't clear the context window and the agent will keep access to its memory. This also means every iteration the context window will fill up further and further and eventually we'll have to compact the context to clear up some space. This kind of goes against the original vision of Ralf where you start fresh on every iteration
This kind of goes against the original vision of Ralf where you start fresh on every iteration and externalize the memory of the model using markdown files. And that's why I rarely use the official plugin and instead rely on my own scripts. Now let's go back to the problem with our script. We see no output while the loop is running because we're in print mode. But looking for us, there's a way to tail the output of the model using the output format flag. Let me demonstrate.
Streaming Model Output1:42
output format flag. Let me demonstrate. Instead of saying cloud-p hello world, we can actually also say -output format stream JSON. And if you say stream JSON, we also have to say verbose, otherwise it'll complain. And now we'll see the messages appear as they come in. But as you can see here, it's not really human readable. So we need to improve our script and parse the JSON into human readable string. For this purpose, let's create a Node.js script that runs the loop for us and
Generating Test Messages2:07
So we need to improve our script and parse the JSON into human readable string. For this purpose, let's create a Node.js script that runs the loop for us and parses the incoming messages. Before we prompt our coding agent to create our Node.js script, let's first generate some test messages we can reference in our prompt and we can do so as follows. We'll say cloud-p for print mode, we'll say output format stream JSON, we have to say verbose. And then we'll ask the model to read the file, do a web fetch and run a command .
Prompting the Node Script2:32
And then we'll ask the model to read the file, do a web fetch and run a command . And we'll output everything to example.txt. Alright, now that we have some example messages, let's prompt our coding agent. And I prepared a small prompt we can use to create our Node.js script. The prompt is pretty simple, we'll ask the model to take a look at ralf.sh or script from the previous lesson and we'll ask it to convert it to a Node.js script that has support for the output format stream JSON verbose flags and we'll parse the JSON strings
Improved Loop Observability3:00
has support for the output format stream JSON verbose flags and we'll parse the JSON strings as they come in. Finally, we mentioned example.txt for an example of the JSON messages so the model knows what to do. Alright, if you take a look at our newly created ralf.js script, we'll see it's going to be a bit more verbose because there's a lot of JSON parsing going on. But the core of the file hasn't changed, which is still a for loop. The architecture of ralf didn't change, we just improved the observability.
But the core of the file hasn't changed, which is still a for loop. The architecture of ralf didn't change, we just improved the observability. And now if you're in Node.Ralf.js, our prompt gets loaded like before, together with our project and progress file. But this time, as you can see on screen, we can watch the model work and real time, which makes the whole loop feel more alive. In the next lesson, I'll introduce you to product requirement documents and how we can use them to transform or loop into a focused and goal-driven builder. I'll see you there
we can use them to transform or loop into a focused and goal-driven builder. I'll see you there .
