Skip to content

Go ports of workflow and chunker fixes - #16878

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
yuzhichang:agent-go-port
Jul 13, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
yuzhichang:agent-go-port

Conversation

@yuzhichang

Copy link
Copy Markdown
Member

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.

…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]>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 13, 2026
@yuzhichang yuzhichang added the ci Continue Integration label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Template reference matching

Layer / File(s) Summary
Variable-reference contract coverage
internal/agent/canvas/variable_test.go, internal/agent/runtime/template.go
Tests cover underscored, colon-bearing, legacy, and bare variable references; they also pin the regex string, verify substitution and extraction, and update the regex documentation.

TokenChunker input precedence

Layer / File(s) Summary
Upstream chunk selection
internal/ingestion/component/chunker/token.go, internal/ingestion/component/chunker/token_test.go
Chunk-formatted upstream data is passed to JSON payload handling instead of raw JSON, with regression coverage for preserving chapter-aware chunks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: 🧪 test

Poem

A rabbit checked each curly brace,
And kept the chunks in chapter place.
Underscores hopped into the fold,
While colons joined the IDs bold.
Raw JSON stayed behind the gate—
Tests now guard the updated state.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main Go porting of workflow and chunker fixes.
Description check ✅ Passed The description matches the required Summary section and clearly states the two upstream Python fixes being ported.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/ingestion/component/chunker/token.go (1)

196-221: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Migration 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 #16812 reference.
  • internal/ingestion/component/chunker/token_test.go#L287-L325: Remove "Go port of the Python" and "(PR #16825)" from the doc comment; keep the #16812 reference 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

📥 Commits

Reviewing files that changed from the base of the PR and between e54e7ec and 168daf3.

📒 Files selected for processing (4)
  • internal/agent/canvas/variable_test.go
  • internal/agent/runtime/template.go
  • internal/ingestion/component/chunker/token.go
  • internal/ingestion/component/chunker/token_test.go

@yuzhichang
yuzhichang merged commit d279aee into infiniflow:main Jul 13, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant