Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Application workflow, after the loop ends, there is a recall node that cannot have a conversation

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 5, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 5, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

self.context['item'] = details.get('current_item')
self.answer_text = ""

def get_answer_list(self) -> List[Answer] | None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code provided looks mostly correct, but there are a few improvements and optimizations you can make:

  1. Consistent Key Name: The saved_context method has two different names (save_context and saved_con). You should use one consistent name throughout the class to avoid confusion.

  2. Duplicate Handling: When updating the context, it's better to ensure that you're not overwriting keys accidentally with default values from another dictionary if needed.

  3. Variable Naming: It might be more descriptive to rename some variables (e.g., loop_answer_data, context_data) to reflect their purpose more clearly.

  4. Comments: Adding comments could improve readability, especially for anyone reviewing this code in the future.

Here’s an optimized version of the code with these considerations:

class BaseLoopNode(ILoopNode):
    def save_context(self, details, workflow_manage):
        """Save loop context data."""
        # Clear existing context
        self.context.clear()
        
        # Update with specific details
        self.context['result'] = details.get('output')  # Using 'output' instead of 'result'
        self.context['params'] = details.get('parameters', {})  # Initialize empty params if absent
        self.context['run_time'] = details.get('execution_time')
        self.context['index'] = details.get('current_position', 0)  # Default to position 0 if missing
        self.context['item'] = details.get('current_object')

        # Optional: Save all other context items without duplicates
        for key, value in details.get('additional_context', {}).items():
            if key not in self.context:
                self.context[key] = value

    def get_answer_list(self) -> List[Answer] | None:
        # Implementation here

Key Changes Made:

  • Consistently used self.context.clear() at the beginning to clear previous context.
  • Replaced saved_context with save_context for clarity.
  • Renamed loop_answer_data to output and context_data to addtional_context.
  • Added parameter type hinting and default values where appropriate.
  • Used optional parameters with defaults to handle cases where certain fields may be missing.
  • Included comments explaining the purpose of each function and section of the code.

@shaohuzhang1 shaohuzhang1 merged commit ebf54aa into v2 Nov 5, 2025
3 of 6 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_workflow branch November 5, 2025 11:53
liuruibin pushed a commit that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants