Repository navigation
fix: [Agent] A simple agent—configured with a "chat history" setting of 2 turns—fails to access prior context; the large language model responds as if the conversation is just beginning ("This is the start of the conversation"). - #7799
Merged
Conversation
…of 2 turns—fails to access prior context; the large language model responds as if the conversation is just beginning ("This is the start of the conversation").
shaohuzhang1
commented
Nov 10, 2026
| data["nodes"][10]["properties"]["node_data"]["dialogue_number"] = application.dialogue_number | ||
| ## 未查询到知识库指定回复 | ||
| if no_references_setting.get("status") == "designated_answer": | ||
| data["nodes"][6]["properties"]["node_data"]["content"] = no_references_setting.get("value") |
Contributor
Author
There was a problem hiding this comment.
Issues / potential problems
-
Unused local variable
dialogue_number = application.dialogue_numberis added but never used.- Both new assignments still call
application.dialogue_numberdirectly:data["nodes"][5]["properties"]["node_data"]["dialogue_number"] = application.dialogue_number data["nodes"][10]["properties"]["node_data"]["dialogue_number"] = application.dialogue_number
- Either remove the local variable, or use it consistently:
node_data["dialogue_number"] = dialogue_number
-
Possible
AttributeErrorfor legacy / versioned objectsapplication.dialogue_numberis accessed three times. If not allApplication/ApplicationVersionrecords have this field,build_workflowcan fail.- Consider a safe fallback and validation:
dialogue_number = getattr(application, "dialogue_number", None)
- If
Noneis not valid for the workflow schema, define an explicit default or skip assignment.
-
Published-version snapshot consistency
- The code comments say published versions use a snapshot. Confirm that
dialogue_numberis part of theApplicationVersionsnapshot. If it is not versioned, published workflows may use a changing/current value or fail depending on the model. - This matters especially because the same function handles both
ApplicationandApplicationVersion.
- The code comments say published versions use a snapshot. Confirm that
-
Workflow schema compatibility
- Ensure
dialogue_numberis a supported property for thenode_dataof nodes5and10. - If unsupported, workflow validation or frontend loading may fail, or the field may be silently ignored.
- Validate the value type, e.g. non-negative integer, and reject/convert invalid strings.
- Ensure
-
Duplication and hard-coded node indices
- The same property is assigned to two hard-coded nodes. This is already repeated for other fields such as
mcp_servers,application_ids, andtool_ids. - Consider a small helper or loop to reduce missed updates:
for node_index in (5, 10): node_data = data["nodes"][node_index]["properties"]["node_data"] node_data["dialogue_number"] = dialogue_number node_data["mcp_servers"] = application.mcp_servers node_data["application_ids"] = application.application_ids node_data["tool_ids"] = application.tool_ids
- Hard-coded
data["nodes"][5]/[10]is fragile if node order changes. If the workflow format allows it, resolve nodes by ID/type instead of index.
- The same property is assigned to two hard-coded nodes. This is already repeated for other fields such as
Suggested cleanup
dialogue_number = getattr(application, "dialogue_number", None)
for node_index in (5, 10):
node_data = data["nodes"][node_index]["properties"]["node_data"]
node_data["dialogue_number"] = dialogue_number
# optionally set the other common fields here tooTests to add
Applicationwith validdialogue_numberApplicationVersionwith validdialogue_number- Missing /
Nonedialogue_number - Invalid type/value
- Workflow schema validation for nodes
5and10
Overall: the main immediate issue is the unused local variable and repeated direct attribute access. The main longer-term risk is whether dialogue_number is guaranteed, versioned, and schema-compatible for both application types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: [Agent] A simple agent—configured with a "chat history" setting of 2 turns—fails to access prior context; the large language model responds as if the conversation is just beginning ("This is the start of the conversation").