DEV Community

Cover image for Show DEV: SPL Workflow Orchestrator
Dominik Gawlik
Dominik Gawlik

Posted on Edited on

Show DEV: SPL Workflow Orchestrator

If you have worked for a while with agentic frameworks one common theme surfaces - this is a lot of complex code:

  • callback hell
  • operating on graphs
  • explicit passing of tools
  • ...

In this post I would like to propose solution that flips the script. What if

We could inline agentic flows directly in JavaScript with minimal syntax?

We could interleave natural language with code?

Enforce contraints on prompts themselves from the code?

Example worth thousand of words

Here is toy example, lets say we are - converting RGB values back and to labels. The syntax is very simple and what it's showing is SPL file. Everything is in JavaScript block for now.

Let's save it to rgb.spl file and run it.

As we can see the runtime runs the cell and returns the response. Now the other way around. We can use agentic blocks to reverse the functionality. Now the agent will give common name for RGB provided by user.

We can save to rgb2.spl and run it:

You can see it is really easy iterate on the solution, because we have both agent and JavaScript at our disposal.

How it works

The SPL runtime is a toolkit and runner in one. First it provides the shorthand function calls ask and agent that translate to OpenAI, Google GenAI and Anthropic clients.

These primitives are used in agentic blocks {agent}{/agent} to run simple control loop.

Then on the other side runtime parses Markdown files and SPL files into steps. Before anything is run, js syntax checks and tool call checks take place not to waste tokens. When the workflow is run, everything is run top to bottom. The variables are shared in global context and with help of built in tools you can easily save them from agentic blocks. Likewise anything you declare in JavaScript is automatically visible in agentic blocks.

Tracing

The tool has been built with reproducibility in mind. Any call to the LLM can be recorded with cli argument --trace. Then on subsequent runs instead of calling LLMs the pre-saved responses are supplied and everything runs deterministically. The trace is JSONL with responses and codegeneration.

Codegen Step

Cool feature is that you can ask llm to generate JavaScript code that later is visible for other steps.

Enforcing Constraints

You can run the workflows from Markdown as well. js code-fences mark the JavaScript code and blockquotes introduce agentic calls. The @ctl special annotation controls parameters of the agent.

You can see enforce/forbid annotations. These are soft guides for an agent to do or not to do something. They are compiled to plain JavaScript functions that append to prompt the instructions.

Thanks

Thanks for your time reading this. Here are some links for you:

https://dgawlik.github.io/semantic-prompt-language
https://github.com/dgawlik/semantic-prompt-language

Can I ask you a favor?

I'm looking for contributors. If you find this cool, you can contact me at dominik.gawlik1@gmail.com. Let's work on this together!

I'm trying also to get better visibility to gather feedback and Issues on Github are more than welcome. Also if you think this actually solves real problem would you consider giving it a star on Github?

That was a short writeup, let me know if I should fix something in the post itself.

Thanks!

Top comments (0)