Skip to content

fix(samples): use latest task in LangGraph HITL conversations - #1139

Open
JiahuiGu (Jiahui-Gu) wants to merge 8 commits into
mainfrom
fix/langgraph-hitl-latest-task
Open

JiahuiGu (Jiahui-Gu) wants to merge 8 commits into
mainfrom
fix/langgraph-hitl-latest-task

Conversation

@Jiahui-Gu

@Jiahui-Gu JiahuiGu (Jiahui-Gu) commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix 07-human-in-the-loop repeatedly drafting from the first user message:

  • Select the latest HumanMessage, preserving structured content.
  • Reset draft/revision history only on a new-task entry; rich feedback revisions retain current-task history.
  • Update only the user-facing graph and task-lifecycle explanation in the sample README.

Regression coverage

  • A shared cloud contract checks two approved tasks in the same conversation.
  • A committed actual-sample/local-HTTP test checks rich function_call_output revision → approve → new task in the same conversation. Exact model-input assertions prove that feedback is applied to the current draft and neither the old draft nor feedback reaches the next task.
  • The model is scripted and the graph checkpointer is in-memory; this local test is not a cloud or UI acceptance claim. No source-string mutation checks are committed.

CI scope at 06f2a9c

The final PR changes only five files: sample implementation, user README, sample cloud contract, positive runtime test, and one narrowly triggered runtime workflow.

The runtime workflow triggers only on this sample's runtime source, its lifecycle regression, or its own workflow file. It installs pinned uv, runs uv sync --frozen --python 3.13 for the committed sample environment, then directly invokes the runtime regression with uv run --no-sync.

There is no runner wrapper or separate wrapper test suite. The existing generic scripts self-test, ADO pipeline/discovery/deployment helpers, skiplists, dependency inputs and locks are unchanged. No failures are hidden through skips or relaxed assertions. Unrelated failing sample jobs are outside this bug-fix PR rather than being patched here.

Validation

  • Positive local HTTP lifecycle regression: 1 passed using the existing local runtime environment.
  • Existing policy-workflow test: 1 passed; existing ADO pipeline fixture tests: 2 passed.
  • Narrow workflow triggers, frozen install-before-execution order, read-only permissions, direct test invocation, and absence of skips verified. Python lint/format and git diff --check pass.
  • Earlier scoped head 58042aea had a successful frozen GitHub runtime test and ADO discovery explicitly reported only two HITL jobs. These are historical results, not current-head cloud claims.
  • Current-head independent runtime workflow 43384072301 succeeded: frozen sample dependencies installed and the real local-HTTP lifecycle regression actually executed (1 test, OK). Cloud results remain separate; no Azure/model, persistence, or UI pass is implied by this scripted-model regression.

@Jiahui-Gu
JiahuiGu (Jiahui-Gu) requested a review from a team as a code owner November 4, 2026 12:34
Copilot AI balanced review requested due to automatic review settings November 4, 2026 12:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the changes to latest-request handling and task-specific state resets.

No open issues 🎉

What changed in this PR

Fixes the LangGraph human-in-the-loop sample so subsequent tasks in the same conversation use the latest user request without carrying over earlier revision history.

Changes:

  • Selects the latest HumanMessage while preserving structured content.
  • Adds a start_task node to reset task-specific state while retaining history during revisions and checkpoint resumes.
  • Updates the graph documentation and adds a shared two-turn behavior contract for sequential approved tasks.
File Description
samples/​python/​hosted-agents/​langgraph/​responses/​07-human-in-the-loop/​src/​langgraph-human-in-the-loop-responses/​main.py Uses the latest user message and resets state for new tasks.
samples/​python/​hosted-agents/​langgraph/​responses/​07-human-in-the-loop/​README.md Documents the entry node and task-versus-revision behavior.
.azure-pipelines/​hosted-agent-tests/​python/​langgraph/​responses/​07-human-in-the-loop/​test-spec.yml Adds a two-turn contract checking that approved drafts follow the current task.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 4, 2026 16:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unconditional runtime imports in the lifecycle test raise ModuleNotFoundError during test discovery because CI installs only policy/helper dependencies, breaking both offline checks and the cloud pipeline.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 4, 2026 17:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block approval of the changes that isolate new tasks from prior drafts and revision history.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 10, 2026 05:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the task-state isolation and regression-testing changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block approval of the changes isolating new tasks from earlier drafts and revision feedback.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 10, 2026 08:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The review has no active issues requiring resolution.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the successive-task state-isolation change.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain to block approval.

No open issues 🎉

Review effort: Balanced

This branch was successfully deployed

1 active deployment
L4-validation — 06f2a9c5 Deployed Nov 13, 2026 by Jiahui-Gu via trusted #974
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.

4 participants