What you’ll build
An AI agent graph is a visual workflow that defines the steps an agent takes and what happens after each step succeeds or fails. In Panolayer, you build it by connecting cards in Graph Builder.
You’ll first run a script graph that prints Hello, world! Then you’ll create a graph that answers questions about your repository, test its failure route, and save steps you can reuse. We’ll use the Twitter example’s saved-posts feature for the agent task.
| Term | Meaning in this guide |
|---|---|
| Graph | The complete workflow: its steps and the routes between them. |
| Node or step | A card that does work, such as asking an agent or running a program. |
| Route or connection | The path to follow after a step’s result. |
| Loop | A path that returns to an earlier step to repeat work, with a limit and an exit. |
| Agent harness | The surrounding system that gives an agent instructions, tools, context, and controls for running its work. Your graph defines the workflow within Panolayer’s execution environment. |
For an overview of the editor, see How Graph Builder works.
Before you start
- Install and set up Panolayer, sign in, and open a repository.
- To follow the saved-posts example exactly, choose Twitter Clone under Try a sample app on Panolayer’s opening screen. It opens as twitter-starter.
- If you use your own repository, replace the example’s filenames and goal with a feature you want to understand.
The first exercise uses only a script. The later agent step uses Panolayer’s model access to read and explain code.
Run a working graph first
-
Open Graph Builder from the sidebar.
Open Graph Builder to create a graph or start from an editable example. -
Under Starter graphs, choose Hello world script. It opens an editable graph with Start → Say hello → Done, plus a failure route to Failed.
One script step is enough to learn how a graph starts, follows a result, and ends. -
Give the graph a name and choose Save. Return to Graph Builder, open its menu, and choose Run graph.
-
Send a short goal such as “Run the hello-world example.” Inspect the Say hello step’s output. You should see Hello, world! and the run should finish at Done.
A successful script exits with code 0, follows the green route, and reaches Done.
You now have a saved graph you can run again. Next, add an agent that can answer a question about your code.
Create an agent step for your repository
-
Return to Graph Builder and choose New Graph. The starter already connects My custom task and Print message between Start, Done, and Failed.
New Graph gives you a connected agent-and-script workflow to customize. -
Select My custom task. Set its Title to Explain saved posts and its Agent classification to researcher. Keep the starter’s read-only permission for this exercise.
-
In Custom instructions, describe the work and the answer you want. Use this example, then type @ after “Request:” and select Goal to insert the goal supplied with each run.
Read the repository code relevant to the request.
Explain the behavior using the actual files and function names.
Identify the functions involved and how they depend on each other.
Point out any asynchronous behavior the reader should inspect.
Do not modify files. If the code does not establish something, say so.
Request:
The Goal chip lets the same saved graph handle different questions. Keep the reusable instructions in the step; supply the specific question when you run it.
Configure a script step
-
Select Print message. Set Program to
echo, enterAll done!in Arguments, and set Success exit code to0.The script runs after the agent step succeeds. Its exit code determines the next route. -
Put each argument on its own line. The program runs directly, without a shell; enter the program and arguments in their separate fields.
This step gives you a visible end-of-workflow message. The agent’s explanation remains in the agent step’s output. Printing All done! confirms that the script ran; review the explanation itself to judge whether it answers your question.
Connect success and failure routes
The starter is already wired. Check that the routes express what you want:
| From | Result | Next step |
|---|---|---|
| Start | Begin | Explain saved posts |
| Explain saved posts | Success | Print message |
| Print message | Success | Done |
| Either working step | Failure | Failed |
To change a route:
-
Select an existing connection and press Delete if you need to remove it.
-
Drag from a step’s green port to the step that should run after success.
Connect the success route to the next step, and give failures an explicit destination. -
Drag from its red port to the failure handler, such as Failed.
Keeping a failure route visible makes the workflow easier to reason about: if the agent cannot complete the request or the program fails, you can see where the run goes.
Save, run, and inspect the answer
- Name the graph Saved posts explainer and choose Save. If validation identifies a step that needs attention, select that step and correct its settings.
- Return to Graph Builder, open the saved graph’s menu, and choose Run graph.
- Send this goal:
Explain how Clear all works in components/SavedPosts.tsx.
Follow clearAll and clearSaved. Describe when the bookmark requests
finish and when the saved-post list is cleared. Do not change code.
Follow the steps as they run. When the graph finishes, inspect the agent’s output and compare it with the source:
- Does it identify
clearAllandclearSavedincomponents/SavedPosts.tsx? - Does it explain how the caller depends on the helper finishing?
- Does it support its explanation with the code, rather than assume what the feature does?
Your output depends on the version of the sample and the current source. For a closer look at these functions, use Explore architecture and dependencies.
Try another goal with the same graph, such as “Explain how an individual saved post is removed.” You can reuse the workflow without rewriting its instructions.
Test the failure path
Use the Hello world script graph you saved earlier to check how a failed step is handled, without depending on a model response.
- Edit that graph and select Say hello. Temporarily change Success exit code from
0to1, leavingechoand its arguments unchanged. - Save and run it again.
echonormally returns0, so the result no longer matches the configured success code. The step should follow its red route to Failed. - Restore Success exit code to
0, save, and run once more. It should reach Done again.
You’ve now exercised both outcomes. A graph that saves has passed its configuration checks; running it shows how it behaves with actual inputs, tools, and model responses.
Reuse steps in another graph
-
Select the steps you want to reuse. To select several, hold ⌘ and drag across the canvas.
-
Choose Save selection as graph and give the new graph a descriptive name.
Save a useful sequence once, then add it to another graph as a single graph step. -
Find the saved graph under Your graphs in the palette and add it to another graph.
Saving a selection creates a separate reusable graph and leaves the current graph in place. Use ordinary Save to update the graph you are editing.
For example, reuse a code-explanation step before a review step. Give each agent step a clear job and an expected output, and connect both its success and failure routes.
Build on it and ship it as an agent
Once your graph behaves as intended, you can package your own saved graph as an interactive agent using Create Agent. The graph defines the workflow; the agent accepts a request, runs that workflow, presents the result, and returns to the prompt for another request.
For a coding workflow, start from an editable copy of Code with Prompt in Built-in graphs. Choose Duplicate to customize and work on your copy. The built-in original remains available as a reference.
Publish to the Marketplace covers sharing your graph as an agent. Run an agent on your repository explains how to give agents work and review their results.
Questions about agent graphs, loops, and harnesses
How is an agent graph different from a prompt?
A prompt supplies instructions for a task. A graph also defines which steps run, their connections, and what follows success or failure. You can reuse the same graph with a different goal each time.
Can I combine agents and scripts in one workflow?
Yes. This tutorial combines a researcher step with a script. Add steps from the palette, configure each one, and connect their outcomes. Different agent classifications let steps take on different jobs.
How do loops fit into a graph?
A connection back to an earlier step creates repeated work, such as another attempt after a failed check. Give that route a limit and keep a path that ends the run when the limit is reached. Start with the straight-through workflow above before adding retries. An agent loop packaged from a graph also returns to a prompt after a request; that is separate from a retry inside the graph.
Am I building an agent harness?
You’re configuring the agent’s workflow within Panolayer’s harness: its instructions, steps, tools, and success and failure paths. You can develop that workflow visually, test it on your repository, and package the saved graph as an agent.
Troubleshooting your first graph
| What you see | What to check |
|---|---|
| A step needs an agent classification | Select the agent step and choose its classification in the right-hand panel. |
| A graph opens read-only | Duplicate the built-in graph to customize your own copy. |
| A script fails immediately | Check Program, one argument per line, and Success exit code. The program must be available where the step runs. |
| The agent ignores the question supplied for this run | Check that Custom instructions includes the Goal variable inserted with @. |
| A step fails but the next action is unclear | Inspect its failure route and give it an explicit handler or Failed destination. |
| The graph finishes but the answer is incomplete | Inspect the agent step’s output, refine its instructions, and run the same goal again. |
For setup or agent access problems, see Troubleshooting.