Skip to content

Prevent duplicate Deep Agents messages after continue-as-new - #1804

Open
1fanwang wants to merge 2 commits into
temporalio:mainfrom
1fanwang:1fannnw/deepagents-can-message-carry
Open

Prevent duplicate Deep Agents messages after continue-as-new#1804
1fanwang wants to merge 2 commits into
temporalio:mainfrom
1fanwang:1fannnw/deepagents-can-message-carry

Conversation

@1fanwang

@1fanwang 1fanwang commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Long-running Deep Agents workflows can use run_deep_agent to carry conversation
state through continue-as-new. Before this fix, each new run appended the original
input messages to the saved history, so the initial user prompt appeared again after
every rollover. The workflow now resumes from the saved message list once.

State restoration replaces the input's messages field with the snapshot while
preserving the other input fields.

Testing

The regression test starts a real Temporal dev server and forces two
continue-as-new boundaries.

Before
$ git checkout upstream/main -- temporalio/contrib/deepagents/workflow.py
$ uv run pytest tests/contrib/deepagents/test_continue_as_new.py::test_can_threshold_and_cache -vv --tb=short --no-header
E   AssertionError: {'messages': ['start', 'step', 'start', 'step', 'start', 'step', ...], 'todos': [{'content': 'work', 'status': 'completed'}]}
E   assert ['start', 'step', 'start', 'step', 'start', 'step', 'start', 'step'] == ['start', 'step', 'step', 'step']
Results (3.99s):
         1 failed
After
$ git checkout HEAD -- temporalio/contrib/deepagents/workflow.py
$ uv run pytest tests/contrib/deepagents/test_continue_as_new.py::test_can_threshold_and_cache -q --no-header
.                                                                        [100%]
Results (4.15s):
         1 passed

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
@1fanwang
1fanwang requested review from a team as code owners September 2, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant