Repository navigation
Go ports of workflow and chunker fixes - #16878
Conversation
…flow#16758) (infiniflow#16792) Port the workflow variable reference regex fix from Python PR infiniflow#16792 to Go. The Python PR widened cpn_id in variable_ref_patt from [a-zA-Z:0-9]+ to [a-zA-Z0-9_:] (adding underscore support for frontend ids like userfillup_abc, retaining colon for legacy DSL ids like UserFillUp:CateInput). Go's internal/agent/runtime/template.go::VarRefPattern already used [a-zA-Z:0-9_]+ (equivalent to [a-zA-Z0-9_:]+), so no regex change is needed. This commit: - Updates the Go comment to reflect Python alignment (removes the stale deviation note). - Adds comprehensive tests in internal/agent/canvas/variable_test.go pinning underscore-bearing, colon-bearing, and legacy cpn_ids, bare {line} non-match, and end-to-end ResolveTemplate/ExtractRefs resolution. All canvas + runtime package tests pass.
…6825) Port of token_chunker.py:347 to the Go TokenChunker. When the upstream emitted chunks (output_format == "chunks", e.g. a TitleChunker feeding into this TokenChunker), consume those chunks rather than the raw parser json_result. Otherwise fall back to the structured json_result. This fixes infiniflow#16812 where a TitleChunker -> TokenChunker chain silently discarded the chapter-level chunks and re-chunked the raw parser output. Co-authored-by: yuzhichang <[email protected]>
📝 WalkthroughWalkthroughThe changes add coverage for widened template variable references, pin the runtime regex string, document its accepted component-ID characters, and update TokenChunker to consume upstream chunks when the requested output format is chunk-based. ChangesTemplate reference matching
TokenChunker input precedence
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/ingestion/component/chunker/token.go (1)
196-221: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMigration history references in comments violate coding guidelines. Both comments reference the Python source as a port origin, which the coding guidelines explicitly discourage ("keep comments aligned with the current runtime path rather than migration history" and "do not add compatibility wording to comments or documentation"). The code logic and test are correct; only the comment wording needs adjustment.
internal/ingestion/component/chunker/token.go#L196-L221: Remove "Port of token_chunker.py:347 —" prefix from the inline comment; keep the behavioral explanation and#16812reference.internal/ingestion/component/chunker/token_test.go#L287-L325: Remove "Go port of the Python" and "(PR#16825)" from the doc comment; keep the#16812reference and test description.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/ingestion/component/chunker/token.go` around lines 196 - 221, Remove migration-history wording from the comments: in internal/ingestion/component/chunker/token.go lines 196-221, remove the “Port of token_chunker.py:347” prefix while retaining the behavior explanation and `#16812` reference; in internal/ingestion/component/chunker/token_test.go lines 287-325, remove “Go port of the Python” and “(PR `#16825`)” while retaining the `#16812` reference and test description. No code changes are needed.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/ingestion/component/chunker/token.go`:
- Around line 196-221: Remove migration-history wording from the comments: in
internal/ingestion/component/chunker/token.go lines 196-221, remove the “Port of
token_chunker.py:347” prefix while retaining the behavior explanation and `#16812`
reference; in internal/ingestion/component/chunker/token_test.go lines 287-325,
remove “Go port of the Python” and “(PR `#16825`)” while retaining the `#16812`
reference and test description. No code changes are needed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e1826354-5bd0-4414-b701-7d2fd987ca86
📒 Files selected for processing (4)
internal/agent/canvas/variable_test.gointernal/agent/runtime/template.gointernal/ingestion/component/chunker/token.gointernal/ingestion/component/chunker/token_test.go
Ports two Python fixes to Go: the variable_ref_patt underscore/colon fix (#16792) and the TokenChunker upstream-chunks fix (#16825). Keeps Go behavior aligned with upstream Python.