Commit 4df96ec
temporal-spring-ai: pass provider-specific ChatOptions through the activity boundary
Serialize the caller's ChatOptions as (class name, JSON) on the workflow
side and rehydrate the exact subclass on the activity side. Every field
survives — including provider-specific ones like OpenAI
reasoning_effort or Anthropic thinking-budget settings — without the
plugin needing per-provider allow-lists, reflection into builder types,
or compile deps on spring-ai-openai/anthropic/etc.
Changes:
- ChatModelTypes.ModelOptions: two new nullable fields,
chatOptionsClass and chatOptionsJson. Older callers that only set
the common scalar fields still work via a convenience constructor.
- ActivityChatModel: serialize the caller's ChatOptions with a plain
ObjectMapper when non-null; a Jackson mixin skips the tool-callback
bag (toolCallbacks/toolNames/toolContext) since those cross the
boundary via the separate `tools` field. Serialization failure is
logged at debug and leaves the blob fields null — activity side then
uses the common-field path.
- ChatModelActivityImpl: primary path rehydrates from the serialized
blob and, if the result is a ToolCallingChatOptions, re-attaches the
stub tool callbacks plus forces internalToolExecutionEnabled=false.
Fallback path (no blob, class-not-found, deser error) builds a plain
ToolCallingChatOptions from the common scalar fields, identical to
the prior behavior.
Tests:
- ProviderOptionsPassthroughTest.customChatOptionsSubclass... — a
test-local CustomChatOptions extending DefaultToolCallingChatOptions
with an extra reasoningEffort field round-trips, and common fields
(temperature/maxTokens) come through the same path.
- ProviderOptionsPassthroughTest.nullChatOptions... — workflow that
doesn't set any options still works via the fallback path.
The workflow calls ActivityChatModel.call(new Prompt(...)) directly
instead of going through ChatClient, because ChatClient.defaultOptions
coerces the caller's subclass into the client's internal options type
before ActivityChatModel ever sees it. Users of ChatClient who want
provider-specific options should set those on the ChatModel bean's
default options (Spring AI merges those into every call).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 979b752 commit 4df96ec
4 files changed
Lines changed: 430 additions & 18 deletions
File tree
- temporal-spring-ai/src
- main/java/io/temporal/springai
- activity
- model
- test/java/io/temporal/springai
Lines changed: 102 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| |||
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
33 | 56 | | |
34 | 57 | | |
35 | 58 | | |
| |||
77 | 100 | | |
78 | 101 | | |
79 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
80 | 129 | | |
81 | 130 | | |
82 | 131 | | |
| |||
93 | 142 | | |
94 | 143 | | |
95 | 144 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 145 | + | |
108 | 146 | | |
109 | 147 | | |
110 | 148 | | |
111 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
112 | 165 | | |
113 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
114 | 202 | | |
115 | 203 | | |
116 | 204 | | |
| |||
Lines changed: 46 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
80 | 108 | | |
81 | 109 | | |
82 | 110 | | |
| |||
226 | 254 | | |
227 | 255 | | |
228 | 256 | | |
229 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
230 | 260 | | |
231 | 261 | | |
232 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
233 | 275 | | |
234 | 276 | | |
235 | 277 | | |
| |||
239 | 281 | | |
240 | 282 | | |
241 | 283 | | |
242 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
243 | 287 | | |
244 | 288 | | |
245 | 289 | | |
| |||
Lines changed: 42 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
| |||
188 | 199 | | |
189 | 200 | | |
190 | 201 | | |
191 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
192 | 232 | | |
0 commit comments