Commit e8dfcc9
Pivot: preserve workflow state across run() calls
Replace the prior 'combined message + checkpoint_id in one run()' approach
with a cleaner default: Workflow.run no longer wipes shared state or runner-
context messages between calls. Iteration counting and per-run kwargs still
reset on a fresh-message run; checkpoint and responses runs are continuations
that preserve everything.
This lets a WorkflowAgent be invoked repeatedly on the same instance and
maintain multi-turn context (e.g. accumulated Conversation.messages) without
asking developers to opt in. Hosted-agent multi-turn pattern becomes two
explicit calls: restore-from-checkpoint (drive to idle), then run-with-message.
Key changes:
- _workflow.py: drop _state.clear() and reset_for_new_run() from run().
Reset iteration count and run kwargs on fresh-message runs only.
Restore 'Cannot provide both message and checkpoint_id' validation.
Add async guard: fresh-message run with un-drained pending executor
messages from a prior run is invalid.
- _runner.py: clear _state before import_state in restore_from_checkpoint
so restore is authoritative (import_state merges, not replaces).
- _agent.py: revert checkpoint branch to restore-only (no message forward).
- _responses.py (foundry_hosting): two-call host pattern - restore checkpoint
silently, then run with new user input.
- tests: state-preservation is the new default; rebuild Workflow for clean slate.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent baff7e3 commit e8dfcc9
5 files changed
Lines changed: 137 additions & 72 deletions
File tree
- python/packages
- core
- agent_framework/_workflows
- tests/workflow
- foundry_hosting/agent_framework_foundry_hosting
Lines changed: 7 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
448 | 447 | | |
449 | 448 | | |
450 | | - | |
451 | 449 | | |
452 | 450 | | |
453 | 451 | | |
| |||
457 | 455 | | |
458 | 456 | | |
459 | 457 | | |
460 | | - | |
461 | 458 | | |
462 | 459 | | |
463 | 460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
| |||
Lines changed: 57 additions & 38 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
314 | | - | |
315 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
316 | 321 | | |
317 | | - | |
| 322 | + | |
318 | 323 | | |
319 | | - | |
| 324 | + | |
320 | 325 | | |
321 | 326 | | |
322 | 327 | | |
| |||
345 | 350 | | |
346 | 351 | | |
347 | 352 | | |
348 | | - | |
349 | | - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
350 | 362 | | |
351 | | - | |
352 | | - | |
353 | 363 | | |
354 | 364 | | |
355 | | - | |
356 | | - | |
357 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
358 | 373 | | |
359 | 374 | | |
360 | 375 | | |
| |||
366 | 381 | | |
367 | 382 | | |
368 | 383 | | |
369 | | - | |
| 384 | + | |
370 | 385 | | |
371 | 386 | | |
372 | 387 | | |
373 | | - | |
| 388 | + | |
| 389 | + | |
374 | 390 | | |
375 | 391 | | |
376 | 392 | | |
| |||
443 | 459 | | |
444 | 460 | | |
445 | 461 | | |
446 | | - | |
| 462 | + | |
447 | 463 | | |
448 | 464 | | |
449 | 465 | | |
| |||
455 | 471 | | |
456 | 472 | | |
457 | 473 | | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
| 474 | + | |
| 475 | + | |
462 | 476 | | |
463 | 477 | | |
464 | 478 | | |
| |||
587 | 601 | | |
588 | 602 | | |
589 | 603 | | |
590 | | - | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
591 | 621 | | |
592 | 622 | | |
593 | 623 | | |
594 | 624 | | |
595 | 625 | | |
596 | | - | |
| 626 | + | |
597 | 627 | | |
598 | 628 | | |
599 | 629 | | |
| |||
662 | 692 | | |
663 | 693 | | |
664 | 694 | | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
| 695 | + | |
672 | 696 | | |
673 | 697 | | |
674 | 698 | | |
| |||
682 | 706 | | |
683 | 707 | | |
684 | 708 | | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
| 709 | + | |
| 710 | + | |
691 | 711 | | |
692 | 712 | | |
693 | 713 | | |
| |||
697 | 717 | | |
698 | 718 | | |
699 | 719 | | |
700 | | - | |
| 720 | + | |
701 | 721 | | |
702 | 722 | | |
703 | 723 | | |
704 | 724 | | |
705 | | - | |
706 | | - | |
| 725 | + | |
707 | 726 | | |
708 | 727 | | |
709 | 728 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
491 | | - | |
492 | | - | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
493 | 498 | | |
494 | 499 | | |
495 | 500 | | |
| |||
503 | 508 | | |
504 | 509 | | |
505 | 510 | | |
506 | | - | |
| 511 | + | |
507 | 512 | | |
508 | 513 | | |
509 | 514 | | |
510 | 515 | | |
511 | 516 | | |
512 | | - | |
| 517 | + | |
513 | 518 | | |
514 | 519 | | |
515 | 520 | | |
516 | | - | |
| 521 | + | |
517 | 522 | | |
518 | | - | |
| 523 | + | |
519 | 524 | | |
520 | 525 | | |
521 | 526 | | |
522 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
523 | 534 | | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
529 | 550 | | |
530 | 551 | | |
531 | 552 | | |
| |||
942 | 963 | | |
943 | 964 | | |
944 | 965 | | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
952 | 976 | | |
953 | 977 | | |
954 | 978 | | |
| |||
Lines changed: 24 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
301 | 323 | | |
302 | | - | |
| 324 | + | |
303 | 325 | | |
304 | 326 | | |
305 | 327 | | |
306 | | - | |
307 | 328 | | |
308 | 329 | | |
309 | 330 | | |
| |||
320 | 341 | | |
321 | 342 | | |
322 | 343 | | |
323 | | - | |
| 344 | + | |
324 | 345 | | |
325 | 346 | | |
326 | 347 | | |
327 | | - | |
328 | 348 | | |
329 | 349 | | |
330 | 350 | | |
| |||
0 commit comments