Skip to navigation

Using the Remediation Orchestrator Agent

View as MarkdownOpen in Claude

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:

result = run_agent_diagnosis(node)
if result.choice == "READY":
return mark_ready(node)
if result.choice == "RUN_REPAIR":
return run_repair(node, result.description)
return escalate_to_operator(node, result.description)

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:

  1. Define the choices the script workflow understands.
  2. Give the agent a small list of Starlark tools it may call.
  3. Put the node, ticket, host, or other workflow values those tools need in tool_params.
  4. Call agent.execute(...).
  5. 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.

def run_agent_diagnosis(node):
choices = {
"READY": "The resource is healthy and the workflow can continue.",
"RUN_REPAIR": "A safe automated repair action should run next.",
"ESCALATE": "The issue is unclear or needs manual investigation.",
}
tool_params = {
"node": {
"id": node.datacenter_node_id,
"hostname": node.hostname,
},
}
result = agent.execute(
"Diagnose the node one tool at a time. Conclude with choose(CHOICE, DESCRIPTION).",
choices,
[agent_healthcheck, agent_read_context, agent_validate_state],
tool_params,
label = "diagnosis",
)
if result.choice == "READY":
return mark_ready(node)
if result.choice == "RUN_REPAIR":
return run_repair(node, result.description)
return escalate_to_operator(node, result.description)

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:

RouteUse
/system/agentsList and inspect individual agent runs.
/dashboards/agentsDashboard view for agent run trends and outcomes.
/system/agents/{workflowID}?run_id=...Detail page for a specific run.

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

result = agent.execute(
prompt,
choices,
tools,
tool_params,
label = "diagnosis",
debug_metadata = {"ticket": ticket_id},
maestro = {"use_result": True},
)

agent.execute accepts:

ArgumentRequiredContract
promptyesA string telling the agent what to investigate, what matters, and when to stop.
choicesyesA dict of final choice ID to human-readable meaning. The agent must eventually call choose("CHOICE", "DESCRIPTION") with one of these IDs.
toolsyesA list of tool functions, tool names, or tool dicts. Details below.
tool_paramsyesA nested dict consumed by param(module, key) inside tools. All statically referenced params are validated before the child workflow starts.
labelnoStored in agent_runs.agent_label and shown in /system/agents. Defaults to default. Use a stable label like diagnosis, node-triage, or failure_handler.
debug_metadatanoJSON-like metadata stored with the run for later analysis. This is not added to the prompt.
maestro = {"use_result": True}noGeneric Remediation Orchestrator call behavior. It wraps Starlark call errors in Result, but an agent decision of choice == "ERROR" is still a successful return value.

Without maestro = {"use_result": True}, the return value is an AgentWorkflowResults object:

result = agent.execute(prompt, choices, tools, tool_params)
print(result.choice)
print(result.description)

With maestro = {"use_result": True}, unwrap it first:

wrapped = agent.execute(prompt, choices, tools, tool_params, maestro = {"use_result": True})
if wrapped.is_err():
return {"choice": "ERROR", "description": "Agent call failed: %s" % wrapped.error}
result = wrapped.unwrap()
return {"choice": result.choice, "description": result.description}

The result fields are:

FieldMeaning
choiceFinal choice ID, or ERROR / TIMEOUT for agent-level failures.
descriptionFinal explanation or failure message.
iterations_to_choiceNumber of agent iterations used.
total_errorsCount of LLM extraction, validation, execution, or workflow errors seen by the agent loop.
max_iterations_reachedTrue when the agent exhausted the configured iteration limit before choosing.

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:

tools = [
agent_healthcheck, # function value from this script or a loaded script
"agent_check_bcm", # function name resolved from the root script binding
{
"tool": "uptime",
"source": 'ssh.execute(param("ssh", "host"), "uptime")',
},
]

Function tools must obey these rules:

RuleWhy
Define exactly one top-level def in the tool source.The callable stays unambiguous and portable across the agent run.
The function must take zero arguments.Runtime values come from param(...), not function parameters.
The first statement must be a string literal docstring.The docstring is included in the agent system prompt.
The body must not call load, getattr, dir, or globals.These are rejected as dangerous operations.
Return compact Starlark values: dicts, lists, strings, numbers, booleans, or module result fields.The tool output is fed back into the LLM and indexed.

Expression tools are for one-liners:

tools = [
{
"tool": "check_uptime",
"source": '# Check host uptime\nssh.execute(param("ssh", "host"), "uptime")',
},
]

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:

load("agent_tools.star", "agent_healthcheck")
def run():
return agent.execute(prompt, choices, [agent_healthcheck], tool_params)

Also allowed:

load("agent_tools.star", "agent_healthcheck")
def run():
return agent.execute(prompt, choices, ["agent_healthcheck"], tool_params)

Not allowed:

# agent_hidden exists in agent_tools.star, but it is not loaded into this script.
def run():
return agent.execute(prompt, choices, ["agent_hidden"], tool_params)

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:

value = param("module", "key")

tool_params is a two-level map:

tool_params = {
"node": {
"id": serial,
"hostname": hostname,
},
"ssh": {
"host": hostname,
},
"ticket": {
"key": ticket_id,
},
}

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:

RestrictionPractical guidance
param takes exactly two string arguments.Always write param("node", "id"), not param(ns, key).
Static validation only sees literal module and key strings.Dynamic param names can still fail at execution time and cost an iteration.
Missing modules and keys are fatal to that tool call.Build tool_params in the same helper that builds the tools list.
Params are serialized through Temporal durable values.Pass workflow-safe values. Existing scripts pass strings, booleans, lists, dicts, and structs.
Namespace names are just contracts.Use names like node, ssh, ticket, command, or validation to make ownership obvious.

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:

agent_healthcheck()
ssh.execute(param("ssh", "host"), "uptime")
choose("READY", "Health checks passed and validation state is safe.")

Invalid generated code:

first = agent_healthcheck()
second = agent_read_context()
{"health": agent_healthcheck(), "context": agent_read_context()}
choose(agent_healthcheck(), "computed choice")

The validator enforces:

RuleEnforcement
The generated code must be one expression statement.Assignments, loops, if statements, and multiple statements are rejected.
Function tools must be called directly by name.agent_healthcheck() is valid. Wrapping it in another expression is not.
Exactly one allowed tool call per iteration.Multiple registered tool calls in the expression are rejected.
Expression tools must match the registered expression hash.The model must use the exact expression shown in the tool docs.
choose(...) is the only finalizer.The first choice should be a literal valid choice ID. Function calls inside choose args are rejected.
load, getattr, dir, and globals are forbidden.These are rejected in generated code and in tool source validation.

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:

  1. Preload function tools into a fresh Starlark REPL.
  2. Build the system prompt from choices and tool docs.
  3. Ask the configured LLM for one Starlark code block.
  4. Validate the generated code.
  5. Execute one tool, exact expression, or choose.
  6. Feed the output or error back to the LLM.
  7. Repeat until choose, timeout, or max_iterations.

Example configuration:

[modules.agent]
max_iterations = 50
workflow_timeout = "6h"

Defaults from ModuleConfig:

ConfigDefault
default_capabilitystandard
default_modelUnset; the LLM module resolves its configured capability ladder or default model.
max_iterations20, and values <= 0 reset to 20; values > 50 reset to 50
workflow_timeout4h

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:

Error layerWhat you see
Starlark call/runtime error from agent.execute itselfWith maestro = {"use_result": True}, you get Err(...). Without it, the script fails.
Agent-level failure represented as a decisionYou get an AgentWorkflowResults with choice = "ERROR" or choice = "TIMEOUT". With use_result, this is still Ok(result).

Handle both:

wrapped = agent.execute(prompt, choices, tools, tool_params, maestro = {"use_result": True})
if wrapped.is_err():
return struct(choice = "ERROR", description = "agent.execute failed: %s" % wrapped.error)
result = wrapped.unwrap()
if result.choice == "ERROR" or result.choice == "TIMEOUT":
return struct(choice = result.choice, description = result.description)
return result

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:

DataLocation
Run state, label, prompt, choices, tool list, parent workflow IDs, metadataagent_runs
System, user, and assistant messagesagent_messages
Tool inputs, outputs, errors, and durationagent_tool_calls

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:

MetricMeaning
agent_choice_made_totalCount of final choices by choice label.
agent_iterations_to_choiceHistogram of iterations before final choice.
agent_iteration_errors_totalCount of validation, execution, timeout, and extraction errors by type.
agent_max_iterations_reached_totalCount of runs that hit the iteration cap.
agent_external_failures_totalParent-observed child workflow failures.

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.star can define diagnostic tools, build a parameter profile, and expose a run_agent_triage function. 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 command and http parameter namespaces. Give each agent invocation a descriptive label such as node-triage.
  • Keep diagnostic tools in a helper such as agent_tools.star, then explicitly load run_agent_diagnosis into 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_value in tools.star, load it into the calling script, pass [classify_value], and invoke agent.execute with a small parameter map.

Use this structure:

def agent_specific_check():
"""State what the tool checks, whether it is disruptive, and the return schema."""
result = some_module.call(param("namespace", "key"), maestro = {"use_result": True})
if result.is_err():
return {"ok": False, "error": result.error}
value = result.unwrap()
return {"ok": True, "summary": value.summary}
def build_agent_params(node):
return {
"node": {
"id": node.datacenter_node_id,
"hostname": node.hostname,
},
}
def run_agent(node):
choices = {
"READY": "The resource is healthy and the workflow can continue.",
"ESCALATE": "Automated triage cannot safely resolve this.",
}
prompt = (
"Investigate the node using one tool at a time. "
"Do not run disruptive tools until non-disruptive evidence supports them. "
"Conclude with choose(CHOICE, DESCRIPTION)."
)
return agent.execute(
prompt,
choices,
[agent_specific_check],
build_agent_params(node),
label = "node-triage",
maestro = {"use_result": True},
)

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 label values so /system/agents and dashboards stay useful.
  • Use debug_metadata for 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 param module or key names.
  • Multiple registered tool calls in one generated expression.
  • Computed choose values.
  • Returning a final choice that the surrounding FSM does not recognize.