Skip to content

feat(runner): native resume_messages on run_task - #100

Merged
divo12 merged 7 commits into
mainfrom
feat/run-task-resume-messages
Aug 16, 2026
Merged

divo12 merged 7 commits into
mainfrom
feat/run-task-resume-messages

Conversation

@divo12

@divo12 divo12 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

User description

Summary

Adds resume_messages to Harness.start_session, Harness.run_role and Harness.run_task (autowired generator head), and exports the public dream.messages types (ConversationMessage, content blocks) for durable-store callers. Resume seeds the live session transcript before send, so the provider sees real prior history (and skips orientation) instead of intent-string injection.

run_task invokes the generator head once per sprint/retry, so a single captured resume_messages would replay the original transcript on every sprint and silently drop the preceding sprint's conversation and tool history. Resume now seeds only the first invocation and each later sprint continues from the completed previous session:

prior_messages = list(resume_messages or ())
async def generator(...):
    result = await harness.run_role(..., resume_messages=prior_messages)
    prior_messages = list(result.messages)   # nonlocal rebind

RunRoleResult gained messages (the completed session transcript) to make that possible.

Type

  • Bug fix
  • Feature
  • Refactor / docs / chore

Checklist

  • Tests added or updated for behaviour changes
  • tests/test_public_api.py updated if the public API changed
  • CHANGELOG.md updated for user-visible changes
  • No secrets, .env.local, or credentials in the diff
  • Scope stays within dream (org/company features belong in sibling repos)

Test plan

  • uv run pytest tests/test_runner/ tests/test_subagents/ tests/test_public_api.py -q — 29 passed
  • New multi-sprint test asserts sprint 2 sees sprint 1's messages
  • uv run ruff check src tests / uv run mypy
  • CI: 4/4 green (3.11–3.14)
  • Chorus follow-up: map ledger conversation_message / tool_callresume_messages and drop intent-injection resume

Notes

Complements dream #92 (FileSessionStore) and chorus #89 (ledger SoT). SecretProxy remains #94.

Link to Devin session: https://app.devin.ai/sessions/4f7deb4af0914056a24a4d660a661713
Requested by: @divo12


CodeAnt-AI Description

Resume conversations from typed message history across sessions and task sprints

What Changed

  • start_session, run_role, and autowired run_task generators can begin with conversation history from a durable store
  • Generator sprints and retries continue with the completed transcript from the previous sprint instead of replaying only the original history
  • Conversation message and content-block types are now available through the public dream API
  • Saved session snapshots still take precedence over supplied history when a session resumes successfully

Impact

✅ Conversations continue from stored history
✅ Generator sprints retain prior tool and assistant messages
✅ Typed transcript support for durable-store integrations

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Seed typed ConversationMessage transcript into generator sessions so
durable stores (chorus ledger, FileSessionStore) can resume without
stuffing history into the intent string.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codeant-ai

codeant-ai Bot commented Aug 7, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Incremental review completed 5bff0d4 Aug 16, 2026 · 18:08 18:08
✅ Reviewed your PR f178483 Aug 07, 2026 · 10:26 10:29

@codeant-ai

codeant-ai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

Co-authored-by: Cursor <cursoragent@cursor.com>
@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Aug 7, 2026
Comment thread src/dream/harness.py
Comment thread src/dream/runner/_generator_head.py Outdated
divo12 and others added 2 commits August 7, 2026 11:05
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@divo12

divo12 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai please review

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown

Greptile Summary

Adds typed transcript resumption across sessions, role runs, and the autowired task generator so durable-store callers can continue prior conversations.

  • Exports public conversation message and content-block types.
  • Sanitizes resumed messages before seeding a session transcript.
  • Carries each completed generator transcript into the next sprint.
  • Returns completed transcripts from role sessions and adds resume-focused tests.

Confidence Score: 4/5

The transcript handoff should be corrected before merging because later generator sprints lose orientation context seen by the first sprint.

The new multi-sprint continuation relies on RunRoleResult.messages, but that snapshot excludes the orientation message inserted only into the engine's local transcript, so resumed provider history differs from the preceding session.

Files Needing Attention: src/dream/runner/_role_session.py

Important Files Changed

Filename Overview
src/dream/session.py Sanitizes and seeds caller-provided resume messages into the live session transcript.
src/dream/runner/_role_session.py Forwards resume messages and returns the session transcript, but the returned history omits engine-only orientation context.
src/dream/runner/_generator_head.py Carries each successful generator session transcript forward into the next sequential sprint.
src/dream/harness.py Exposes resume_messages through session, role, and autowired task entry points.
src/dream/messages.py Introduces a public facade for conversation messages and supported content blocks.

Sequence Diagram

sequenceDiagram
    participant Store as Durable Store
    participant Task as Harness.run_task
    participant Head as Generator Head
    participant Role as Harness.run_role
    participant Session
    participant Provider

    Store->>Task: resume_messages
    Task->>Head: construct with prior transcript
    loop Each sprint
        Head->>Role: prompt + prior_messages
        Role->>Session: start_session(resume_messages)
        Session->>Provider: sanitized history + sprint prompt
        Provider-->>Session: assistant/tool turns
        Session-->>Role: completed transcript
        Role-->>Head: RunRoleResult.messages
        Head->>Head: replace prior_messages
    end
Loading
Prompt To Fix All With AI
### Issue 1
src/dream/runner/_role_session.py:260
**Returned transcript drops orientation**

On an initially cold generator session, the engine inserts the orientation message only into its local transcript, while `session.transcript` does not record it. Returning that incomplete transcript for the next sprint causes the resumed provider context to omit instructions that were present during the preceding sprint.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "refactor: rebind generator transcript st..." | Re-trigger Greptile

Comment thread src/dream/runner/_role_session.py Outdated
final_text="".join(text_chunks),
cost=session.cost,
events=tuple(captured),
messages=tuple(session.transcript),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Returned transcript drops orientation

On an initially cold generator session, the engine inserts the orientation message only into its local transcript, while session.transcript does not record it. Returning that incomplete transcript for the next sprint causes the resumed provider context to omit instructions that were present during the preceding sprint.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/dream/runner/_role_session.py
Line: 260

Comment:
**Returned transcript drops orientation**

On an initially cold generator session, the engine inserts the orientation message only into its local transcript, while `session.transcript` does not record it. Returning that incomplete transcript for the next sprint causes the resumed provider context to omit instructions that were present during the preceding sprint.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

divo12 and others added 3 commits August 16, 2026 23:33
…n_task

Seed typed ConversationMessage transcript before send, and capture
per generator sprint so later sprints keep prior history instead of
replaying a single resume list.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep transcript seeding on cold start and Session-owned rewind indices after the human-rewind merge.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the reviewed current-main implementation while joining the original PR branch without rewriting remote history.
@codeant-ai

codeant-ai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@divo12
divo12 merged commit c474b2c into main Aug 16, 2026
@divo12
divo12 deleted the feat/run-task-resume-messages branch August 16, 2026 18:08

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

divo12 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@codeant-ai codeant-ai Bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant