Add support for content parts and image URLs in AI Guard#10449
Conversation
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 64 metrics, 7 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.59.0-SNAPSHOT~4180892f39, baseline=1.59.0-SNAPSHOT~708daf39d2
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.057 s) : 0, 1057114
Total [baseline] (8.684 s) : 0, 8683611
Agent [candidate] (1.056 s) : 0, 1056126
Total [candidate] (8.719 s) : 0, 8718537
section iast
Agent [baseline] (1.251 s) : 0, 1251330
Total [baseline] (9.423 s) : 0, 9422517
Agent [candidate] (1.232 s) : 0, 1231940
Total [candidate] (9.346 s) : 0, 9345909
gantt
title insecure-bank - break down per module: candidate=1.59.0-SNAPSHOT~4180892f39, baseline=1.59.0-SNAPSHOT~708daf39d2
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.176 ms) : 0, 1176
crashtracking [candidate] (1.175 ms) : 0, 1175
BytebuddyAgent [baseline] (622.115 ms) : 0, 622115
BytebuddyAgent [candidate] (623.305 ms) : 0, 623305
AgentMeter [baseline] (28.703 ms) : 0, 28703
AgentMeter [candidate] (28.781 ms) : 0, 28781
GlobalTracer [baseline] (256.41 ms) : 0, 256410
GlobalTracer [candidate] (256.991 ms) : 0, 256991
AppSec [baseline] (32.882 ms) : 0, 32882
AppSec [candidate] (32.834 ms) : 0, 32834
Debugger [baseline] (63.265 ms) : 0, 63265
Debugger [candidate] (59.623 ms) : 0, 59623
Remote Config [baseline] (615.222 µs) : 0, 615
Remote Config [candidate] (628.574 µs) : 0, 629
Telemetry [baseline] (11.225 ms) : 0, 11225
Telemetry [candidate] (9.831 ms) : 0, 9831
Flare Poller [baseline] (5.381 ms) : 0, 5381
Flare Poller [candidate] (7.634 ms) : 0, 7634
section iast
crashtracking [baseline] (1.231 ms) : 0, 1231
crashtracking [candidate] (1.188 ms) : 0, 1188
BytebuddyAgent [baseline] (808.615 ms) : 0, 808615
BytebuddyAgent [candidate] (797.168 ms) : 0, 797168
AgentMeter [baseline] (11.713 ms) : 0, 11713
AgentMeter [candidate] (11.391 ms) : 0, 11391
GlobalTracer [baseline] (252.071 ms) : 0, 252071
GlobalTracer [candidate] (248.068 ms) : 0, 248068
AppSec [baseline] (33.654 ms) : 0, 33654
AppSec [candidate] (33.743 ms) : 0, 33743
Debugger [baseline] (67.897 ms) : 0, 67897
Debugger [candidate] (65.633 ms) : 0, 65633
Remote Config [baseline] (556.762 µs) : 0, 557
Remote Config [candidate] (556.529 µs) : 0, 557
Telemetry [baseline] (8.694 ms) : 0, 8694
Telemetry [candidate] (8.497 ms) : 0, 8497
Flare Poller [baseline] (3.528 ms) : 0, 3528
Flare Poller [candidate] (3.417 ms) : 0, 3417
IAST [baseline] (27.545 ms) : 0, 27545
IAST [candidate] (26.827 ms) : 0, 26827
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.59.0-SNAPSHOT~4180892f39, baseline=1.59.0-SNAPSHOT~708daf39d2
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.059 s) : 0, 1059494
Total [baseline] (10.916 s) : 0, 10915910
Agent [candidate] (1.059 s) : 0, 1059027
Total [candidate] (10.817 s) : 0, 10817206
section appsec
Agent [baseline] (1.237 s) : 0, 1237155
Total [baseline] (10.89 s) : 0, 10889671
Agent [candidate] (1.231 s) : 0, 1230538
Total [candidate] (10.923 s) : 0, 10923291
section iast
Agent [baseline] (1.225 s) : 0, 1225299
Total [baseline] (11.155 s) : 0, 11154645
Agent [candidate] (1.226 s) : 0, 1225986
Total [candidate] (11.143 s) : 0, 11143431
section profiling
Agent [baseline] (1.194 s) : 0, 1194014
Total [baseline] (10.864 s) : 0, 10864385
Agent [candidate] (1.19 s) : 0, 1190336
Total [candidate] (10.808 s) : 0, 10808486
gantt
title petclinic - break down per module: candidate=1.59.0-SNAPSHOT~4180892f39, baseline=1.59.0-SNAPSHOT~708daf39d2
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.205 ms) : 0, 1205
crashtracking [candidate] (1.183 ms) : 0, 1183
BytebuddyAgent [baseline] (624.199 ms) : 0, 624199
BytebuddyAgent [candidate] (623.01 ms) : 0, 623010
AgentMeter [baseline] (28.84 ms) : 0, 28840
AgentMeter [candidate] (28.854 ms) : 0, 28854
GlobalTracer [baseline] (257.753 ms) : 0, 257753
GlobalTracer [candidate] (257.337 ms) : 0, 257337
AppSec [baseline] (33.044 ms) : 0, 33044
AppSec [candidate] (32.955 ms) : 0, 32955
Debugger [baseline] (60.835 ms) : 0, 60835
Debugger [candidate] (62.093 ms) : 0, 62093
Remote Config [baseline] (637.351 µs) : 0, 637
Remote Config [candidate] (634.779 µs) : 0, 635
Telemetry [baseline] (9.201 ms) : 0, 9201
Telemetry [candidate] (10.697 ms) : 0, 10697
Flare Poller [baseline] (8.439 ms) : 0, 8439
Flare Poller [candidate] (6.933 ms) : 0, 6933
section appsec
crashtracking [baseline] (1.188 ms) : 0, 1188
crashtracking [candidate] (1.177 ms) : 0, 1177
BytebuddyAgent [baseline] (656.245 ms) : 0, 656245
BytebuddyAgent [candidate] (651.72 ms) : 0, 651720
AgentMeter [baseline] (11.878 ms) : 0, 11878
AgentMeter [candidate] (11.785 ms) : 0, 11785
GlobalTracer [baseline] (257.989 ms) : 0, 257989
GlobalTracer [candidate] (256.805 ms) : 0, 256805
AppSec [baseline] (167.888 ms) : 0, 167888
AppSec [candidate] (167.217 ms) : 0, 167217
Debugger [baseline] (67.406 ms) : 0, 67406
Debugger [candidate] (67.58 ms) : 0, 67580
Remote Config [baseline] (680.291 µs) : 0, 680
Remote Config [candidate] (682.235 µs) : 0, 682
Telemetry [baseline] (9.244 ms) : 0, 9244
Telemetry [candidate] (9.248 ms) : 0, 9248
Flare Poller [baseline] (3.619 ms) : 0, 3619
Flare Poller [candidate] (3.693 ms) : 0, 3693
IAST [baseline] (25.643 ms) : 0, 25643
IAST [candidate] (25.372 ms) : 0, 25372
section iast
crashtracking [baseline] (1.185 ms) : 0, 1185
crashtracking [candidate] (1.186 ms) : 0, 1186
BytebuddyAgent [baseline] (789.688 ms) : 0, 789688
BytebuddyAgent [candidate] (790.187 ms) : 0, 790187
AgentMeter [baseline] (11.16 ms) : 0, 11160
AgentMeter [candidate] (11.132 ms) : 0, 11132
GlobalTracer [baseline] (247.779 ms) : 0, 247779
GlobalTracer [candidate] (247.815 ms) : 0, 247815
AppSec [baseline] (34.331 ms) : 0, 34331
AppSec [candidate] (35.526 ms) : 0, 35526
Debugger [baseline] (66.383 ms) : 0, 66383
Debugger [candidate] (65.212 ms) : 0, 65212
Remote Config [baseline] (555.771 µs) : 0, 556
Remote Config [candidate] (552.787 µs) : 0, 553
Telemetry [baseline] (8.574 ms) : 0, 8574
Telemetry [candidate] (8.586 ms) : 0, 8586
Flare Poller [baseline] (3.474 ms) : 0, 3474
Flare Poller [candidate] (3.479 ms) : 0, 3479
IAST [baseline] (26.81 ms) : 0, 26810
IAST [candidate] (26.958 ms) : 0, 26958
section profiling
crashtracking [baseline] (1.23 ms) : 0, 1230
crashtracking [candidate] (1.217 ms) : 0, 1217
BytebuddyAgent [baseline] (682.646 ms) : 0, 682646
BytebuddyAgent [candidate] (680.201 ms) : 0, 680201
AgentMeter [baseline] (8.69 ms) : 0, 8690
AgentMeter [candidate] (8.65 ms) : 0, 8650
GlobalTracer [baseline] (217.964 ms) : 0, 217964
GlobalTracer [candidate] (217.373 ms) : 0, 217373
AppSec [baseline] (32.854 ms) : 0, 32854
AppSec [candidate] (32.633 ms) : 0, 32633
Debugger [baseline] (68.063 ms) : 0, 68063
Debugger [candidate] (67.891 ms) : 0, 67891
Remote Config [baseline] (584.65 µs) : 0, 585
Remote Config [candidate] (590.051 µs) : 0, 590
Telemetry [baseline] (8.655 ms) : 0, 8655
Telemetry [candidate] (8.696 ms) : 0, 8696
Flare Poller [baseline] (3.749 ms) : 0, 3749
Flare Poller [candidate] (3.766 ms) : 0, 3766
ProfilingAgent [baseline] (99.284 ms) : 0, 99284
ProfilingAgent [candidate] (99.186 ms) : 0, 99186
Profiling [baseline] (99.866 ms) : 0, 99866
Profiling [candidate] (99.764 ms) : 0, 99764
LoadParameters
See matching parameters
SummaryFound 2 performance improvements and 1 performance regressions! Performance is the same for 16 metrics, 17 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~4180892f39, baseline=1.59.0-SNAPSHOT~708daf39d2
dateFormat X
axisFormat %s
section baseline
no_agent (18.214 ms) : 18026, 18401
. : milestone, 18214,
appsec (19.575 ms) : 19374, 19776
. : milestone, 19575,
code_origins (17.621 ms) : 17448, 17793
. : milestone, 17621,
iast (17.431 ms) : 17260, 17602
. : milestone, 17431,
profiling (18.485 ms) : 18298, 18671
. : milestone, 18485,
tracing (17.664 ms) : 17487, 17842
. : milestone, 17664,
section candidate
no_agent (17.589 ms) : 17413, 17765
. : milestone, 17589,
appsec (18.795 ms) : 18602, 18987
. : milestone, 18795,
code_origins (17.65 ms) : 17474, 17826
. : milestone, 17650,
iast (17.878 ms) : 17696, 18060
. : milestone, 17878,
profiling (18.678 ms) : 18490, 18865
. : milestone, 18678,
tracing (17.719 ms) : 17541, 17897
. : milestone, 17719,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~4180892f39, baseline=1.59.0-SNAPSHOT~708daf39d2
dateFormat X
axisFormat %s
section baseline
no_agent (1.189 ms) : 1177, 1200
. : milestone, 1189,
iast (3.25 ms) : 3206, 3294
. : milestone, 3250,
iast_FULL (5.905 ms) : 5846, 5965
. : milestone, 5905,
iast_GLOBAL (3.673 ms) : 3610, 3736
. : milestone, 3673,
profiling (2.029 ms) : 2011, 2046
. : milestone, 2029,
tracing (1.833 ms) : 1817, 1849
. : milestone, 1833,
section candidate
no_agent (1.167 ms) : 1155, 1178
. : milestone, 1167,
iast (3.206 ms) : 3166, 3247
. : milestone, 3206,
iast_FULL (5.664 ms) : 5609, 5720
. : milestone, 5664,
iast_GLOBAL (3.493 ms) : 3436, 3551
. : milestone, 3493,
profiling (2.011 ms) : 1994, 2029
. : milestone, 2011,
tracing (1.809 ms) : 1793, 1824
. : milestone, 1809,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~4180892f39, baseline=1.59.0-SNAPSHOT~708daf39d2
dateFormat X
axisFormat %s
section baseline
no_agent (1.476 ms) : 1465, 1488
. : milestone, 1476,
appsec (3.76 ms) : 3538, 3981
. : milestone, 3760,
iast (2.255 ms) : 2186, 2324
. : milestone, 2255,
iast_GLOBAL (2.297 ms) : 2227, 2367
. : milestone, 2297,
profiling (2.114 ms) : 2058, 2171
. : milestone, 2114,
tracing (2.065 ms) : 2012, 2119
. : milestone, 2065,
section candidate
no_agent (1.475 ms) : 1464, 1487
. : milestone, 1475,
appsec (3.736 ms) : 3515, 3957
. : milestone, 3736,
iast (2.252 ms) : 2184, 2321
. : milestone, 2252,
iast_GLOBAL (2.302 ms) : 2232, 2371
. : milestone, 2302,
profiling (2.122 ms) : 2064, 2179
. : milestone, 2122,
tracing (2.073 ms) : 2019, 2127
. : milestone, 2073,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~4180892f39, baseline=1.59.0-SNAPSHOT~708daf39d2
dateFormat X
axisFormat %s
section baseline
no_agent (14.901 s) : 14901000, 14901000
. : milestone, 14901000,
appsec (14.822 s) : 14822000, 14822000
. : milestone, 14822000,
iast (18.451 s) : 18451000, 18451000
. : milestone, 18451000,
iast_GLOBAL (17.807 s) : 17807000, 17807000
. : milestone, 17807000,
profiling (14.883 s) : 14883000, 14883000
. : milestone, 14883000,
tracing (14.74 s) : 14740000, 14740000
. : milestone, 14740000,
section candidate
no_agent (15.306 s) : 15306000, 15306000
. : milestone, 15306000,
appsec (14.835 s) : 14835000, 14835000
. : milestone, 14835000,
iast (18.051 s) : 18051000, 18051000
. : milestone, 18051000,
iast_GLOBAL (17.922 s) : 17922000, 17922000
. : milestone, 17922000,
profiling (14.836 s) : 14836000, 14836000
. : milestone, 14836000,
tracing (14.568 s) : 14568000, 14568000
. : milestone, 14568000,
|
add6730 to
bf924ea
Compare
bf924ea to
e9063f6
Compare
| final boolean hasToolCalls = isNotEmpty(value.getToolCalls(), size); | ||
|
|
||
| final boolean hasContentParts = isNotEmpty(value.getContentParts(), size); | ||
| final boolean hasContent = !hasContentParts && isNotBlank(value.getContent(), size); |
There was a problem hiding this comment.
Can we probably switch the var name to hasContentString? I was confused and I thought it was a boolean to check if there was any content (either content parts or content string)
There was a problem hiding this comment.
Good point. I'll change it. Also reviewing this I realized there's an incorrect edge case here: it's ok to have empty / blank content, so that isNotBlank should probably be just != null.
There was a problem hiding this comment.
Although I will not touch the isNotBlank in this PR, since it's unrelated.
e9063f6 to
4180892
Compare
PerfectSlayer
left a comment
There was a problem hiding this comment.
Looking good. Left a minor comment.
| private final String role; | ||
| private final String content; | ||
| @Nullable private final String content; | ||
| @Nullable private final List<ContentPart> contentParts; |
There was a problem hiding this comment.
🎯 suggestion: What about enforcing non @Nullable collection and use empty ones instead? In particular for public API?
There was a problem hiding this comment.
The thing is only one or the other should be set here, either a plain string content or a list of content parts. In serialization both will be within the content field. Most users will simply set a string instead of a list of content parts.
What Does This Do
Motivation
Support multi-modal prompts (text + images) in AI Guard.
Additional Notes
Validated with system tests at DataDog/system-tests#6131
Reference PR for dd-trace-py at DataDog/dd-trace-py#15939
Contributor Checklist
type:and (comp:orinst:) labels in addition to any useful labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: APPSEC-60264