Skip to content

fix(flow): scope human feedback payload to producing router (#9586) - #9590

Open
yy-luck wants to merge 1 commit into
crewAIInc:mainfrom
yy-luck:fix/router-feedback-payload-scope-9586
Open

yy-luck wants to merge 1 commit into
crewAIInc:mainfrom
yy-luck:fix/router-feedback-payload-scope-9586

Conversation

@yy-luck

@yy-luck yy-luck commented Nov 20, 2026

Copy link
Copy Markdown

Related issue

Fixes #9586

Summary

When a Flow records human feedback (or in repeated kickoffs of the same Flow instance), self.last_human_feedback remains stored on the flow. Previously, _execute_listeners and _execute_start_method unconditionally fell back to self.last_human_feedback for any router result payload without checking whether the triggering router was actually the method that produced the feedback. As a result, subsequent ordinary routers (such as an invoice router or a conditional branching router on a second kickoff) had their return values overridden by the earlier HumanFeedbackResult, leading to AttributeError in downstream listeners.

This fix verifies that self.last_human_feedback.method_name matches the triggering method before substituting the router outcome payload with the feedback result. Ordinary routers and later clean kickoffs preserve their own return values as listeners' arguments, while actual @human_feedback(emit=...) routers continue to deliver their feedback payload to their listeners.

Verification

  • Added unit tests verifying that ordinary routers retain their own return value as listener payload when self.last_human_feedback exists from a previous step or run.
  • Verified that routers decorated with @human_feedback continue to correctly deliver their feedback object to downstream listeners.
  • Ran offline reproduction matrix against both ordinary branching and HITL feedback methods.

Additional context

Note: This PR was prepared with AI assistance and verified locally.

@strix-security

strix-security Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Strix Security Review

✅ No open security findings.

PR summary: The PR scopes the flow engine's substitution of the router result with the stored human-feedback object to the method that actually produced that feedback, so ordinary routers and later kickoffs keep their own return values. It also deep-copies declarative state defaults instead of shallow-copying them and gives each flow instance its own id when it inherits a shared class-level state default.

Review summary

No security vulnerabilities found in the changed code. I traced the two new feedback-scoping guards, the deep-copied state defaults and the per-instance id re-minting through their callers and consumers; all three independently validated payload suspicions were rejected because the changed lines only narrow a previously broader substitution, never reach a decision an outside party controls, and the identity/id changes strictly improve per-flow isolation. Two non-security notes for the author: the _execute_listeners guard compares against the loop-invariant entry trigger rather than the router just executed, so a chained @human_feedback(emit=...) router reached through another router's outcome no longer hands its HumanFeedbackResult to its listeners, and on resume the same listener still receives the object — an API-consistency issue worth aligning. Also, the deepcopy fallback catches only TypeError/AttributeError, so a state default whose __deepcopy__ raises anything else now fails flow construction instead of falling back.

Ruled out (4)
  • Can a human feedback object still be substituted into a different, chained router's listener payload?
    The gate compares against the loop-invariant entry trigger rather than the executed router, but the change only narrows the old unconditional substitution, the substituted object is a plain informational dataclass that never carries authorization semantics, and the only way to hit it is flow defini…
  • Does a chained @​human_feedback(emit=...) router lose its feedback payload, causing a listener to treat a rejection as approval?
    Its outcome listeners now receive the collapsed outcome string instead of the feedback object, but the routing decision still comes straight from the reviewer's feedback outside the gate, so listeners only fire for the outcome the review actually produced and a type-mismatched listener fails loudly…
  • Can an outcome label that collides with a method name satisfy the new gate and deliver an unrelated approval?
    The colliding value is fixed in the committed flow definition, method names and labels cannot be set by kickoff inputs, and every scenario the collision enables was already substituted by the broader pre-PR condition.
  • Does building a state model from a schema with a remote $ref let an untrusted party trigger outbound requests from the flow?
    The schema only ever comes from the flow author's definition or a locally read checkpoint, and a party able to edit it can already name Python import references in the same definition, so no privilege boundary is crossed and the diff does not change that path.

Review 1 on this PR · 7ed4706 · requested Nov 20 06:06 UTC when the PR was opened


Reviewed by Strix
Re-run review · Configure security review settings · Try a deeper review with @strix-security /deep

This branch has not been deployed

No deployments
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.

[BUG] Previous human feedback replaces ordinary router payloads, including on later kickoffs

1 participant