Skip to content

Filter LLM context around loop subgraphs during param completion#398

Open
zhongkaifu wants to merge 1 commit into
mainfrom
codex/clear-llm-context-during-loop-creation
Open

Filter LLM context around loop subgraphs during param completion#398
zhongkaifu wants to merge 1 commit into
mainfrom
codex/clear-llm-context-during-loop-creation

Conversation

@zhongkaifu
Copy link
Copy Markdown
Owner

Motivation

  • Reduce LLM hallucination by scoping the parameter-completion context so loop body information does not leak into unrelated node reasoning.
  • When preparing context for filling node params, ensure only loop-related nodes are visible to the LLM while constructing a loop body and that loop body details are excluded for non-loop nodes.

Description

  • Add index_loop_body_nodes usage and a new _build_global_context_from_nodes helper that builds global context from plain node/edge maps instead of Workflow objects.
  • Introduce _summarize_node_outputs_from_map to extract output_fields for nodes represented as mappings (including loop exports).
  • Rewrite _build_param_context to assemble workflow_dict, compute loop_body_parents, derive loop_related_ids, and filter upstream/context nodes with _allow_node_id so loop subgraph nodes are included only when relevant.
  • Adjust upstream/context summaries to work with mapping-style nodes and edge lists and normalize action_id/params lookups for the LLM-facing payload.

Testing

  • No automated tests were executed as part of this change.
  • Manual validation not included in this PR.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7e99bf447

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1919 to +1923
nodes = [
n
for n in iter_workflow_and_loop_body_nodes(workflow_dict)
if isinstance(n, Mapping)
]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep loop-body param context in sync with updates

By switching _build_param_context to pull from iter_workflow_and_loop_body_nodes, get_param_context can now return payloads for loop body nodes (i.e., nodes with parent_node_id inside a loop). However update_node_params still validates against _build_workflow_for_params(), which builds a Workflow from only top-level nodes and therefore won’t contain those loop body nodes, causing updates to fail with “节点不存在于当前 workflow.” This breaks the param-completion flow for loop body nodes: the LLM can get context but cannot persist the filled params. Consider either excluding loop body nodes here or updating the validation path to include loop body nodes as well.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant