Skip to Content
Agentlang is open source now!
Agents

Agents

In Agentlang, an agent is more than just a script or a program — it’s an intelligent, autonomous “assistant” that understands your goals and takes action on your behalf. Picture this: your HR department is drowning in a sea of resumes from job applicants. Sorting through them all is tedious, repetitive, and time-consuming. With Agentlang, you can create an agent that automatically reviews each resume, categorizing them into “selected” (promising candidates worth a closer look) or “rejected” (those that don’t meet your criteria). The agent handles this initial triage tirelessly and at scale, freeing your HR team to focus on the human side of hiring — the interviews, the conversations, the decisions that matter most.

In the sections that follow, you’ll learn how to design and deploy such an agent using Agentlang’s declarative constructs. You’ll see how natural language instructions can work hand-in-hand with structured domain models to create systems that are not only intelligent, but also precise, consistent, and remarkably reliable.

Initialize the project

The first step is to initialize an Agentlang project using the al init command. Let’s call this project simply as hr:

agent init hr cd hr

Add a module that contains an agent

After this open the src/core.al file and update it as shown below:

src/core.al
module hr.core @public agent resumeReview { role "You are an agent that reviews resumes", directives [{"if": "the candidate is a software engineer with more than 10 years experience", "then": "return 'selected'"}, {"if": "the candidate is not an experienced software engineer", "then": "return 'rejected'"}] }

Agentlang programs are organized as “modules”. Here we have a module called hr that contains a single agent - resumeReview. What we expect the agent to do is clearly stated in its instruction.

Test your agent

Make sure you have these two environment variables set:

export OPENAI_API_KEY=<your_openai_api_key>

Now you can run the agent using the following command:

agent run

You can test the agent with the following POST request:

curl -X POST http://localhost:8080/hr.core/resumeReview \ -H 'Content-Type: application/json' \ -d '{"message": "name: Jake, languages: Python;Rust, years of experience: 20"}'

The agent should respond with the string "selected". Try a few other resumes and see if the agent is able to classify them as expected.

Increase reliability with Agentic Reliability Modeling

Coordinating Agents with Flows

Real-world scenarios often involve complex, multi-step business processes, where several actions must occur in sequence or depend on one another. Agentlang makes it easy to model and coordinate such processes through Agentic Flows — declarative definitions that describe how AI agents should collaborate to achieve a goal.

At runtime, the Agentlang engine interprets a Flow as a guiding framework rather than a rigid script, allowing agents to operate autonomously while still following an overall process structure.

Here’s a quick glimpse of what a Flow looks like:

resumeReview --> "selected" checkCurrentInterviewSchedule checkCurrentInterviewSchedule --> scheduleInterview

We’ll learn more about this when we revisit agents.

Improving Attention

You can help an agent remain focused on the task at hand by supplying additional context through directives, examples, and other guidance. These unique Agentlang features can significantly enhance an agent’s reliability and consistency. The resumeReview agent already makes use of directives. The following example demonstrates how the agent can be made even more dependable by leveraging some other capabilities.

@public agent resumeReview { role "You are an agent that reviews resumes", directives [{"if": "the candidate is a software engineer with more than 10 years experience", "then": "return 'selected'"}, {"if": "the candidate is not an experienced software engineer", "then": "return 'rejected'"}] scenarios [{"user": "Software engineering manager with 25 years experience", "ai": "rejected"}, {"user": "C++ programmer with 2 years experience", "ai": "rejected"}, {"user": "C++ programmer with 12 years experience", "ai": "selected"}], glossary [{"name": "developer", "meaning": "software engineer", "synonyms": "programmer"}] }

Here we have enhanced the agent with scenarios and glossary.

Directives instruct the agent on how to behave under various circumstances. They are expressed concisely in the form of if-then clauses.

Scenarios provide the agent with a few examples that it can consult while analysing the user input. They are provided in the form of user-input and expected AI response.

Glossary helps the agent to make sense of domain-specific vocabulary.

What we have designed here is a reliable agent that can deal with textual input. Agentlang agents are more powerful in the sense that they can work in the context of complex business domains expressed declaratively. Before we explore that aspect of agents, let’s get familiar with the declarative modeling language that lies at the core of Agentlang.

Last updated on