luigidemasi commented on code in PR #27656:
URL: https://github.com/apache/camel/pull/27656#discussion_r4237544506


##########
components/camel-ai/camel-semantic/src/main/java/org/apache/camel/semantic/internal/SemanticAuditService.java:
##########
@@ -361,10 +381,50 @@ public final class Invocation {
         private final List<SemanticObserver.Observation> handles = new 
ArrayList<>();
         // Confined to the invocation thread; cancellation emits a separate 
request record.
         private boolean completed;
+        private final Map<String, Object> inputFields = new LinkedHashMap<>();
 
         private Invocation(Map<String, Object> fields, boolean enabled) {
             this.fields = fields;
             this.enabled = enabled;
+            if (enabled && configuration.getInput((String) 
fields.get("expert")).isEnabled()) {
+                inputFields.put("inputOmitted", "unavailable");
+            }
+        }
+
+        /** Snapshot the effective selected state before a provider can mutate 
it. Observers never receive this data. */
+        public void captureInput(Object input) {
+            if (fields == null || completed || inputFields.isEmpty()) {
+                return;
+            }
+            SemanticAuditInputConfiguration policy = 
configuration.getInput((String) fields.get("expert"));
+            SemanticAuditInputRedactor redactor = 
redactors.get(fields.get("expert"));
+            inputFields.clear();
+            if (policy.getRedactor() != null && redactor == null) {
+                inputFields.put("inputOmitted", "redaction_failed");
+                return;
+            }
+            Object snapshot;
+            try {
+                snapshot = SemanticAuditInputSnapshot.copy(input, 
policy.getMaxChars());
+            } catch (Exception | AssertionError | LinkageError failure) {
+                inputFields.put("inputOmitted", 
"snapshot_limit_or_unsupported_type");
+                return;
+            }
+            if (redactor != null) {
+                try {
+                    snapshot = redactor.redact(snapshot);
+                    if (snapshot == null) {
+                        inputFields.put("inputOmitted", "redacted");
+                        return;
+                    }
+                    snapshot = SemanticAuditInputSnapshot.copy(snapshot, 
policy.getMaxChars());
+                } catch (Exception | AssertionError | LinkageError failure) {

Review Comment:
   Added the comment in 
[ef9a87d2da22](https://github.com/apache/camel/commit/ef9a87d2da22cdff41c87cc4cb1d491c41451c8b)
 explaining that a failing redactor omits input without affecting evaluation or 
falling back to raw data. Tests now cover AssertionError and LinkageError from 
the redactor, in addition to the existing exception, null-output and 
invalid-output cases. The catch remains intentionally limited rather than 
catching every Error.
   
   _AI-generated by OpenAI Codex on behalf of @luigidemasi._



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to