AgentLang
Uses markdown heading hierarchy as structural skeleton and numbered lists as execution steps. Friendly to non-programmers, unambiguous to agents.
Keywords
8 keywords covering all control flow:
| Keyword | Purpose | Example |
|---------|---------|---------|
| def: | Define an action | #### def: FetchData(url) |
| call | Invoke an action (local or other agent) | call FetchData: get user list |
| if | Conditional | if fails: return |
| else | Alternative branch | else: retry |
| repeat | Loop | repeat until done |
| parallel | Parallel execution | parallel: + sub-step list |
| confirm | Pause for user confirmation or input | confirm: continue? |
| return | Terminate current action and output result | return data |
Writing Rules
### [Entrypoint: agentlang]— H3 + brackets = application entry, identifies this as an AgentLang program#### def: Name— H4 +def:= action definition#### Main— H4 +Main= execution entry- Numbered lists = sequential steps
parallel:followed by-unordered list = parallel steps- Description after colon = optional intent context for the agent
Parsing Guide
Parsing rules (execute in order):
- Scan all
#### def:to build an action index - Start sequential execution from
#### Main - On
call X→ resolve as "execute X", no distinction between local def and external agent (unified model) - On
call X: descriptionorcall X("arg"): description→ description serves as execution context - On
parallel:→ execute child-list items concurrently - On
confirm→ pause execution, wait for user response; if user declines, terminate current flow - Natural language in steps → agent interprets and executes autonomously
- Parameters: inferred from context by default; explicit passing uses
Name(arg0, arg1)form
Structure Recognition
| Markdown Element | Semantics |
|-----------------|-----------|
| ### [Entrypoint: agentlang] | Application entry, identifies an AgentLang program |
| #### def: Name | Action definition start |
| #### def: Name(args) | Action definition with parameters |
| #### Main | Execution entry |
| 1. 2. 3. numbered list | Sequential steps |
| - unordered list (under parallel:) | Parallel steps |
Execution Model
- Steps execute in numbered order unless
parallel:is encountered callis the sole invocation mechanism, handling both local actions and external agents uniformlyconfirmpauses execution flow, waits for user response; user decline terminates current flowif/elseprovide branching, agent decides based on runtime staterepeatcreates loops, requires termination condition (until, attempt limit)returnterminates current action, outputs result to caller- Each step's return value is implicitly passed to the next step (unless explicitly specified)
Example
[Entrypoint: agentlang]
def: ParseSkill(source)
- scan source for
### [Entrypoint: agentlang]to identify skill boundary - scan all
#### def:headings to build action index - locate
#### Mainas execution entry - return parsed skill structure
def: ExecuteStep(step)
- if step starts with
call: resolve target action and execute it - if step starts with
confirm: pause and wait for user response; if declined, terminate flow - if step starts with
parallel:: execute child list items concurrently - if step starts with
if: evaluate condition and branch - if step starts with
repeat: loop until termination condition met - else: interpret natural language and execute
Main
- call ParseSkill: parse the given AgentLang source document
- read the first step from Main block
- repeat until all steps are processed:
- call ExecuteStep: execute current step
- if step returns error: return error
- advance to next step
- return final result
Scan to join WeChat group