Skip to main content
IntentLang
← All examples

ResearchAgentRun

examples/ResearchAgentRun.intent

ResearchAgentRun.intent
1# ResearchAgentRun.intent
2# Domain: AI agent workflow. An autonomous, tool-using agent needs guardrails as
3# explicit as its goal: bounded steps, a spend budget, no irreversible action
4# without approval, and cited answers. The control policy runs as a decision.
5
6mission ResearchAgentRun
7use product
8
9title "Run a tool-using research agent within hard guardrails"
10for AgentOperator
11
12note pm:
13 The agent is useful only if it stops, asks, or escalates before it does harm.
14
15goal
16 Let an agent answer a research task by calling tools, while staying inside its
17 step, budget, and safety limits.
18
19why
20 An unbounded agent loops forever, overspends, or takes irreversible actions no
21 one approved. The guardrails are the product, not an afterthought.
22
23requires
24 ResearchTask
25 ToolAllowlist
26
27input
28 task: ResearchTask
29 stepsTaken: Count
30 spendUsd: Money
31 budgetUsd: Money
32 actionIsIrreversible: Flag
33 humanApproved: Flag
34
35output
36 answer: GroundedAnswer
37
38guarantee every claim in the answer cites a retrieved source
39 because an uncited agent answer is indistinguishable from a hallucination
40 verify citation coverage test
41
42guarantee the agent halts at its step and budget limits
43 because an unbounded loop is how agents overspend and hang
44 verify budget and step limit test
45
46never
47 take an irreversible action without human approval
48 call a tool outside the allowlist
49 exceed the spend budget
50
51never take an irreversible action without human approval
52 because a delete, a payment, or a send cannot be undone by a retry
53 verify approval gate test
54
55never call a tool outside the allowlist
56 because the allowlist is the agent's entire authority boundary
57 verify tool allowlist test
58
59never exceed the spend budget
60 because runaway token or API cost is a direct financial loss
61 verify budget and step limit test
62
63# The agent control loop, one deterministic step decision. `intent run` / `intent test`.
64decision AgentNextAction
65 inputs
66 stepsTaken
67 maxSteps
68 spendUsd
69 budgetUsd
70 actionIsIrreversible
71 humanApproved
72 rule overBudget
73 when spendUsd >= budgetUsd
74 return Halt
75 rule outOfSteps
76 when stepsTaken >= maxSteps
77 return Halt
78 rule needsApproval
79 when actionIsIrreversible == true and humanApproved == false
80 return Escalate
81 default
82 return Continue
83
84target
85 TypeScript
86 Tests
87
88test AgentNextAction
89 case within limits keeps going
90 given stepsTaken 3, maxSteps 20, spendUsd 0.4, budgetUsd 5, actionIsIrreversible false, humanApproved false
91 expect Continue
92 case over budget halts
93 given stepsTaken 3, maxSteps 20, spendUsd 5, budgetUsd 5, actionIsIrreversible false, humanApproved false
94 expect Halt
95 case out of steps halts
96 given stepsTaken 20, maxSteps 20, spendUsd 1, budgetUsd 5, actionIsIrreversible false, humanApproved false
97 expect Halt
98 case irreversible action without approval escalates
99 given stepsTaken 3, maxSteps 20, spendUsd 1, budgetUsd 5, actionIsIrreversible true, humanApproved false
100 expect Escalate
101 case irreversible action with approval proceeds
102 given stepsTaken 3, maxSteps 20, spendUsd 1, budgetUsd 5, actionIsIrreversible true, humanApproved true
103 expect Continue
Draft syntax. This file is illustrative and does not run yet.