Reasoning effort that is raised for the next stage when a trigger fires
Source:R/core-effort-escalate.R
hr_effort_escalate.RdA policy for a call's effort (hr_call()) or a read's effort_mode
(gr_read_spec()). Every stage starts at base (one level, or a map named
by call stem, resolved as a static effort is). When a trigger in on
fired during a stage, the next stage is sent at to. The stage after a
raised one goes back to base unless a trigger fired in the raised stage
too and a raise is left: at most max_escalations raises happen in one
run (one trace), so at the default of 1 it always goes back. A stage is a call label up to its second dot, with a
merge level (.level2), a summary level (.L2) and a judge's order
(.o2) left off, so map.answer and reduce are stages and
reduce.level1 belongs to reduce.
Usage
hr_effort_escalate(
base = "low",
to = "high",
on = .hr_escalate_triggers,
max_escalations = 1L,
replies = NULL
)
# S3 method for class 'hr_effort_escalate'
print(x, ...)Arguments
- base
The starting effort: one level, or a character vector named by call stem.
- to
The raised effort, one level.
- on
The triggers that raise the next stage.
- max_escalations
The most raises in one run.
- replies
NULL, or a named character vector from trigger name to the text a reply that signals it starts with.- x
An
hr_effort_escalate.- ...
Ignored.
Details
The triggers the core sees for itself are "truncated" (a "truncate"
step of the trace, or a reply cut off at its output cap; a cut made while
a stage packs its requests belongs to that stage, including one made
before its first request),
"parse_failure" (a reply to one of harnessr's own structured requests,
such as ctx$call_json() in a benchmark arm, a judge or a document reader,
that is not JSON) and
"schema_failure" (one that does not fit the schema). hr_call() with a
schema does not parse its reply, so it fires neither: check the reply
and report it with hr_effort_event(). replies names
replies that are triggers: a named character vector from trigger to the
text a reply starts with, such as c(not_in_document = "NOT_IN_DOCUMENT");
such a trigger fires when every request of the stage replied with it.
Other triggers ("verify_failed", "unclear", "disagreement", or any
name of your own) fire when the caller reports them with
hr_effort_event().
The state lives on the run's trace, so a call without a trace is sent at
base. Each raise writes an "effort.escalate" step naming the triggers,
the stage they fired in and the stage raised; when the raised stage ends,
an "effort.resolve" step says whether it fired the same triggers again.
hr_effort_log() returns both as a table.
See also
hr_effort_event(), hr_effort_log(), hr_effort_check(),
gr_read_spec() for effort_mode
Other harness:
gr_arm(),
gr_condensation_check(),
gr_qa_reference(),
gr_reverse_text(),
gr_scorer_answer(),
hr_arm(),
hr_benchmark(),
hr_chain(),
hr_contrast(),
hr_drift_check(),
hr_effort_check(),
hr_effort_event(),
hr_effort_log(),
hr_mdd(),
hr_modules(),
hr_reference(),
hr_register(),
hr_report(),
hr_scorer(),
hr_set(),
hr_settings(),
hr_skill(),
hr_step(),
hr_step_command(),
hr_sweep(),
hr_sweep_check()
Examples
pol <- hr_effort_escalate(base = "low", to = "high",
replies = c(not_in_document = "NOT_IN_DOCUMENT"))
pol
#> <hr_effort_escalate>
#> base: low; raised to high for the next stage, at most 1 time(s) a run
#> on: truncated, parse_failure, schema_failure, verify_failed, not_in_document, unclear, disagreement
# A first stage that found nothing raises the second.
cl <- hr_mock_client(function(m, p) {
if (identical(p$effort, "low") && grepl("first", m[[1]]$content)) {
return("NOT_IN_DOCUMENT")
}
paste("done at", p$effort)
})
tr <- hr_trace()
hr_call(cl, "first step", model = "gpt-5.6-luna", trace = tr, label = "plan.draft",
effort = pol)$text
#> [1] "NOT_IN_DOCUMENT"
hr_call(cl, "second step", model = "gpt-5.6-luna", trace = tr, label = "plan.final",
effort = pol)$text
#> [1] "done at high"
hr_effort_log(tr)
#> after stage triggers to calls resolved
#> 1 plan.draft plan.final not_in_document high 1 TRUE