Skip to content

Add agent DAG management tools and run watches#2113

Merged
yohamta0 merged 12 commits into
mainfrom
codex/agent-dag-manage-watch
May 7, 2026
Merged

Add agent DAG management tools and run watches#2113
yohamta0 merged 12 commits into
mainfrom
codex/agent-dag-manage-watch

Conversation

@yohamta0

@yohamta0 yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add built-in agent tools for DAG definition and DAG run inspection
  • add session-local DAG run watch support to avoid repeated agent polling after enqueue
  • surface agent step chat history in the UI and update the agent prompt to prefer the new tools

Validation

  • go test ./internal/agent ./internal/runtime/builtin/agentstep ./internal/runtime/agent ./internal/cmd ./internal/service/frontend ./internal/service/frontend/api/v1
  • pnpm --dir ui typecheck

Summary by CodeRabbit

  • New Features

    • DAG definition tools (list/get/validate/schema) and DAG run inspection (list/get/read_log/read_messages/diagnose); session-scoped run watches (watch/status/cancel) with assistant notifications; tools auto-enabled when stores/watchers present; chat history now includes agent/chat steps.
  • Bug Fixes

    • Session lifecycle now clears associated DAG run watches on failures/cancellations/cleanup.
  • Tests

    • Extensive tests for DAG tools, watches, diagnostics; Windows test timeout adjustments.
  • Documentation

    • Updated in-chat guidance to use the new DAG tools and workflows.

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: e9b6d2ea-b77b-45c8-8d83-3ce35e8eeaa0

📥 Commits

Reviewing files that changed from the base of the PR and between 419d6ce and ab3e4a1.

📒 Files selected for processing (6)
  • internal/agent/api.go
  • internal/agent/api_test.go
  • internal/agent/dag_manage_test.go
  • internal/agent/dag_run_watch.go
  • internal/agent/session.go
  • internal/agent/system_prompt.txt
✅ Files skipped from review due to trivial changes (1)
  • internal/agent/dag_manage_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/agent/system_prompt.txt
  • internal/agent/dag_run_watch.go
  • internal/agent/api.go

📝 Walkthrough

Walkthrough

Adds dag_def_manage and dag_run_manage agent tools, an in-memory session-local DAG run watch registry, context/ToolConfig/API/Session/runtime wiring for DAG stores/watchers, UI/prompt updates, and tests covering management and watch behaviors.

Changes

DAG Management Agent Tools

Layer / File(s) Summary
Context helpers & ToolConfig
internal/agent/contextkeys.go, internal/agent/tool_registry.go, internal/cmd/agent.go, internal/runtime/agent/agent.go, internal/runtime/builtin/agentstep/executor.go
Adds With/GetDAGStore, With/GetDAGRunStore, extends ToolConfig with DAGStore/DAGRunStore/DAGRunWatcher, and wires DAG stores into API/runtime initialization.
dag_def_manage tool
internal/agent/dag_def_manage.go
Adds read-only DAG definition inspection tool with JSON actions: list, get, validate, schema, plus compact summaries and validation-error normalization.
dag_run_manage tool
internal/agent/dag_run_manage.go
Adds JSON dispatcher and handlers for list, get, read_log, read_messages, diagnose, watch, watch_status, and cancel_watch; builds run/status/log payloads and validates store/watcher availability per action.
Watcher types & registry
internal/agent/dag_run_watch.go
Defines DAGRunWatcher interface and types; implements an in-memory registry with Watch/Status/Cancel, polling, dedupe, expiry/pruning, ClearSession, and notification formatting; exposes (*API) notifyDAGRunWatch.
API & Session wiring
internal/agent/api.go, internal/agent/session.go, internal/service/frontend/server.go
Extends API/APIConfig and SessionManagerConfig with DAG stores/watchers; NewAPI registers/auto-creates watcher when appropriate; runtime/server wiring injects DAG stores and adapts remote resolver.
API helpers
internal/agent/api.go
Adds prepareInternalSessionRuntime and enqueueInternalAgentMessage; adds clearDAGRunWatchesForSession invoked on session create/compact/cancel/idle-cleanup and session deletion paths.
UI & Prompt
ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx, internal/agent/system_prompt.txt
ChatHistoryTab includes agent executor nodes in historySteps and refines selection behavior; system prompt updated to reference new DAG definition/run tools and workflows.
Tests & Platform tweaks
internal/agent/dag_manage_test.go, internal/agent/api_test.go, internal/agent/tool_registry_test.go, engine_test.go, internal/core/spec/*_test.go
Adds extensive tests for dag_run_manage/dag_def_manage/watch registry and API notify; provides fakes/helpers; updates expected registered tools; adjusts engine/spec tests for Windows.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Agent as Agent LLM
    participant SessionMgr as Session Manager
    participant Tool as dag_run_manage Tool
    participant DAGRunStore
    participant Logger

    User->>Agent: Query DAG run status
    Agent->>SessionMgr: Invoke dag_run_manage (action: "list")
    SessionMgr->>Tool: Call Run() with JSON input
    Tool->>DAGRunStore: List runs with filters
    DAGRunStore-->>Tool: Return paginated runs
    Tool->>Logger: Read step logs & messages
    Logger-->>Tool: Return log content
    Tool-->>SessionMgr: Return JSON response (runs, logs, cursor)
    SessionMgr-->>Agent: Tool output
    Agent-->>User: Formatted DAG status report
Loading
sequenceDiagram
    actor User
    participant Agent as Agent LLM
    participant SessionMgr as Session Manager
    participant Tool as dag_run_manage Tool
    participant Registry as Watch Registry
    participant DAGRunStore
    participant Notifier

    User->>Agent: Monitor DAG run (action: "watch")
    Agent->>SessionMgr: Invoke dag_run_manage
    SessionMgr->>Tool: Call Run() with watch request
    Tool->>Registry: Watch(dagName, runId, notifyOn)
    Registry->>DAGRunStore: Read current run status
    DAGRunStore-->>Registry: Return status
    Registry->>Registry: Start polling goroutine
    Registry-->>Tool: Return watchId
    Tool-->>Agent: {"watch": "started", "watchId": "..."}

    loop Poll interval
        Registry->>DAGRunStore: Check run status
        alt Terminal state detected
            Registry->>Registry: Mark completed
            Registry->>Notifier: formatDAGRunWatchNotification()
            Notifier->>SessionMgr: AppendExternalMessage()
            SessionMgr-->>Agent: External notification
        else Still running
            Registry->>Registry: Update cached status
        end
    end

    User->>Agent: Check watch status
    Agent->>SessionMgr: Invoke dag_run_manage (action: "watch_status")
    SessionMgr->>Registry: Status(watchId)
    Registry-->>Agent: Return latest status & timestamps
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • dagucloud/dagu#2013: Both PRs modify and rewire DAG persistence and run/store APIs; the new DAG tools/watcher wiring here may need to align with changes in #2013.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% 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 'Add agent DAG management tools and run watches' accurately summarizes the main changes: two new agent tools (dag_def_manage and dag_run_manage) and session-local DAG run watch support to eliminate repeated polling.
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/agent-dag-manage-watch

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx (1)

1-5: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing GPL v3 license header.

The file is missing the required GPL v3 license header. As per coding guidelines (**/*.{go,ts,tsx,js}): apply GPL v3 license headers on source files, managed via make addlicense.

Run make addlicense to add the license header automatically.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx` around lines
1 - 5, The file ChatHistoryTab.tsx is missing the required GPL v3 license
header; run the repository license tool (make addlicense) to insert the standard
header into this source file, or manually add the GPL v3 header comment at the
top of ChatHistoryTab.tsx so all exported identifiers (e.g., the ChatHistoryTab
component, imports like StepMessagesTable, isActiveNodeStatus, and any top-level
functions) are covered by the license; ensure the header matches the project's
standard used for .ts/.tsx files.
🧹 Nitpick comments (1)
ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx (1)

45-54: ⚡ Quick win

useEffect resets user selection on every defaultStep change.

The effect unconditionally overwrites selectedStep whenever defaultStep changes (e.g., any time a node finishes). A user who manually picked a step mid-run will have their selection silently replaced. Consider tracking whether the user has explicitly chosen a step and skipping the reset in that case.

♻️ Suggested approach
+ const [userSelected, setUserSelected] = useState(false);
  const [selectedStep, setSelectedStep] = useState<string | undefined>(defaultStep);

  useEffect(() => {
-   if (defaultStep) {
-     setSelectedStep(defaultStep);
-   }
+   if (defaultStep && !userSelected) {
+     setSelectedStep(defaultStep);
+   }
  }, [defaultStep, userSelected]);

  // in the onChange handler:
- onChange={(e) => setSelectedStep(e.target.value)}
+ onChange={(e) => { setUserSelected(true); setSelectedStep(e.target.value); }}

You may also want to reset userSelected when the dagRun.dagRunId changes (new run opened).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx` around lines
45 - 54, The current useEffect unconditionally sets selectedStep from
defaultStep on every change, which overwrites a user's manual choice; add a
boolean state (e.g., userSelected) and set it to true when the user calls
setSelectedStep manually, update the effect in ChatHistoryTab to only copy
defaultStep into selectedStep when userSelected is false (or when the active run
changes), and reset userSelected to false when dagRun.dagRunId (or whichever run
identifier is used) changes so defaultStep can apply for a new run.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/agent/api.go`:
- Around line 191-193: The shared DAGRunWatchRegistry created in
api.dagRunWatcher via newDAGRunWatchRegistry(api.dagRunStore,
api.notifyDAGRunWatch, api.logger) lacks teardown handling so canceled/cleaned
sessions keep their watches; add explicit cleanup hooks to unregister watches
when a session ends (e.g., add a RemoveSessionWatches(sessionID) or
Clear(sessionID) method on DAGRunWatchRegistry and call it from the session
teardown/Cancel/Close path), ensure notifyDAGRunWatch or session lifecycle code
invokes that removal, and update DAGRunWatchRegistry to stop any background
pollers for that session to prevent stale polling against dagRunStore.

In `@internal/agent/dag_def_manage.go`:
- Around line 159-161: The loop over result.Items can panic because it
dereferences dag.Name without checking for nil; modify the for loop that builds
items to guard each dag: for each element in result.Items, first check if dag ==
nil and either skip it or construct a safe fallback entry, then call
summarizeDAGDefinition and store.IsSuspended only when dag is non-nil (using
dag.Name). Ensure the references to summarizeDAGDefinition and
store.IsSuspended(dag.Name) are moved inside the nil-check so nil items are not
dereferenced.

In `@internal/agent/dag_run_watch.go`:
- Around line 315-323: The polling loop currently calls readStatus(...) and
complete(...) with context.Background(), which prevents cancellation and can
leak poll goroutines; change both calls to use a cancellable/timeout context
derived from the watch's parent context (e.g., use the ctx variable for the
goroutine or create one with context.WithTimeout(parentCtx, timeout) and defer
cancel()) so store reads and completion respect cancellation/deadline; update
the calls to readStatus(ctx, req.DAGName, ...) and complete(ctx, watchID,
status) and ensure you cancel the derived context to avoid leaks.

---

Outside diff comments:
In `@ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx`:
- Around line 1-5: The file ChatHistoryTab.tsx is missing the required GPL v3
license header; run the repository license tool (make addlicense) to insert the
standard header into this source file, or manually add the GPL v3 header comment
at the top of ChatHistoryTab.tsx so all exported identifiers (e.g., the
ChatHistoryTab component, imports like StepMessagesTable, isActiveNodeStatus,
and any top-level functions) are covered by the license; ensure the header
matches the project's standard used for .ts/.tsx files.

---

Nitpick comments:
In `@ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx`:
- Around line 45-54: The current useEffect unconditionally sets selectedStep
from defaultStep on every change, which overwrites a user's manual choice; add a
boolean state (e.g., userSelected) and set it to true when the user calls
setSelectedStep manually, update the effect in ChatHistoryTab to only copy
defaultStep into selectedStep when userSelected is false (or when the active run
changes), and reset userSelected to false when dagRun.dagRunId (or whichever run
identifier is used) changes so defaultStep can apply for a new run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a8621d50-51e2-44b4-a1fd-c6d597bda508

📥 Commits

Reviewing files that changed from the base of the PR and between fd33bdd and 962a4df.

📒 Files selected for processing (15)
  • internal/agent/api.go
  • internal/agent/contextkeys.go
  • internal/agent/dag_def_manage.go
  • internal/agent/dag_manage_test.go
  • internal/agent/dag_run_manage.go
  • internal/agent/dag_run_watch.go
  • internal/agent/session.go
  • internal/agent/system_prompt.txt
  • internal/agent/tool_registry.go
  • internal/agent/tool_registry_test.go
  • internal/cmd/agent.go
  • internal/runtime/agent/agent.go
  • internal/runtime/builtin/agentstep/executor.go
  • internal/service/frontend/server.go
  • ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx

Comment thread internal/agent/api.go
Comment thread internal/agent/dag_def_manage.go Outdated
Comment thread internal/agent/dag_run_watch.go Outdated

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
internal/agent/dag_run_manage.go (1)

287-307: ⚡ Quick win

Add validation to reject conflicting last and from parameters.

When both last and from are supplied, the handler appends two exec.WithFrom() options where the second (from args.From) silently overrides the first (from args.Last). The codebase already validates this in cmd/history.go (line 207), rejecting the combination with: cannot use --last with --from or --to (conflicting time range specifications). Follow the same pattern in dagRunManageList() for consistency and to prevent LLM agents from experiencing silent override on semantically conflicting parameters.

♻️ Suggested validation
+	if args.Last != "" && args.From != "" {
+		return toolError("specify either last or from, not both")
+	}
 	if args.Last != "" {
 		from, err := parseDAGManageRelativeTime(args.Last, time.Now())
 		if err != nil {
 			return toolError("%v", err)
 		}
 		opts = append(opts, exec.WithFrom(exec.NewUTC(from)))
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/agent/dag_run_manage.go` around lines 287 - 307, In
dagRunManageList(), add a pre-validation that rejects conflicting time flags by
returning toolError when args.Last is set together with args.From or args.To
(e.g., if args.Last != "" && (args.From != "" || args.To != "")), mirroring
cmd/history.go’s message "cannot use --last with --from or --to (conflicting
time range specifications)"; perform this check before any
parseDAGManageRelativeTime/parseDAGManageAbsoluteTime calls so you avoid
appending multiple exec.WithFrom() options and silent overrides.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/agent/dag_run_manage.go`:
- Around line 287-307: In dagRunManageList(), add a pre-validation that rejects
conflicting time flags by returning toolError when args.Last is set together
with args.From or args.To (e.g., if args.Last != "" && (args.From != "" ||
args.To != "")), mirroring cmd/history.go’s message "cannot use --last with
--from or --to (conflicting time range specifications)"; perform this check
before any parseDAGManageRelativeTime/parseDAGManageAbsoluteTime calls so you
avoid appending multiple exec.WithFrom() options and silent overrides.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1c68eeaf-fa9f-4d91-8184-36571099f44f

📥 Commits

Reviewing files that changed from the base of the PR and between 962a4df and 7159356.

📒 Files selected for processing (6)
  • internal/agent/api.go
  • internal/agent/dag_def_manage.go
  • internal/agent/dag_manage_test.go
  • internal/agent/dag_run_manage.go
  • internal/agent/dag_run_watch.go
  • ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx
  • internal/agent/dag_manage_test.go
  • internal/agent/dag_run_watch.go
  • internal/agent/dag_def_manage.go

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx (1)

28-28: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Stale comment — update to reflect agent steps

The comment says "Determine default selected step: last finished chat step" but the step pool now includes agent nodes too.

✏️ Proposed fix
-  // Determine default selected step: last finished chat step
+  // Determine default selected step: last finished chat/agent step
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx` at line 28,
Update the stale comment in ChatHistoryTab.tsx to reflect that the step pool
includes agent nodes now—replace "Determine default selected step: last finished
chat step" with a clearer note such as "Determine default selected step: last
finished step (includes chat and agent steps)" so the comment accurately
documents the selection logic for the step pool used by ChatHistoryTab.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/agent/dag_run_watch.go`:
- Around line 320-335: The notifyCtx created in poll is derived from the watch's
ctx so when complete calls entry.cancel() it cancels notifyCtx before r.notify
runs; change poll to create an independent timeout context for notification
(e.g., use context.WithTimeout(context.Background(), r.pollTimeout()) instead of
deriving from ctx) so r.notify(notifyCtx, ...) and AppendExternalMessage run
with a non-canceled root, or alternatively modify complete to delay calling
entry.cancel() until after r.notify returns; update the code around poll,
notifyCtx, complete, entry.cancel and the r.notify call accordingly.

In `@ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx`:
- Around line 68-69: The selectedStep can become stale when historySteps
changes; ensure you guard against a missing selection by computing a
resolvedStep (e.g., check whether historySteps contains a step with name ===
selectedStep and if not fall back to defaultStep) or by resetting state (call
setSelectedStep(defaultStep) inside a useEffect when the selected name is
absent); use resolvedStep instead of selectedStep for the select value, for
deriving selectedNode (find by resolvedStep), for computing isSelectedActive
(use isActiveNodeStatus on the resolved node), and when rendering
StepMessagesTable so you never pass a non-existent step name downstream.

---

Outside diff comments:
In `@ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx`:
- Line 28: Update the stale comment in ChatHistoryTab.tsx to reflect that the
step pool includes agent nodes now—replace "Determine default selected step:
last finished chat step" with a clearer note such as "Determine default selected
step: last finished step (includes chat and agent steps)" so the comment
accurately documents the selection logic for the step pool used by
ChatHistoryTab.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d5f617d3-42eb-452e-b6a1-affbac9f5d78

📥 Commits

Reviewing files that changed from the base of the PR and between fd33bdd and 7159356.

📒 Files selected for processing (15)
  • internal/agent/api.go
  • internal/agent/contextkeys.go
  • internal/agent/dag_def_manage.go
  • internal/agent/dag_manage_test.go
  • internal/agent/dag_run_manage.go
  • internal/agent/dag_run_watch.go
  • internal/agent/session.go
  • internal/agent/system_prompt.txt
  • internal/agent/tool_registry.go
  • internal/agent/tool_registry_test.go
  • internal/cmd/agent.go
  • internal/runtime/agent/agent.go
  • internal/runtime/builtin/agentstep/executor.go
  • internal/service/frontend/server.go
  • ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx

Comment thread internal/agent/dag_run_watch.go
Comment thread ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx Outdated
@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/agent/dag_run_manage.go`:
- Around line 379-386: The diagnose path currently only falls back to
node.ChatMessages when attempt.ReadStepMessages returns an empty slice; change
both call sites (the one around ReadStepMessages at the top of the snippet and
the second site around lines 431-435) so that any non-nil error from
attempt.ReadStepMessages also triggers the same fallback: if ReadStepMessages
returns an error or an empty slice, try status.NodeByName(args.StepName) and
assign node.ChatMessages to messages when available; update dagRunManageDiagnose
and the surrounding logic that uses messages to preserve chat history on read
failures.
- Around line 349-352: The code currently calls
normalizeDAGRunLogStream(args.Stream) which defaults an empty stream to
"scheduler", so a read_log request with a stepName but no stream will
incorrectly return the run/scheduler log; change the guard to fail fast when a
step-specific read is requested without an explicit stream: check the raw
args.Stream (not the normalized value) and if args.StepName is non-empty and
args.Stream is empty, return a toolError indicating that a stream is required
for step logs (e.g., in the same block that currently calls
normalizeDAGRunLogStream), otherwise continue to normalize and validate the
stream as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 441905df-2abd-4a46-b4aa-d87d0fd7d873

📥 Commits

Reviewing files that changed from the base of the PR and between 7159356 and f4b8535.

📒 Files selected for processing (4)
  • internal/agent/dag_manage_test.go
  • internal/agent/dag_run_manage.go
  • internal/agent/dag_run_watch.go
  • ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • ui/src/features/dags/components/chat-history/ChatHistoryTab.tsx
  • internal/agent/dag_run_watch.go

Comment thread internal/agent/dag_run_manage.go
Comment thread internal/agent/dag_run_manage.go Outdated
@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/agent/dag_manage_test.go`:
- Around line 182-195: The test reuses the map variable `got` across two
json.Unmarshal calls which can leave stale keys (like "messages") from the first
payload and yield false positives; fix it by resetting or re-declaring `got`
before the second Unmarshal (e.g., assign got = nil or declare a new var) so the
second call to json.Unmarshal into `got` (used after the second runJSONTool(...)
call) cannot see leftover keys from the prior parse; update the test in
internal/agent/dag_manage_test.go around the second json.Unmarshal to
clear/recreate `got`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 59b31f07-c6f9-4fc9-a5d1-f5d0406eb17d

📥 Commits

Reviewing files that changed from the base of the PR and between f4b8535 and cd8ea1d.

📒 Files selected for processing (2)
  • internal/agent/dag_manage_test.go
  • internal/agent/dag_run_manage.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/agent/dag_run_manage.go

Comment thread internal/agent/dag_manage_test.go Outdated
@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0

yohamta0 commented May 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yohamta0 yohamta0 merged commit 94bf7c0 into main May 7, 2026
11 checks passed
@yohamta0 yohamta0 deleted the codex/agent-dag-manage-watch branch May 7, 2026 10:40
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