Stream the inference proxy's provider events as they arrive (#263) The proxy buffered the whole provider stream and wrote one SSE body after the vendor finished, so thinking tokens reached clients in one lump at the end of a turn's message — the coder TUI showed nothing while the model reasoned. The Vercel gateway streams reasoning deltas token by token and our decoder already normalizes them; this hop was the buffer. The stream now opens (chunked 200, SSE headers, the grant's lane in x-openagents-model) before the first provider event, and every event is translated and flushed as it arrives. A fallback disclosure corrects the model named on the chunks that follow it, exactly as the body-level attribution did. Costs, accepted and tested: - a provider failure after the stream opened can no longer be a clean 502; it arrives as a terminal provider_failed error frame carrying the same bounded reason class (and upstream status when known) the JSON refusal carried, then [DONE] - the response header can no longer be corrected after the fact, so a call an undisclosed fallback served names the requested lane in the header; the unresolved attribution still lives in the metered usage record (METER-001) and the analytics events The Responses surface already flushed as it happened; both surfaces now agree.
Stream the inference proxy's provider events as they arrive (#263)
Deploy story
What this commit did to the running system — joined from the forge receipt chain, the part a commit page elsewhere cannot show.
- pushed
- by user · WAL seq 473 · 2026-08-27T19:19:59.177981Z
- built
- 2 modules in 164.1 s
- deployed
- live · 2 modules on 3 nodes · push→live 29735.1 s
Changed files
-
modified
lib/openagents_web/controllers/inference_proxy_controller.ex -
modified
test/openagents_web/controllers/inference_proxy_controller_test.exs -
modified
test/openagents_web/controllers/inference_proxy_fallback_test.exs
Diff
3 files changed, +234 -64
lib/openagents_web/controllers/inference_proxy_controller.ex modified +133 -50
@@ -28,9 +28,18 @@ defmodule OpenAgentsWeb.InferenceProxyController do
| 28 | 28 |
|
| 29 | 29 |
|
| 30 | 30 |
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 34 | 43 |
|
| 35 | 44 |
|
| 36 | 45 |
|
@@ -197,24 +206,47 @@ defmodule OpenAgentsWeb.InferenceProxyController do
| 197 | 206 |
|
| 198 | 207 |
|
| 199 | 208 |
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 200 | 218 |
|
| 201 | 219 |
|
| 202 | 220 |
|
| 203 | 221 |
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 210 | 240 |
|
| 211 | 241 |
|
| 212 | 242 |
|
| 243 |
|
|
| 244 |
|
|
| 213 | 245 |
|
| 214 | 246 |
|
| 215 | 247 |
|
| 216 | 248 |
|
| 217 |
|
|
| 249 |
|
|
| 218 | 250 |
|
| 219 | 251 |
|
| 220 | 252 |
|
@@ -234,17 +266,15 @@ defmodule OpenAgentsWeb.InferenceProxyController do
| 234 | 266 |
|
| 235 | 267 |
|
| 236 | 268 |
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
|
| 269 |
|
|
| 242 | 270 |
|
| 243 | 271 |
|
| 272 |
|
|
| 273 |
|
|
| 244 | 274 |
|
| 245 | 275 |
|
| 246 | 276 |
|
| 247 |
|
|
| 277 |
|
|
| 248 | 278 |
|
| 249 | 279 |
|
| 250 | 280 |
|
@@ -268,16 +298,82 @@ defmodule OpenAgentsWeb.InferenceProxyController do
| 268 | 298 |
|
| 269 | 299 |
|
| 270 | 300 |
|
| 271 |
|
|
| 301 |
|
|
| 302 |
|
|
| 303 |
|
|
| 304 |
|
|
| 305 |
|
|
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
|
| 311 |
|
|
| 312 |
|
|
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| 317 |
|
|
| 318 |
|
|
| 319 |
|
|
| 320 |
|
|
| 321 |
|
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 325 |
|
|
| 326 |
|
|
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| 332 |
|
|
| 333 |
|
|
| 334 |
|
|
| 335 |
|
|
| 336 |
|
|
| 337 |
|
|
| 338 |
|
|
| 339 |
|
|
| 272 | 340 |
|
| 341 |
|
|
| 342 |
|
|
| 343 |
|
|
| 344 |
|
|
| 345 |
|
|
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
|
|
| 352 |
|
|
| 353 |
|
|
| 354 |
|
|
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| 358 |
|
|
| 359 |
|
|
| 273 | 360 |
|
| 274 | 361 |
|
| 275 |
|
|
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 362 |
|
|
| 363 |
|
|
| 364 |
|
|
| 365 |
|
|
| 366 |
|
|
| 367 |
|
|
| 368 |
|
|
| 369 |
|
|
| 370 |
|
|
| 371 |
|
|
| 372 |
|
|
| 373 |
|
|
| 280 | 374 |
|
| 375 |
|
|
| 376 |
|
|
| 281 | 377 |
|
| 282 | 378 |
|
| 283 | 379 |
|
@@ -394,53 +490,40 @@ defmodule OpenAgentsWeb.InferenceProxyController do
| 394 | 490 |
|
| 395 | 491 |
|
| 396 | 492 |
|
| 397 |
|
|
| 398 |
|
|
| 399 |
|
|
| 400 |
|
|
| 401 |
|
|
| 402 |
|
|
| 403 |
|
|
| 404 |
|
|
| 405 |
|
|
| 406 |
|
|
| 407 |
|
|
| 493 |
|
|
| 494 |
|
|
| 495 |
|
|
| 496 |
|
|
| 408 | 497 |
|
| 409 | 498 |
|
| 410 | 499 |
|
| 411 |
|
|
| 412 |
|
|
| 413 |
|
|
| 414 |
|
|
| 415 |
|
|
| 416 | 500 |
|
| 417 | 501 |
|
| 418 | 502 |
|
| 419 |
|
|
| 503 |
|
|
| 420 | 504 |
|
| 421 | 505 |
|
| 422 | 506 |
|
| 423 | 507 |
|
| 424 |
|
|
| 425 |
|
|
| 426 |
|
|
| 427 |
|
|
| 428 |
|
|
| 429 |
|
|
| 508 |
|
|
| 509 |
|
|
| 510 |
|
|
| 430 | 511 |
|
| 431 | 512 |
|
| 432 |
|
|
| 513 |
|
|
| 514 |
|
|
| 515 |
|
|
| 433 | 516 |
|
| 434 | 517 |
|
| 435 | 518 |
|
| 436 | 519 |
|
| 437 | 520 |
|
| 438 | 521 |
|
| 439 |
|
|
| 522 |
|
|
| 440 | 523 |
|
| 441 | 524 |
|
| 442 | 525 |
|
| 443 |
|
|
| 526 |
|
|
| 444 | 527 |
|
| 445 | 528 |
|
| 446 | 529 |
|
test/openagents_web/controllers/inference_proxy_controller_test.exs modified +78 -9
@@ -191,6 +191,66 @@ defmodule OpenAgentsWeb.InferenceProxyControllerTest do
| 191 | 191 |
|
| 192 | 192 |
|
| 193 | 193 |
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 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 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
|
| 242 |
|
|
| 243 |
|
|
| 244 |
|
|
| 245 |
|
|
| 246 |
|
|
| 247 |
|
|
| 248 |
|
|
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 194 | 254 |
|
| 195 | 255 |
|
| 196 | 256 |
|
@@ -342,20 +402,29 @@ defmodule OpenAgentsWeb.InferenceProxyControllerTest do
| 342 | 402 |
|
| 343 | 403 |
|
| 344 | 404 |
|
| 345 |
|
|
| 405 |
|
|
| 346 | 406 |
|
| 347 | 407 |
|
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 | 408 |
|
| 352 |
|
|
| 353 |
|
|
| 354 |
|
|
| 409 |
|
|
| 410 |
|
|
| 411 |
|
|
| 412 |
|
|
| 413 |
|
|
| 414 |
|
|
| 415 |
|
|
| 416 |
|
|
| 417 |
|
|
| 418 |
|
|
| 419 |
|
|
| 420 |
|
|
| 355 | 421 |
|
| 356 | 422 |
|
| 357 |
|
|
| 358 |
|
|
| 423 |
|
|
| 424 |
|
|
| 425 |
|
|
| 426 |
|
|
| 427 |
|
|
| 359 | 428 |
|
| 360 | 429 |
|
| 361 | 430 |
|
test/openagents_web/controllers/inference_proxy_fallback_test.exs modified +23 -5
@@ -95,13 +95,25 @@ defmodule OpenAgentsWeb.InferenceProxyFallbackTest do
| 95 | 95 |
|
| 96 | 96 |
|
| 97 | 97 |
|
| 98 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 99 | 108 |
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 109 |
|
|
| 103 | 110 |
|
| 104 | 111 |
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 105 | 117 |
|
| 106 | 118 |
|
| 107 | 119 |
|
@@ -170,7 +182,13 @@ defmodule OpenAgentsWeb.InferenceProxyFallbackTest do
| 170 | 182 |
|
| 171 | 183 |
|
| 172 | 184 |
|
| 173 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 174 | 192 |
|
| 175 | 193 |
|
| 176 | 194 |
|