activeagent 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +91 -0
- data/lib/active_agent/evals/correlation.rb +178 -0
- data/lib/active_agent/evals/judge.rb +44 -6
- data/lib/active_agent/evals.rb +3 -1
- data/lib/active_agent/telemetry/instrumentation.rb +17 -1
- data/lib/active_agent/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1611f71e0ff6a30b864e797b01cd20242a46acad9df3888c836799f0d297e3d1
|
|
4
|
+
data.tar.gz: 5f93c9a8c43a98cf7eb599d9efb37f2915c1d2e5ef6f4138464c33cd1f4d3af1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e27caea807dc1d32744260bf157086160d73935fba48aea9c4c59e3234c26a5aee707eb650104a76f2fdf2e59497b0408b6a80392b83ceeab2770b4c8eef3c0
|
|
7
|
+
data.tar.gz: e44dc91193d40a6fafa9bc79c3cfc3a8c4f2acc215fc0fae0229424218a8c1bc6ca5b96c5803553bb610f89b86eb519b2f0c6061018117b65a38d77eba61100b
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,97 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.6.3] - 2026-09-18
|
|
11
|
+
|
|
12
|
+
Releases `activeagent` and `actionagent` 1.6.3 from one tag.
|
|
13
|
+
|
|
14
|
+
A release about telling the truth on the screens that report what happened.
|
|
15
|
+
The context meter now divides the provider's own `prompt_tokens` among its
|
|
16
|
+
segments instead of subtracting estimates from it, and sizes each piece —
|
|
17
|
+
tool schemas, MCP schemas, instructions and the transcript — before the span
|
|
18
|
+
clips it for storage; previously a trace with dense tool schemas showed a
|
|
19
|
+
large message history that was never sent. An adapted replay is metered as
|
|
20
|
+
one execution like any other, so a host that supplies its own runtime is no
|
|
21
|
+
longer silently uncounted, and a spec naming a provider the agent cannot
|
|
22
|
+
serve now fails before the replay rather than reaching it.
|
|
23
|
+
|
|
24
|
+
Three seams hosts were reaching around become API. `ActiveAgent::Evals::Correlation`
|
|
25
|
+
joins `Runner`'s `around_evaluation:` hook to a telemetry backend's trace
|
|
26
|
+
scope, so a report row links back to the conversation behind it. A `Judge`
|
|
27
|
+
block that accepts `kind:` is told whether it is scoring, recommending or
|
|
28
|
+
writing the verdict, instead of matching on the gem's own instruction prose.
|
|
29
|
+
`Agent#generations` replaces the polymorphic join hosts were copying out of a
|
|
30
|
+
private service method.
|
|
31
|
+
|
|
32
|
+
Upgrading: no migration, and nothing that already worked changes. The judge
|
|
33
|
+
keyword reaches only a block that asks for it, so existing judges are
|
|
34
|
+
untouched; `Evaluation#replace_scenarios!` keeps `:destroy` as its default.
|
|
35
|
+
Adapters should drop any `ActionAgent.record_usage` call of their own, which
|
|
36
|
+
now double-counts, and any provider allow-list check of their own, which is
|
|
37
|
+
now dead code.
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
|
|
41
|
+
- The prompt span records how large the tool schemas actually are, as
|
|
42
|
+
`prompt.input.tools.tokens`, `prompt.input.mcp_tools.tokens`,
|
|
43
|
+
`prompt.input.instructions.tokens` and `prompt.input.messages.tokens`. The
|
|
44
|
+
transcript's size is measured before the span trims the history to the turns
|
|
45
|
+
that fit, the others before their content is clipped. The content attributes
|
|
46
|
+
beside them are previews clipped for storage — and on the SDK path the tool
|
|
47
|
+
attribute is a roster of names and parameter keys, several times smaller than
|
|
48
|
+
the schema the model is sent — so a reader that sized the context from one
|
|
49
|
+
understated tool pressure badly.
|
|
50
|
+
- MCP tool schemas are attributed apart from the toolbox's, so the context meter
|
|
51
|
+
can name which half fills the window.
|
|
52
|
+
- `Evaluation#replace_scenarios!` takes `on_removed:` — `:destroy` (the
|
|
53
|
+
default, unchanged) or `:disable`, which keeps a scenario the suite no
|
|
54
|
+
longer names as `enabled: false` so earlier runs' results still resolve.
|
|
55
|
+
- **An evaluation's traces link back to the result that caused them.**
|
|
56
|
+
`ActiveAgent::Evals::Correlation` joins two APIs the module already had but
|
|
57
|
+
never connected: `Runner`'s `around_evaluation:` hook and its `metadata:`
|
|
58
|
+
run identity, and a telemetry backend's per-block agent scope. A run mints a
|
|
59
|
+
`run_id`, each evaluation a `result_id`, and both ride every trace opened
|
|
60
|
+
inside them as `eval.`-prefixed attributes; the trace ids travel the other
|
|
61
|
+
way onto `result.replay.metadata` — `trace_id` for the replay,
|
|
62
|
+
`judge_trace_ids` for the judge calls that graded it, with a run-level
|
|
63
|
+
verdict landing on the run metadata the Report carries rather than on
|
|
64
|
+
whichever result was evaluated last. The tracer is injected, so the module
|
|
65
|
+
takes on no telemetry dependency and `require "active_agent/evals"` still
|
|
66
|
+
loads on its own. Hand the object to `Runner.new(around_evaluation:)`
|
|
67
|
+
directly; a plain lambda there keeps working unchanged.
|
|
68
|
+
- A `Judge` block that accepts `kind:` is told which of the judge's three calls
|
|
69
|
+
it is serving — `:score`, `:recommend` or `:verdict` — so a host can trace,
|
|
70
|
+
budget or model them separately. Previously the only signal was the
|
|
71
|
+
`instructions` string, so hosts matched against the gem's own
|
|
72
|
+
`RECOMMEND_INSTRUCTIONS` / `VERDICT_INSTRUCTIONS` constants; rewording one
|
|
73
|
+
then sent every such host quietly down its `else` branch, mislabelling traces
|
|
74
|
+
rather than failing. The keyword reaches only a block that names it or
|
|
75
|
+
collects `**`, so judges taking `instructions:` and `prompt:` are unaffected.
|
|
76
|
+
(#462)
|
|
77
|
+
- `Agent#generations` reads the generations recorded against an agent, with
|
|
78
|
+
`Agent#agent_contexts` beside it. Generations hang off `AgentContext`
|
|
79
|
+
polymorphically, so reaching them meant hand-writing that join — the engine
|
|
80
|
+
did it itself in a private service method a host could not reuse, which now
|
|
81
|
+
uses the association instead. Destroying an agent still leaves its contexts
|
|
82
|
+
alone, as it always has. (#464)
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
|
|
86
|
+
- The dashboard's context meter divides the provider's own `prompt_tokens`
|
|
87
|
+
among its segments instead of subtracting its estimates from it. Charging the
|
|
88
|
+
difference to one segment made "Messages" absorb the whole approximation
|
|
89
|
+
error, so a trace with dense JSON tool schemas read as a large message history
|
|
90
|
+
that was never sent. The transcript is one of the divided segments: dividing
|
|
91
|
+
only the rest would hand its share to the segments that remained, so a long
|
|
92
|
+
conversation reported an enormous system prompt and no history at all.
|
|
93
|
+
- A host that supplies a `scenario_evaluation_adapter_resolver` now has its
|
|
94
|
+
replays metered as executions, one per scenario x model, the same unit the
|
|
95
|
+
default path records. Previously an adapted replay was counted only if the
|
|
96
|
+
host remembered to call `ActionAgent.record_usage` itself.
|
|
97
|
+
- A scenario evaluation whose selected models name a provider the agent cannot
|
|
98
|
+
serve fails with `ArgumentError` before any replay runs. A spec handed back
|
|
99
|
+
as a Hash naming both `provider` and `model` bypassed the `providers:`
|
|
100
|
+
allow-list, so the run reached the replay with a provider nothing serves.
|
|
10
101
|
## [1.6.2] - 2026-09-16
|
|
11
102
|
|
|
12
103
|
Releases `activeagent` and `actionagent` 1.6.2 from one tag.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "securerandom"
|
|
4
|
+
require "active_support/isolated_execution_state"
|
|
5
|
+
|
|
6
|
+
module ActiveAgent
|
|
7
|
+
module Evals
|
|
8
|
+
# Used to tie the traces an evaluation produces back to the run and the
|
|
9
|
+
# result that caused them, so a report row links to the exact conversation
|
|
10
|
+
# behind it.
|
|
11
|
+
#
|
|
12
|
+
# A run mints a `run_id`, each evaluation mints a `result_id`, and both ride
|
|
13
|
+
# every trace opened inside them as `eval.`-prefixed attributes. The trace
|
|
14
|
+
# ids travel the other way: a replay's trace id lands on
|
|
15
|
+
# `result.replay.metadata["trace_id"]`, and every judge call made while
|
|
16
|
+
# scoring that result appends to its `"judge_trace_ids"`. The verdict — a
|
|
17
|
+
# judge call made outside any evaluation — appends to the run metadata
|
|
18
|
+
# instead, which is the same Hash a Report carries as its `metadata`.
|
|
19
|
+
#
|
|
20
|
+
# A tracer is `(name, action:, attributes:, on_trace:) { ... }`: it opens a
|
|
21
|
+
# trace named for the agent, and calls `on_trace` with something answering
|
|
22
|
+
# to `#trace_id` once the trace is known.
|
|
23
|
+
#
|
|
24
|
+
# correlation = ActiveAgent::Evals::Correlation.new(
|
|
25
|
+
# agent_name: "SupportAgent",
|
|
26
|
+
# judge_name: "SupportAgentJudge",
|
|
27
|
+
# tracer: ->(name, action:, attributes:, on_trace:, &block) {
|
|
28
|
+
# MyTelemetry.with_agent(name, action: action, attributes: attributes,
|
|
29
|
+
# on_trace: on_trace, synchronous: true, &block)
|
|
30
|
+
# }
|
|
31
|
+
# )
|
|
32
|
+
#
|
|
33
|
+
# correlation.with_run("suite" => "support") do |metadata|
|
|
34
|
+
# Runner.new(
|
|
35
|
+
# scenarios: scenarios, models: models, metadata: metadata,
|
|
36
|
+
# replay: ->(scenario, spec) { correlation.replay { agent.run(scenario.prompt) } },
|
|
37
|
+
# judge: Judge.new(label: "judge-model") { |instructions:, prompt:|
|
|
38
|
+
# correlation.judge("score") { chat.with_instructions(instructions).ask(prompt).content }
|
|
39
|
+
# },
|
|
40
|
+
# around_evaluation: correlation
|
|
41
|
+
# ).call
|
|
42
|
+
# end
|
|
43
|
+
#
|
|
44
|
+
# Without a tracer the correlation still mints ids and merges metadata. The
|
|
45
|
+
# blocks run untraced.
|
|
46
|
+
class Correlation
|
|
47
|
+
STATE_KEY = :active_agent_evals_correlation
|
|
48
|
+
|
|
49
|
+
# DEFAULT_TRACE_KEYS names the correlation metadata that rides a trace as
|
|
50
|
+
# `eval.`-prefixed attributes. Anything else a caller puts in the run
|
|
51
|
+
# metadata (a tenant, a role) stays on the report but off the traces.
|
|
52
|
+
DEFAULT_TRACE_KEYS = %w[run_id result_id suite scenario_key model_label model provider].freeze
|
|
53
|
+
|
|
54
|
+
attr_reader :agent_name, :judge_name, :trace_keys
|
|
55
|
+
|
|
56
|
+
# @param agent_name [String] the trace name for the agent under evaluation
|
|
57
|
+
# @param judge_name [String] the trace name for judge traffic, kept distinct
|
|
58
|
+
# so grading calls do not read as the agent's own traffic
|
|
59
|
+
# @param tracer [#call, nil] `(name, action:, attributes:, on_trace:) { ... }`;
|
|
60
|
+
# nil runs every block untraced
|
|
61
|
+
# @param replay_action [String] the action name recorded for a replay trace
|
|
62
|
+
# @param trace_keys [Array<String>] which correlation keys become attributes
|
|
63
|
+
def initialize(agent_name:, judge_name: "#{agent_name}Judge", tracer: nil, replay_action: "eval",
|
|
64
|
+
trace_keys: DEFAULT_TRACE_KEYS)
|
|
65
|
+
@agent_name = agent_name
|
|
66
|
+
@judge_name = judge_name
|
|
67
|
+
@tracer = tracer
|
|
68
|
+
@replay_action = replay_action
|
|
69
|
+
@trace_keys = trace_keys.map(&:to_s)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Opens a run. Mints `run_id` unless `metadata` carries one, and yields the
|
|
73
|
+
# metadata hash the traces will be correlated against — pass that same hash
|
|
74
|
+
# to `Runner.new(metadata:)` so the Report carries the run's identity and
|
|
75
|
+
# collects the verdict's trace id.
|
|
76
|
+
#
|
|
77
|
+
# The hash yielded is the caller's own, mutated in place, so a run
|
|
78
|
+
# reopened around a later verdict accumulates onto the metadata a Report
|
|
79
|
+
# already carries.
|
|
80
|
+
#
|
|
81
|
+
# @param metadata [Hash] opaque run metadata. A non-Hash is coerced with
|
|
82
|
+
# `#to_h`, and non-String keys are stringified.
|
|
83
|
+
# @yieldparam metadata [Hash]
|
|
84
|
+
def with_run(metadata = {})
|
|
85
|
+
run = metadata.is_a?(Hash) ? metadata : metadata.to_h
|
|
86
|
+
run.transform_keys!(&:to_s) unless run.keys.all?(String)
|
|
87
|
+
run["run_id"] ||= SecureRandom.uuid
|
|
88
|
+
with_context({ run: run, result: nil }) { yield run }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Wraps one evaluation, in the shape `Runner.new(around_evaluation:)` calls:
|
|
92
|
+
# `(scenario, spec) { ... } → Result`. Mints a `result_id`, merges the
|
|
93
|
+
# correlation onto the Result's replay metadata, and returns the Result.
|
|
94
|
+
def around_evaluation(scenario, spec)
|
|
95
|
+
result_metadata = {
|
|
96
|
+
"run_id" => run_metadata["run_id"],
|
|
97
|
+
"result_id" => SecureRandom.uuid,
|
|
98
|
+
"scenario_key" => scenario.key,
|
|
99
|
+
"model_label" => spec.label,
|
|
100
|
+
"model" => spec.model,
|
|
101
|
+
"provider" => spec.provider
|
|
102
|
+
}.compact
|
|
103
|
+
|
|
104
|
+
with_context(run: run_metadata, result: result_metadata) do
|
|
105
|
+
yield.tap { |result| result.replay.metadata.merge!(result_metadata) }
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Delegates to `around_evaluation`, so the object satisfies
|
|
110
|
+
# `Runner.new(around_evaluation:)` directly.
|
|
111
|
+
def call(scenario, spec, &)
|
|
112
|
+
around_evaluation(scenario, spec, &)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Traces one replay of the agent under evaluation. The trace id lands on
|
|
116
|
+
# the current result's metadata, so a report row links to the conversation.
|
|
117
|
+
def replay(action = @replay_action, &)
|
|
118
|
+
trace(@agent_name, action, judge: false, &)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Traces one judge call. Appends to the current result's `judge_trace_ids`,
|
|
122
|
+
# or the run's when no evaluation is open (the verdict).
|
|
123
|
+
def judge(action = "score", &)
|
|
124
|
+
trace(@judge_name, action, judge: true, &)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# The correlation metadata in scope, or nil outside a run. A result's
|
|
128
|
+
# values win over the run's.
|
|
129
|
+
def current
|
|
130
|
+
context = ActiveSupport::IsolatedExecutionState[STATE_KEY]
|
|
131
|
+
return nil unless context
|
|
132
|
+
|
|
133
|
+
context.fetch(:run, {}).merge(context[:result] || {})
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
private
|
|
137
|
+
|
|
138
|
+
def run_metadata
|
|
139
|
+
context = ActiveSupport::IsolatedExecutionState[STATE_KEY]
|
|
140
|
+
context&.fetch(:run, nil) || {}
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def with_context(context)
|
|
144
|
+
previous = ActiveSupport::IsolatedExecutionState[STATE_KEY]
|
|
145
|
+
ActiveSupport::IsolatedExecutionState[STATE_KEY] = context
|
|
146
|
+
yield
|
|
147
|
+
ensure
|
|
148
|
+
ActiveSupport::IsolatedExecutionState[STATE_KEY] = previous
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def trace(name, action, judge:, &block)
|
|
152
|
+
return block.call unless @tracer
|
|
153
|
+
|
|
154
|
+
context = ActiveSupport::IsolatedExecutionState[STATE_KEY] || {}
|
|
155
|
+
correlation = context.fetch(:run, {}).merge(context[:result] || {})
|
|
156
|
+
attributes = correlation.slice(*@trace_keys).transform_keys { |key| "eval.#{key}" }
|
|
157
|
+
# A replay belongs to the evaluation that opened it and nowhere else, so
|
|
158
|
+
# it records no trace id when called outside one. A judge call outside an
|
|
159
|
+
# evaluation is the verdict, which belongs to the run.
|
|
160
|
+
target = judge ? (context[:result] || context[:run]) : context[:result]
|
|
161
|
+
|
|
162
|
+
@tracer.call(name, action: action, attributes: attributes, on_trace: recorder(target, judge: judge), &block)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def recorder(target, judge:)
|
|
166
|
+
lambda do |trace|
|
|
167
|
+
next unless target
|
|
168
|
+
|
|
169
|
+
if judge
|
|
170
|
+
(target["judge_trace_ids"] ||= []) << trace.trace_id
|
|
171
|
+
else
|
|
172
|
+
target["trace_id"] = trace.trace_id
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -10,6 +10,21 @@ module ActiveAgent
|
|
|
10
10
|
# RubyLLM.chat(model: "claude-opus-5").with_instructions(instructions).ask(prompt).content
|
|
11
11
|
# end
|
|
12
12
|
#
|
|
13
|
+
# A judge serves three different calls, and a block that accepts `kind:` is
|
|
14
|
+
# told which one it is serving — `:score`, `:recommend` or `:verdict` — so a
|
|
15
|
+
# host can trace them apart, budget them apart, or score with a cheaper model
|
|
16
|
+
# than it writes the verdict with:
|
|
17
|
+
#
|
|
18
|
+
# Judge.new(label: "claude-opus-5") do |instructions:, prompt:, kind:|
|
|
19
|
+
# model = kind == :score ? "claude-haiku-4-5" : "claude-opus-5"
|
|
20
|
+
# RubyLLM.chat(model: model).with_instructions(instructions).ask(prompt).content
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
23
|
+
# The keyword is passed only to a block that names it (or collects `**`), so
|
|
24
|
+
# a two-keyword block written before this is unaffected. Without it the only
|
|
25
|
+
# signal is the `instructions` string, which means matching on the gem's own
|
|
26
|
+
# prose — and a reworded constant then mislabels silently instead of failing.
|
|
27
|
+
#
|
|
13
28
|
# Every method returns nil when the judge fails or answers unusably, so an
|
|
14
29
|
# evaluation degrades to rule scoring rather than aborting.
|
|
15
30
|
class Judge
|
|
@@ -23,6 +38,8 @@ module ActiveAgent
|
|
|
23
38
|
# @param label [String] how reports name the judge (usually its model)
|
|
24
39
|
# @yieldparam instructions [String] the system prompt
|
|
25
40
|
# @yieldparam prompt [String] the user prompt
|
|
41
|
+
# @yieldparam kind [Symbol] which call this is — `:score`, `:recommend` or
|
|
42
|
+
# `:verdict`. Passed only to a block that accepts it.
|
|
26
43
|
# @yieldreturn [String] the completion text
|
|
27
44
|
# How much of a scenario's notes the judge reads. Where a suite's notes
|
|
28
45
|
# are its grading rubric, a "Must not…" clause tends to come last, and a
|
|
@@ -41,7 +58,7 @@ module ActiveAgent
|
|
|
41
58
|
return nil if answer.blank?
|
|
42
59
|
|
|
43
60
|
guidance = criterion.dig("config", "prompt").presence || criterion["key"].to_s.humanize
|
|
44
|
-
parse_score(ask(SCORE_INSTRUCTIONS, <<~PROMPT))
|
|
61
|
+
parse_score(ask(SCORE_INSTRUCTIONS, <<~PROMPT, :score))
|
|
45
62
|
Criterion: #{guidance}
|
|
46
63
|
|
|
47
64
|
The user asked:
|
|
@@ -64,7 +81,7 @@ module ActiveAgent
|
|
|
64
81
|
def score_task(scenario:, answer:)
|
|
65
82
|
return nil if answer.blank?
|
|
66
83
|
|
|
67
|
-
parse_score(ask(SCORE_INSTRUCTIONS, <<~PROMPT))
|
|
84
|
+
parse_score(ask(SCORE_INSTRUCTIONS, <<~PROMPT, :score))
|
|
68
85
|
A user asked an assistant:
|
|
69
86
|
---
|
|
70
87
|
#{scenario.prompt}
|
|
@@ -90,7 +107,7 @@ module ActiveAgent
|
|
|
90
107
|
"- #{call['name']}#{' (errored)' if call['error']}: #{call['arguments'].to_json.truncate(200)}"
|
|
91
108
|
end.join("\n")
|
|
92
109
|
|
|
93
|
-
parsed = parse_object(ask(RECOMMEND_INSTRUCTIONS, <<~PROMPT))
|
|
110
|
+
parsed = parse_object(ask(RECOMMEND_INSTRUCTIONS, <<~PROMPT, :recommend))
|
|
94
111
|
An AI agent failed one evaluation scenario. Recommend the fix.
|
|
95
112
|
|
|
96
113
|
Agent instructions:
|
|
@@ -146,7 +163,7 @@ module ActiveAgent
|
|
|
146
163
|
"#{", faults: #{faults}" if faults.present?}"
|
|
147
164
|
end
|
|
148
165
|
|
|
149
|
-
parsed = parse_object(ask(VERDICT_INSTRUCTIONS, <<~PROMPT))
|
|
166
|
+
parsed = parse_object(ask(VERDICT_INSTRUCTIONS, <<~PROMPT, :verdict))
|
|
150
167
|
An AI agent ran the same scenarios under several models. Its goals:
|
|
151
168
|
---
|
|
152
169
|
#{instructions.to_s.truncate(1_000).presence || '(no instructions configured)'}
|
|
@@ -180,13 +197,34 @@ module ActiveAgent
|
|
|
180
197
|
end
|
|
181
198
|
end
|
|
182
199
|
|
|
183
|
-
def ask(instructions, prompt)
|
|
184
|
-
@generate.call(instructions
|
|
200
|
+
def ask(instructions, prompt, kind)
|
|
201
|
+
@generate.call(**ask_arguments(instructions, prompt, kind)).to_s
|
|
185
202
|
rescue StandardError => e
|
|
186
203
|
warn_failure(e)
|
|
187
204
|
nil
|
|
188
205
|
end
|
|
189
206
|
|
|
207
|
+
# The block signature is public API, and every judge written before `kind:`
|
|
208
|
+
# existed takes exactly `instructions:` and `prompt:` — passing a third
|
|
209
|
+
# keyword to one of those raises ArgumentError, which `ask` would swallow
|
|
210
|
+
# as a judge failure, degrading the run to rule scoring. So the kind goes
|
|
211
|
+
# only to a block that asked for it.
|
|
212
|
+
def ask_arguments(instructions, prompt, kind)
|
|
213
|
+
arguments = { instructions: instructions, prompt: prompt }
|
|
214
|
+
arguments[:kind] = kind if generate_accepts_kind?
|
|
215
|
+
arguments
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# True for a block naming `kind:` or collecting `**`. Memoized because the
|
|
219
|
+
# answer cannot change for a given judge and `ask` runs per scored result.
|
|
220
|
+
def generate_accepts_kind?
|
|
221
|
+
return @generate_accepts_kind if defined?(@generate_accepts_kind)
|
|
222
|
+
|
|
223
|
+
@generate_accepts_kind = @generate.parameters.any? do |type, name|
|
|
224
|
+
type == :keyrest || (name == :kind && (type == :key || type == :keyreq))
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
190
228
|
def warn_failure(error)
|
|
191
229
|
message = "[ActiveAgent::Evals] judge #{label} failed: #{error.class}: #{error.message}"
|
|
192
230
|
if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
|
data/lib/active_agent/evals.rb
CHANGED
|
@@ -25,6 +25,7 @@ require_relative "evals/design_tokens"
|
|
|
25
25
|
require_relative "evals/report_html"
|
|
26
26
|
require_relative "evals/report"
|
|
27
27
|
require_relative "evals/runner"
|
|
28
|
+
require_relative "evals/correlation"
|
|
28
29
|
require_relative "evals/publisher"
|
|
29
30
|
|
|
30
31
|
# Scenario evaluations for agents that answer with tools.
|
|
@@ -40,7 +41,8 @@ require_relative "evals/publisher"
|
|
|
40
41
|
# fell short and what would fix it (Diagnosis, refined by an optional Judge),
|
|
41
42
|
# and rolling everything up per model (Report). Runner ties them together
|
|
42
43
|
# around one callable you supply: given a scenario and a model, run the
|
|
43
|
-
# agent and return a Replay.
|
|
44
|
+
# agent and return a Replay. Correlation is optional plumbing on top: it
|
|
45
|
+
# links the traces a run emits back to the result that caused them.
|
|
44
46
|
#
|
|
45
47
|
# scenarios = ActiveAgent::Evals::ScenarioParser.scenarios(pasted_text)
|
|
46
48
|
# models = ActiveAgent::Evals::ModelSpec.parse_all(%w[gpt-5-mini qwen3:8b], default_provider: "openai")
|
|
@@ -101,7 +101,23 @@ module ActiveAgent
|
|
|
101
101
|
parameters: properties.is_a?(Hash) ? properties.keys : []
|
|
102
102
|
}.compact
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
if roster.any?
|
|
105
|
+
prompt_span.set_attribute("prompt.input.tools", JSON.generate(roster))
|
|
106
|
+
# The roster is a reading aid: names, a truncated description
|
|
107
|
+
# and parameter keys. What the model is sent is the full JSON
|
|
108
|
+
# Schema — types, enums, nested objects, anyOf branches —
|
|
109
|
+
# which for a twelve-tool agent is several times the roster,
|
|
110
|
+
# so a context meter sizing tool pressure from the roster
|
|
111
|
+
# understates it badly. The schemas come from the host and
|
|
112
|
+
# need not be serializable; a size is worth less than the
|
|
113
|
+
# generation it would otherwise take down.
|
|
114
|
+
tools_size = begin
|
|
115
|
+
JSON.generate(tools).length
|
|
116
|
+
rescue StandardError
|
|
117
|
+
nil
|
|
118
|
+
end
|
|
119
|
+
prompt_span.set_attribute("prompt.input.tools.tokens", (tools_size / 4.0).round) if tools_size
|
|
120
|
+
end
|
|
105
121
|
end
|
|
106
122
|
|
|
107
123
|
# prompt_options[:messages] holds the turns a caller passed
|
data/lib/active_agent/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activeagent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Bowen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|
|
@@ -434,6 +434,7 @@ files:
|
|
|
434
434
|
- lib/active_agent/delegation/schema.rb
|
|
435
435
|
- lib/active_agent/deprecator.rb
|
|
436
436
|
- lib/active_agent/evals.rb
|
|
437
|
+
- lib/active_agent/evals/correlation.rb
|
|
437
438
|
- lib/active_agent/evals/design_tokens.rb
|
|
438
439
|
- lib/active_agent/evals/diagnosis.rb
|
|
439
440
|
- lib/active_agent/evals/judge.rb
|