Skip to content

feat: carry push-back context into AI steps#2109

Merged
yottahmd merged 1 commit intomainfrom
codex/pushback-context
May 6, 2026
Merged

feat: carry push-back context into AI steps#2109
yottahmd merged 1 commit intomainfrom
codex/pushback-context

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented May 6, 2026

Summary

  • carry push-back iteration and feedback through AI step re-execution without DAG glue
  • preserve previous stdout log paths for rewound harness steps and expose them via env/prompt context
  • restore prior chat/agent conversation context for push-back re-execution, including rewind-to upstream AI steps

Validation

  • go test ./internal/service/frontend/api/v1 -run TestApplyPushBackRewindToResetsNamedStepAndDependents
  • go test ./internal/runtime -run 'TestSetupPushBackConversation|TestPushBackInputsExposeJSONHistoryEnv'
  • go test ./internal/runtime/builtin/harness ./internal/runtime/builtin/chat ./internal/runtime/builtin/agentstep
  • go test ./internal/runtime/transform ./internal/core/exec ./internal/proto/convert
  • go test ./internal/service/coordinator ./internal/runtime/executor
  • go test ./internal/intg -run 'TestApprovalPushBack|Test.*Approval'
  • git diff --check

Summary by CodeRabbit

Release Notes

  • New Features
    • Push-back iterations now preserve and expose previous step output logs for reviewer reference during step rewinding and resumption.
    • Enhanced reviewer feedback handling for chat and harness-based steps with improved iteration context tracking during push-back operations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4af9cabb-5ae1-410e-a423-9c0a2bd06323

📥 Commits

Reviewing files that changed from the base of the PR and between 129d2f0 and c19ea1d.

📒 Files selected for processing (15)
  • internal/core/exec/env.go
  • internal/core/exec/node.go
  • internal/runtime/builtin/chat/executor.go
  • internal/runtime/builtin/chat/executor_test.go
  • internal/runtime/builtin/harness/harness.go
  • internal/runtime/builtin/harness/harness_test.go
  • internal/runtime/data.go
  • internal/runtime/executor/executor.go
  • internal/runtime/export_test.go
  • internal/runtime/node.go
  • internal/runtime/runner.go
  • internal/runtime/runner_test.go
  • internal/runtime/transform/node.go
  • internal/service/frontend/api/v1/dagruns.go
  • internal/service/frontend/api/v1/dagruns_internal_test.go

📝 Walkthrough

Walkthrough

This PR adds support for capturing and propagating the previous stdout of rewound DAG nodes during push-back iterations. New environment variables, node fields, and executor interfaces enable chat and harness executors to access previous stdout when re-executing steps with reviewer feedback.

Changes

Push-Back Previous Stdout Propagation

Layer / File(s) Summary
Data Shape
internal/core/exec/env.go, internal/core/exec/node.go, internal/runtime/data.go
New constants EnvKeyDAGPushBackIteration and EnvKeyDAGPushBackPreviousStdoutFile added. Node struct gains PushBackPreviousStdout field to store stdout path. NodeState gains matching PushBackPreviousStdout field for runtime state.
Interfaces & Contracts
internal/runtime/executor/executor.go
New public interface PushBackPreviousStdoutAware added with SetPushBackPreviousStdout(path string) method to allow executors to receive previous stdout context.
Chat Executor Push-Back
internal/runtime/builtin/chat/executor.go
Executor gains pushBackInputs and pushBackIteration fields. Implements PushBackAware, SubRunProvider, and ToolDefinitionProvider. New SetPushBackContext API exposes push-back inputs and iteration. executionMessages path evaluates messages and optionally injects feedback as a system+user message. New systemMessages and formatPushBackFeedback helpers format reviewer feedback with approved keys.
Harness Executor Push-Back
internal/runtime/builtin/harness/harness.go
Executor struct expanded with pushBackInputs, pushBackIteration, pushBackPreviousStdout. Implements PushBackAware and PushBackPreviousStdoutAware. New SetPushBackContext and SetPushBackPreviousStdout methods configure push-back state. effectivePrompt() augments the prompt with push-back context, sorted feedback keys, and optional previous stdout log path. Command invocation uses effective prompt instead of raw prompt.
Runtime Wiring
internal/runtime/runner.go, internal/runtime/node.go
Runner injects DAG_PUSHBACK_ITERATION and DAG_PUSHBACK_PREVIOUS_STDOUT_FILE environment variables for AI-enabled steps. Node.Execute propagates previous stdout to executors implementing PushBackPreviousStdoutAware when approval iteration is active.
State Propagation
internal/runtime/transform/node.go
Transform layer includes PushBackPreviousStdout in NodeState and exec.Node construction, enabling round-trip persistence and retrieval.
API Layer
internal/service/frontend/api/v1/dagruns.go
setPushBackContext signature updated to accept previousStdout parameter. Push-back rewind logic captures node's previous stdout before resetting and stores it on the node state via new field.
Tests
internal/runtime/builtin/chat/executor_test.go, internal/runtime/builtin/harness/harness_test.go, internal/runtime/runner_test.go, internal/runtime/export_test.go, internal/service/frontend/api/v1/dagruns_internal_test.go
New chat executor test validates push-back message flow with feedback. New harness test validates prompt augmentation with log path reference. Runner tests added for chat/agent step push-back and extended environment variable handling. Export test helper SetPushBackPreviousStdout added. DAG runs test updated with previous stdout assertions across node indices.

Sequence Diagram

sequenceDiagram
    participant DagAPI as DAG API<br/>(dagruns.go)
    participant Runner as Runner<br/>(runner.go)
    participant Node as Node<br/>(node.go)
    participant Executor as Executor<br/>(chat/harness)
    participant State as State<br/>(data.go)

    DagAPI->>DagAPI: Capture node.Stdout<br/>before reset
    DagAPI->>DagAPI: Call setPushBackContext<br/>with previousStdout
    DagAPI->>State: Store PushBackPreviousStdout<br/>in NodeState
    
    Runner->>Runner: setupNodeExecutionEnv
    Runner->>Runner: Inject env vars:<br/>DAG_PUSHBACK_ITERATION<br/>DAG_PUSHBACK_PREVIOUS_STDOUT_FILE
    
    Node->>Executor: Execute command
    Executor->>Executor: Check if implements<br/>PushBackPreviousStdoutAware
    
    Node->>Executor: SetPushBackPreviousStdout(path)<br/>if ApprovalIteration > 0
    
    Executor->>Executor: Use previous stdout<br/>in message/prompt<br/>construction
    Executor->>Executor: Format feedback<br/>with context
    Executor->>Executor: Augment prompt<br/>with log reference
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • dagucloud/dagu#2080: Modifies the same runner environment setup for push-back (internal/runtime/runner.go), injecting push-back-related env vars before precondition evaluation.
  • dagucloud/dagu#2038: Extends push-back machinery at the code level across the same files (internal/core/exec/env.go, internal/core/exec/node.go, runtime runner/transform paths), managing push-back-related env vars and node state.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: carry push-back context into AI steps' accurately summarizes the main change: enabling push-back iteration, feedback, and previous stdout context to be propagated through AI step re-execution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/pushback-context

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yottahmd yottahmd merged commit 7a25852 into main May 6, 2026
10 checks passed
@yottahmd yottahmd deleted the codex/pushback-context branch May 6, 2026 14:52
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