Using the Remediation Orchestrator Agent
What Are Agents?
Agents are bounded agentic loops for running workflow actions like diagnosis, fixes, validations, and evidence gathering. They are useful when a normal scripted workflow is too rigid: datacenter breakfix sees novel issues all the time, and it is not practical to codify every possible remediation branch ahead of time.
You invoke an agent from a Starlark script workflow with agent.execute(...). In the usual shape,
that call starts an agent child workflow, the script waits for the child workflow result, and then
the script routes based on the returned choice.
An agent gives a script workflow a controlled amount of fuzziness. The script decides the goal, the allowed tools, the runtime parameters, and the choices it is willing to accept. The agent then runs for a fixed timeout and a fixed number of actions. When it has enough signal, it returns a single choice and description so the script can go back to deterministic routing.
The safety model is intentionally narrow: agents run against a fixed tool list, read deterministic parameters supplied by the script, and validate generated actions before execution. The LLM chooses among declared actions; it does not get an open-ended workflow runtime.
For example, a workflow can let an agent inspect health signals, recent workflow context, and validation output, then route based on the choice:
The agent is for the fuzzy middle: deciding what to inspect next, correlating evidence, trying safe workflow actions, and selecting the next route. The surrounding script workflow still owns state transitions, retries, ticketing, and final routing.
How To Use One
Most script integrations follow the same shape:
- Define the choices the script workflow understands.
- Give the agent a small list of Starlark tools it may call.
- Put the node, ticket, host, or other workflow values those tools need in
tool_params. - Call
agent.execute(...). - Route on
result.choice.
The agent is deliberately boxed in. It cannot call arbitrary workflow functions, invent final
choices, or pass arbitrary arguments to tools. The script provides the tool list, the choice list,
and the parameter map. Tools read those parameters with param("namespace", "key"), so the LLM
chooses which declared tool to run but does not get to supply ad hoc tool arguments.
The tools can be defined in the same script or loaded from a helper script. The rest of this page explains the exact tool and parameter contracts, but you do not need much more than this shape to read existing integrations.
Keep the first version boring: one or two non-disruptive diagnostic tools, clear choices, and a
prompt that tells the agent when to stop. Add remediation tools only after the diagnostic loop is
easy to inspect in /system/agents.
Where To Watch Runs
Agent runs are visible in the Remediation Orchestrator UI under System > Agents:
Use these while developing prompts and tools. They make it much easier to see what the agent tried, what each tool returned, and why it chose the route it chose.
Detailed API Contract
agent.execute accepts:
Without maestro = {"use_result": True}, the return value is an AgentWorkflowResults object:
With maestro = {"use_result": True}, unwrap it first:
The result fields are:
Tool Contract
Tools are the only actions the agent can take. Each tool should represent one understandable
operation, such as “run health check”, “check BMC state”, “read serial console”, or “power reset”.
Tool names must be unique across the tools list.
A tools list item may be:
Function tools must obey these rules:
Expression tools are for one-liners:
Expression tools must be a single expression statement, and that expression must be a function call. Leading comments become the tool description. The expression is normalized and hashed; the agent must emit the exact registered expression when it wants to call that tool.
Tool Resolution
Registry tools without inline source are resolved from the script context at the time
agent.execute is called.
Allowed:
Also allowed:
Not allowed:
The resolver only exposes functions defined in the root script or explicitly imported with
load(...) into the root script. Functions hidden inside dependency scripts are not tools. If the
same name is loaded more than once, Starlark’s last-write-wins binding is used.
In REPL-style execution where there is no parent script, tools can be resolved from the current
thread-local function source cache. In normal workflow scripts, prefer explicit definitions or
explicit load(...) bindings.
Param Passing Contract
Tools do not receive arguments. They read all runtime data through:
tool_params is a two-level map:
The agent package scans tool source for literal param("module", "key") calls and validates that
each module and key exists before the agent starts. Missing params produce an
AgentWorkflowResults with choice = "ERROR" and a validation message.
Important restrictions:
Use param(...) inside helper tools, not in the top-level agent prompt. The LLM sees tool docs and
tool outputs; it does not need direct access to your Starlark variables.
Generated Code Restrictions
Every LLM iteration must include a Markdown starlark code block. Remediation Orchestrator extracts that code,
validates it, then executes it.
Valid generated code:
Invalid generated code:
The validator enforces:
A function tool may internally do multiple Remediation Orchestrator module calls, but that is still one agent tool from the LLM’s perspective. If a tool is disruptive or multi-step, say that plainly in its docstring and return enough structured detail for the next iteration.
Runtime Behavior
The child workflow does this:
- Preload function tools into a fresh Starlark REPL.
- Build the system prompt from choices and tool docs.
- Ask the configured LLM for one Starlark code block.
- Validate the generated code.
- Execute one tool, exact expression, or
choose. - Feed the output or error back to the LLM.
- Repeat until
choose, timeout, ormax_iterations.
Example configuration:
Defaults from ModuleConfig:
When 10 percent or less of the workflow timeout remains, the agent is told to choose immediately.
When time is exhausted, the result choice is TIMEOUT.
Error Handling
There are two layers of errors:
Handle both:
Inside tools, prefer maestro = {"use_result": True} around module calls that can fail. Convert
errors into compact dicts when the agent can learn from them. Let the tool raise only when the
error should count as a failed execution attempt.
Observability
Each indexed run records:
The debug routes listed above are backed by this index data, so recent runs can be inspected without going directly to Temporal history.
The module also runs reconcile-agents every 10 minutes to correct stale RUNNING rows, and
provides hydrate-agents to rebuild index rows from Temporal history.
Metrics emitted by the package:
Reusable Agent Tool Patterns
Separate shared agent tools from the workflow that consumes their decisions. The following script names are placeholders; use the corresponding scripts in your own repository.
- A shared helper such as
shared_agent_tools.starcan define diagnostic tools, build a parameter profile, and expose arun_agent_triagefunction. Each calling workflow chooses the final-choice taxonomy to match its state machine. - A workflow can select the tools it needs before invoking the agent and pass
separate
commandandhttpparameter namespaces. Give each agent invocation a descriptive label such asnode-triage. - Keep diagnostic tools in a helper such as
agent_tools.star, then explicitly loadrun_agent_diagnosisinto the entrypoint script. Loaded tools must be bound into the calling script’s closure to be available to the agent. - For a small loaded-tool smoke test, define
classify_valueintools.star, load it into the calling script, pass[classify_value], and invokeagent.executewith a small parameter map.
Recommended Shape For Production Agents
Use this structure:
Be explicit:
- Put the choice taxonomy near the workflow code that consumes it.
- Keep tool docstrings operational, not vague. Include disruption level and return schema.
- Return structured, small outputs. Do not dump unbounded logs unless the tool is intentionally a log tool.
- Use stable
labelvalues so/system/agentsand dashboards stay useful. - Use
debug_metadatafor comparison data that humans need later but the model should not consider. - Keep params in named namespaces and build the param map next to the tool list.
- Convert expected module failures into tool outputs with
maestro = {"use_result": True}.
Avoid:
- Tool functions with arguments.
- Hidden dependency functions that are not explicitly loaded.
- Dynamic
parammodule or key names. - Multiple registered tool calls in one generated expression.
- Computed
choosevalues. - Returning a final choice that the surrounding FSM does not recognize.