# Imperative Workflow Engine: A Privilege-Level Instruction Encoding Scheme That Boosts LLM Agent Task Accuracy from 41% to 96%

> A privilege-level instruction encoding system based on the Routine framework, which significantly improves the execution accuracy of multi-step tasks through structured execution contracts and runtime verification mechanisms.

- 板块: [Openclaw Llm](https://www.zingnex.cn/en/forum/board/openclaw-llm)
- 发布时间: 2026-05-24T20:15:29.000Z
- 最近活动: 2026-05-24T20:21:07.103Z
- 热度: 159.9
- 关键词: LLM, agent, workflow, privilege encoding, routine framework, execution contract, runtime verification, task accuracy
- 页面链接: https://www.zingnex.cn/en/forum/thread/imperative-workflow-engine-llm-41-96
- Canonical: https://www.zingnex.cn/forum/thread/imperative-workflow-engine-llm-41-96
- Markdown 来源: floors_fallback

---

## Introduction / Main Floor: Imperative Workflow Engine: A Privilege-Level Instruction Encoding Scheme That Boosts LLM Agent Task Accuracy from 41% to 96%

A privilege-level instruction encoding system based on the Routine framework, which significantly improves the execution accuracy of multi-step tasks through structured execution contracts and runtime verification mechanisms.

## Original Author and Source

- **Original Author/Maintainer**: ether-btc
- **Source Platform**: GitHub
- **Original Title**: imperative-workflow-engine
- **Original Link**: https://github.com/ether-btc/imperative-workflow-engine
- **Publication Date**: 2026-05-24

---

## Background and Problem

Current large language models (LLMs) often have unsatisfactory accuracy when executing multi-step tasks. Studies show that the execution accuracy of complex task chains can be as low as around 41%. The root cause of this problem is that LLMs tend to deviate from the original goal or lose key constraints during execution when handling long contexts and complex instructions.

Traditional prompt engineering methods can improve output quality to some extent, but lack a systematic execution guarantee mechanism. When tasks involve multiple steps, tool calls, or need to strictly follow specific rules, the model may call tools at inappropriate times or ignore important safety constraints.

## Project Overview

Imperative Workflow Engine is an open-source project implemented based on the Routine framework (arXiv:2507.14447), aiming to solve the above problems through Privilege-Level Instruction Encoding and structured execution contracts. This project increases the execution accuracy of multi-step tasks from about 41% to about 96%, an improvement of more than twice.

The core idea of the project is to draw on the concept of privilege levels in operating systems, assigning different priorities and constraint strengths to different types of instructions. By explicitly marking the privilege level of instructions, the system can enforce these constraints at runtime to ensure that high-priority rules are not overridden by low-priority requests.

## Privilege-Level Instruction Encoding

The project defines five privilege levels, each corresponding to different types of instructions:

| Level | Label | Purpose |
|------|------|------|
| 0 | Safety rules | Safety rules, absolutely non-deviable |
| 1 | System imperatives | Core system instructions |
| 2 | Skill-loaded rules | Default rules when skills are loaded |
| 3 | User requests | Default level for user requests |
| 4 | Tool outputs | Tool output results |

This layered design ensures that the most critical safety constraints (Level 0) have the highest priority and will not be overridden under any circumstances. User requests (Level 3) can be executed flexibly without violating higher-level constraints.

## Execution Contract Decomposition

The `routine_decomposer.py` script in the project is responsible for decomposing complex tasks into Routine-style execution contracts. These contracts clearly define the input, output, preconditions, and postconditions of each step, forming a formal execution protocol.

The advantages of execution contracts are:
- **Verifiability**: The execution result of each step can be independently verified
- **Traceability**: The complete path of task execution can be recorded and audited
- **Recoverability**: When a step fails, the system can accurately locate the problem and attempt recovery

## Runtime Verification Mechanism

`contract_verifier.py` provides runtime verification functionality to ensure that the execution process strictly follows predefined contracts. This verification is not a simple result check, but continuous monitoring during execution to ensure each step meets expectations.

## Semantic Tool Filtering

`tool_filter.py` implements semantic tool filtering based on context relevance. This means the system does not blindly expose all available tools to the model, but intelligently selects the most relevant subset of tools based on the context of the current task. This filtering mechanism reduces the probability of the model selecting the wrong tool and also reduces noise in the context window.
