Skip to content

Agents, Abilities & Functions

Expose an entry point and keep implementation inside the agent.

A public ability defines an externally callable capability. Private functions and skills organize internal implementation. A struct gives the result a named shape with explicit fields.

Complete example

Save the example as agents.aal

agents.aal
struct Report
  score: Int
  verdict: String

agent Tutorial is Agent
  private
    skill assessment
      fn verdict(score: Int) -> String effects()
        return if score >= 6 then "ready" else "revise"

  public
    ability run(score: Int) -> Report effects()
      return Report(score: score, verdict: self.assessment.verdict(score))
Download .aal

Syntax explained

  1. Call a private skill method with self.assessment.verdict(...). Its result must satisfy the declared type.

  2. Report(...) constructs a struct with named fields. A record with the same fields is not the same nominal type.

  3. effects(...) bounds allowed effects, including indirect calls. effects() excludes thinking, memory writes and external tools.

Build and run

Terminal
cargo run --locked --bin aalc -- check agents.aal

cargo run --locked --bin aalc -- build agents.aal -o agents.aalc

cargo run --locked --bin aalc -- run agents.aalc \
  --agent Tutorial --ability run \
  --args '{"score":7}' \
  --state-dir .aal-tutorial/agents --invocation agents-1

Run with a fresh state directory. The returned value is shown below; the CLI also prints execution information.

Expected result
{"score":7,"verdict":"ready"}

Try it yourself

Set score to 4 and use a new invocation ID. Report should contain score: 4 and verdict: revise.

Language source and specification