Skip to content

fix: agent chat completions can not use - #16570

Merged
yuzhichang merged 4 commits into
infiniflow:mainfrom
Haruko386:mei
Jul 3, 2026
Merged

yuzhichang merged 4 commits into
infiniflow:mainfrom
Haruko386:mei

Conversation

@Haruko386

Copy link
Copy Markdown
Member

Summary

As title
image

@Haruko386 Haruko386 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 2, 2026
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc7a97b9-72fb-40a1-b603-b56964f82f51

📥 Commits

Reviewing files that changed from the base of the PR and between 6f86b2e and 1e07386.

📒 Files selected for processing (2)
  • internal/agent/component/llm.go
  • internal/service/bot_completion.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/agent/component/llm.go
  • internal/service/bot_completion.go

📝 Walkthrough

Walkthrough

Adds prompt DSL parsing and runtime prompt formatting for agent inputs, centralizes provider base URL lookup, and changes agent-canvas streaming to a flat SSE envelope with matching handler and test updates.

Changes

Agent prompt parsing and runtime formatting

Layer / File(s) Summary
Prompt parsing and runtime prompt flow
internal/agent/component/agent.go, internal/agent/component/agent_test.go
Adds prompt parsing helpers, canvas-state template resolution, runtime prompt formatting, and tests for {sys.query} and REASONING/CONTEXT/QUERY output.
Provider base URL map helper
internal/agent/component/agent.go, internal/agent/component/llm.go
Switches agent chat model and invoker base URL resolution to a shared helper that returns either the override map or provider URLs.

Agent-canvas SSE envelope changes

Layer / File(s) Summary
Run-event SSE envelope
internal/service/bot_completion.go
Reworks WriteChatbotRunEvent to emit a flat JSON SSE envelope with optional identifiers, parsed event data, sanitized error handling, and a shared SSE writer helper.
Handler docs and SSE assertions
internal/handler/agent.go, internal/handler/agent_test.go, internal/service/bot_completion_history_test.go
Updates the SSE contract comment and test expectations to match the flat event/message/task/session/content/outputs frame shape.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: yuzhichang

Poem

A rabbit found new prompty trails,
With query hops and base-URL sails.
Flat SSE frames now skip and gleam,
While tests nibble through the stream. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is just 'As title' and lacks the required summary and background context from the template. Replace it with a brief summary of the problem, the fix, and any relevant background context.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is related to the agent chat completions fix, though the wording is awkward and incomplete.
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 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

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

Actionable comments posted: 1

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

Inline comments:
In `@internal/agent/component/agent.go`:
- Line 399: The runtime prompt override checks in agent.go are treating the
schema-default user_prompt as if it were a real user-supplied prompt, which
blocks the sys.query fallback and can overwrite an existing prompts user
template. Update the logic around hasRuntimeUserPrompt, the fallback path near
the query handling, and the prompt merge path so only explicit runtime input
counts, while agentUserPromptSchemaDefault is ignored unless the user actually
provided user_prompt. Use the existing symbols hasRuntimeUserPrompt,
hasNonEmptyString, sys.query handling, and the prompts user template merge to
locate and adjust the behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2b95733d-1d65-4c40-abb0-22234b4eee5d

📥 Commits

Reviewing files that changed from the base of the PR and between c8cf0c9 and c775f48.

📒 Files selected for processing (7)
  • internal/agent/component/agent.go
  • internal/agent/component/agent_test.go
  • internal/agent/component/llm.go
  • internal/handler/agent.go
  • internal/handler/agent_test.go
  • internal/service/bot_completion.go
  • internal/service/bot_completion_history_test.go

Comment thread internal/agent/component/agent.go Resolved
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (c8cf0c9) to head (6f86b2e).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16570   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yuzhichang
yuzhichang self-requested a review July 3, 2026 05:24

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 3, 2026
@yuzhichang
yuzhichang merged commit 383d059 into infiniflow:main Jul 3, 2026
5 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 7, 2026
@dosubot dosubot Bot mentioned this pull request Jul 8, 2026
4 tasks done
@Haruko386
Haruko386 deleted the mei branch July 14, 2026 03:02
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 lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants