ruby_llm-agents 3.5.4 → 3.5.5
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fcd75502c369dc11b47f538e49ab52b0a04fa742c0df7b889915ee3b6003eebb
|
|
4
|
+
data.tar.gz: 14d32d454e00c7bf2f0c9d1f61c0d8c16b82fd6d63fd3d72bc5d263c2f143ab0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d53fe803e960be5b11e92bae6ad6923b3f648359ec476b9f56c46a355e2f71e75c63b71b546ecd170ee8e923300d6c11889ac8573071a891c8b21570094378e
|
|
7
|
+
data.tar.gz: 674ba879084fdff24c48c02b0374cff6a1a7218420582d88ad76731f53c8fa9e41b97c081a721de8578d69c8a2348a124c283910b48a8b8b144e44d3ea4ce585
|
|
@@ -202,6 +202,12 @@ module RubyLLM
|
|
|
202
202
|
data[:tenant_id] = context.tenant_id
|
|
203
203
|
end
|
|
204
204
|
|
|
205
|
+
# Include agent-defined metadata so it appears on the dashboard immediately
|
|
206
|
+
agent_meta = safe_agent_metadata(context)
|
|
207
|
+
if agent_meta.any?
|
|
208
|
+
data[:metadata] = agent_meta.transform_keys(&:to_s)
|
|
209
|
+
end
|
|
210
|
+
|
|
205
211
|
data
|
|
206
212
|
end
|
|
207
213
|
|
|
@@ -222,12 +228,18 @@ module RubyLLM
|
|
|
222
228
|
attempts_count: context.attempts_made
|
|
223
229
|
}
|
|
224
230
|
|
|
225
|
-
#
|
|
226
|
-
|
|
231
|
+
# Merge metadata: agent metadata (base) < middleware metadata (overlay)
|
|
232
|
+
agent_meta = safe_agent_metadata(context)
|
|
233
|
+
merged_metadata = agent_meta.transform_keys(&:to_s)
|
|
234
|
+
|
|
235
|
+
context_meta = begin
|
|
227
236
|
context.metadata.dup
|
|
228
237
|
rescue
|
|
229
238
|
{}
|
|
230
239
|
end
|
|
240
|
+
context_meta.transform_keys!(&:to_s)
|
|
241
|
+
merged_metadata.merge!(context_meta)
|
|
242
|
+
|
|
231
243
|
if context.cached? && context[:cache_key]
|
|
232
244
|
merged_metadata["response_cache_key"] = context[:cache_key]
|
|
233
245
|
end
|
|
@@ -321,11 +333,18 @@ module RubyLLM
|
|
|
321
333
|
# @param status [String] "success" or "error"
|
|
322
334
|
# @return [Hash] Execution data
|
|
323
335
|
def build_execution_data(context, status)
|
|
324
|
-
|
|
336
|
+
# Merge metadata: agent metadata (base) < middleware metadata (overlay)
|
|
337
|
+
agent_meta = safe_agent_metadata(context)
|
|
338
|
+
merged_metadata = agent_meta.transform_keys(&:to_s)
|
|
339
|
+
|
|
340
|
+
context_meta = begin
|
|
325
341
|
context.metadata.dup
|
|
326
342
|
rescue
|
|
327
343
|
{}
|
|
328
344
|
end
|
|
345
|
+
context_meta.transform_keys!(&:to_s)
|
|
346
|
+
merged_metadata.merge!(context_meta)
|
|
347
|
+
|
|
329
348
|
if context.cached? && context[:cache_key]
|
|
330
349
|
merged_metadata["response_cache_key"] = context[:cache_key]
|
|
331
350
|
end
|
|
@@ -426,6 +445,24 @@ module RubyLLM
|
|
|
426
445
|
params
|
|
427
446
|
end
|
|
428
447
|
|
|
448
|
+
# Safely retrieves custom metadata from the agent instance
|
|
449
|
+
#
|
|
450
|
+
# Returns an empty hash if the agent doesn't define metadata,
|
|
451
|
+
# the method raises, or the result isn't a Hash.
|
|
452
|
+
#
|
|
453
|
+
# @param context [Context] The execution context
|
|
454
|
+
# @return [Hash] Agent-defined metadata, or empty hash
|
|
455
|
+
def safe_agent_metadata(context)
|
|
456
|
+
return {} unless context.agent_instance
|
|
457
|
+
return {} unless context.agent_instance.respond_to?(:metadata)
|
|
458
|
+
|
|
459
|
+
result = context.agent_instance.metadata
|
|
460
|
+
result.is_a?(Hash) ? result : {}
|
|
461
|
+
rescue => e
|
|
462
|
+
debug("Failed to retrieve agent metadata: #{e.message}")
|
|
463
|
+
{}
|
|
464
|
+
end
|
|
465
|
+
|
|
429
466
|
# Sensitive parameter keys that should be redacted
|
|
430
467
|
SENSITIVE_KEYS = %w[
|
|
431
468
|
password token api_key secret credential auth key
|