Repository navigation
Fix: UserFillUp interactive forms not working in agent explore mode - #14589
yuzhichang merged 13 commits into
Conversation
The explore mode's session completion event stream was filtering out `user_inputs` and `workflow_finished` events, causing agents with UserFillUp components to silently fail — the interactive form never appeared. Additionally, the explore mode's SessionChat component was missing the DebugContent children rendering needed to display UserFillUp forms. Backend: Add `user_inputs` and `workflow_finished` to the allowed event types in `_iter_session_completion_events`. Frontend: Add DebugContent/MarkdownContent rendering as MessageItem children in SessionChat, matching the behavior of the run mode's chat box component. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughSessionChat now renders assistant messages with markdown or debug content based on generated parameters, tracks awaiting-input state, and disables the next input while waiting. The agent API now forwards ChangesAgent Session Streaming + Canvas-Aware Chat
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
Actionable comments posted: 3
🧹 Nitpick comments (3)
api/apps/restful_apis/agent_api.py (1)
240-267: 💤 Low valueAdd logging for the new event passthrough.
Per coding guidelines for
**/*.py("Add logging for new flows"), consider emitting a debug log whenuser_inputsorworkflow_finishedis forwarded — these mark significant workflow transitions (pause-for-input and completion) and the lack of any trace makes the explore-mode UserFillUp regression harder to diagnose if it surfaces again.📝 Suggested addition
- if event in ["message", "message_end", "user_inputs", "workflow_finished"]: - yield ans + if event in ("message", "message_end", "user_inputs", "workflow_finished"): + if event in ("user_inputs", "workflow_finished"): + logging.debug( + "Forwarding session completion event: agent_id=%s event=%s", + agent_id, event, + ) + yield ansAs per coding guidelines: "Add logging for new flows".
🤖 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 `@api/apps/restful_apis/agent_api.py` around lines 240 - 267, In _iter_session_completion_events, add a debug log when forwarding events "user_inputs" or "workflow_finished" so we record these significant workflow transitions; inside the branch that checks if event in ["message", "message_end", "user_inputs", "workflow_finished"] (or just before yielding ans for those two specific events), call the module or request logger (e.g., process_logger or the existing logger used in this module) with a debug-level message that includes tenant_id, agent_id, event, and any minimal identifying data from ans["data"] (if present) to aid diagnostics when return_trace is False or traces are absent. Ensure the log message is concise and does not alter control flow or payload returned by _iter_session_completion_events.web/src/pages/agent/explore/components/session-chat.tsx (2)
163-163: ⚡ Quick winLocalize the Submit button label using the existing translation key.
useTranslationis imported andtis in scope (lines 18, 28); the hard-coded'Submit'will not localize. The translation keycommon.submitexists and aligns with the fallback pattern used in theDebugContentcomponent. Additionally, this pattern appears in multiple files (web/src/pages/agent/chat/box.tsx:102,web/src/pages/agent/share/parameter-dialog.tsx:25,web/src/pages/agent/share/index.tsx:169), so consider applying the same fix consistently.- btnText={'Submit'} + btnText={t('common.submit')}🤖 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 `@web/src/pages/agent/explore/components/session-chat.tsx` at line 163, The Submit button label is hard-coded as 'Submit' in the session-chat component; replace the literal with the i18n helper (t) that is already in scope so it uses the existing translation key — e.g., change the btnText prop to call t('common.submit') (or t('common.submit', 'Submit') if a fallback is desired); update other similar occurrences (btnText in session-chat, and matching patterns in chat/box.tsx, parameter-dialog.tsx, share/index.tsx) to the same t('common.submit') usage to keep behavior consistent.
32-61: 💤 Low valueUse type-safe parameter extraction and add runtime validation for
canvasId.The route
/agent/:id/exploredoes define the:idparameter, andSessionChatis rendered only from the explore page component mounted on that route. However,useParams()still returnsid: string | undefined, and the current code hides this type uncertainty withas string.While the route structure ensures
:idis present in normal usage, the code should be defensive:- const { id: canvasId } = useParams(); + const { id: canvasId } = useParams<{ id: string }>(); + if (!canvasId) { + // Handle error: route misconfiguration or unexpected mount + return <FallbackComponent />; + }Pass
canvasIddirectly (without cast) touseAwaitCompentData. This makes the guarantee explicit at runtime and prevents silent failures if the component is ever mounted on a route without:id.🤖 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 `@web/src/pages/agent/explore/components/session-chat.tsx` around lines 32 - 61, The code currently forces a string cast on canvasId (const { id: canvasId } = useParams(); ... canvasId as string) which hides that useParams() can return undefined; change to keep canvasId as string | undefined by removing the cast, add a runtime validation right after obtaining canvasId (e.g., if (!canvasId) return or throw/show an error), and pass the raw canvasId variable into useAwaitCompentData so it receives the possibly-undefined value and the component short-circuits or handles the missing id safely; update any dependent logic (useAwaitCompentData, SessionChat render path) to expect canvasId?: string and avoid using "as string".
🤖 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 `@api/apps/restful_apis/agent_api.py`:
- Around line 266-267: The non-stream response contract is breaking because
_iter_session_completion_events now yields "workflow_finished" (whose data shape
differs) and the non-stream path assigns final_ans = ans on each iteration;
update the logic so non-stream consumers still end with the last "message_end"
event: either filter out "workflow_finished" and "user_inputs" before the
non-stream branch inside _iter_session_completion_events (so yield only events
compatible with the streaming contract), or change the non-stream loop that
consumes _iter_session_completion_events to buffer/track events and explicitly
set final_ans from the last event where event == "message_end" while handling
"workflow_finished" separately (e.g., store it in a separate variable) instead
of letting it overwrite final_ans.
In `@web/src/pages/agent/explore/components/session-chat.tsx`:
- Around line 156-178: Guard the rendering of DebugContent and MarkdownContent
so they only appear for assistant messages that actually carry a UserFillUp
payload: check message.data?.inputs or that buildInputList(message) returns a
non-empty array before rendering DebugContent (for the latest assistant message)
and before rendering MarkdownContent / the input-values div (for prior assistant
messages). Update the conditional branches that reference MessageType.Assistant,
derivedMessages, DebugContent, MarkdownContent, and buildInputList to include
this additional truthy check (e.g., message.data?.inputs?.length > 0 or
buildInputList(message)?.length > 0) so normal assistant text replies do not
show the form editor or empty markdown block.
- Around line 173-175: The mapped list rendered from buildInputList(message)
lacks a React key prop; update the map in the JSX (the expression using
buildInputList(message)?.map((item) => item.value)) to return an element with a
stable key (use a unique field from each item such as item.key or item.id, or
fall back to item.value and only use index as last resort) so React can track
list items properly—modify the map to produce an element wrapper (e.g., a
span/div) with key={...} and render item.value inside it.
---
Nitpick comments:
In `@api/apps/restful_apis/agent_api.py`:
- Around line 240-267: In _iter_session_completion_events, add a debug log when
forwarding events "user_inputs" or "workflow_finished" so we record these
significant workflow transitions; inside the branch that checks if event in
["message", "message_end", "user_inputs", "workflow_finished"] (or just before
yielding ans for those two specific events), call the module or request logger
(e.g., process_logger or the existing logger used in this module) with a
debug-level message that includes tenant_id, agent_id, event, and any minimal
identifying data from ans["data"] (if present) to aid diagnostics when
return_trace is False or traces are absent. Ensure the log message is concise
and does not alter control flow or payload returned by
_iter_session_completion_events.
In `@web/src/pages/agent/explore/components/session-chat.tsx`:
- Line 163: The Submit button label is hard-coded as 'Submit' in the
session-chat component; replace the literal with the i18n helper (t) that is
already in scope so it uses the existing translation key — e.g., change the
btnText prop to call t('common.submit') (or t('common.submit', 'Submit') if a
fallback is desired); update other similar occurrences (btnText in session-chat,
and matching patterns in chat/box.tsx, parameter-dialog.tsx, share/index.tsx) to
the same t('common.submit') usage to keep behavior consistent.
- Around line 32-61: The code currently forces a string cast on canvasId (const
{ id: canvasId } = useParams(); ... canvasId as string) which hides that
useParams() can return undefined; change to keep canvasId as string | undefined
by removing the cast, add a runtime validation right after obtaining canvasId
(e.g., if (!canvasId) return or throw/show an error), and pass the raw canvasId
variable into useAwaitCompentData so it receives the possibly-undefined value
and the component short-circuits or handles the missing id safely; update any
dependent logic (useAwaitCompentData, SessionChat render path) to expect
canvasId?: string and avoid using "as string".
🪄 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: 9759f549-caa2-46a5-81dd-f3f7b4fe47e3
📒 Files selected for processing (2)
api/apps/restful_apis/agent_api.pyweb/src/pages/agent/explore/components/session-chat.tsx
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
api/apps/restful_apis/agent_api.py (1)
1449-1456: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick winGuard
files[0]before queuing the dataflow run.This branch crashes with
IndexErrorwhen the request omitsfiles, becausefiles[0]is accessed unconditionally.Suggested fix
+ if not files: + return get_data_error_result(message="At least one file is required for dataflow runs.") ok, error_message = await thread_pool_exec( queue_dataflow, user_id, agent_id, task_id, CANVAS_DEBUG_DOC_ID, files[0], 0, )🤖 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 `@api/apps/restful_apis/agent_api.py` around lines 1449 - 1456, The queueing path in agent_api.py is indexing files[0] unconditionally, which can raise IndexError when no files are provided. Update the branch around thread_pool_exec and queue_dataflow to guard the files collection before accessing the first element, and only pass a file argument when at least one file exists; otherwise skip this path or handle the missing-file case explicitly using the existing files and queue_dataflow symbols.
🧹 Nitpick comments (1)
api/apps/restful_apis/agent_api.py (1)
195-366: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd entry/exit logs for the new workflow-session flow.
This helper introduces a new execution path, but it only logs failures. A small info log around start/finish (
agent_id,session_id,stream, resumed/new) would make this path much easier to debug. As per coding guidelines,**/*.py: Add logging for new flows.🤖 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 `@api/apps/restful_apis/agent_api.py` around lines 195 - 366, _add entry and exit info logs around _run_workflow_session to make the new workflow-session path observable._ Add a start log near the beginning of _run_workflow_session that includes agent_id, session_id, stream, and whether this is a resumed or new session, and add a matching completion log in both the streaming sse flow and the non-streaming return path. Keep the existing failure logs, and use the _run_workflow_session, sse, and persist_workflow_session symbols to place the logs consistently.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.
Outside diff comments:
In `@api/apps/restful_apis/agent_api.py`:
- Around line 1449-1456: The queueing path in agent_api.py is indexing files[0]
unconditionally, which can raise IndexError when no files are provided. Update
the branch around thread_pool_exec and queue_dataflow to guard the files
collection before accessing the first element, and only pass a file argument
when at least one file exists; otherwise skip this path or handle the
missing-file case explicitly using the existing files and queue_dataflow
symbols.
---
Nitpick comments:
In `@api/apps/restful_apis/agent_api.py`:
- Around line 195-366: _add entry and exit info logs around
_run_workflow_session to make the new workflow-session path observable._ Add a
start log near the beginning of _run_workflow_session that includes agent_id,
session_id, stream, and whether this is a resumed or new session, and add a
matching completion log in both the streaming sse flow and the non-streaming
return path. Keep the existing failure logs, and use the _run_workflow_session,
sse, and persist_workflow_session symbols to place the logs consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d6b7b6f8-b85e-4c0d-b2f2-932219734c3a
📒 Files selected for processing (1)
api/apps/restful_apis/agent_api.py
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
api/apps/restful_apis/agent_api.py (1)
559-559: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a log for the newly forwarded completion-event path.
This branch now introduces
user_inputs/workflow_finishedhandling, but there is still no observability when explore-mode runs pause or finish through those events. As per coding guidelines, "**/*.py: Add logging for new flows`."🤖 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 `@api/apps/restful_apis/agent_api.py` at line 559, The new completion-event branch in agent_api.py lacks observability for the added user_inputs and workflow_finished flow. Update the event handling around the existing message/message_end/user_inputs/workflow_finished check to emit a clear log when these forwarded completion events are processed, using the surrounding handler logic in the agent API path so explore-mode pauses and finishes can be traced.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.
Inline comments:
In `@api/apps/restful_apis/agent_api.py`:
- Around line 1548-1549: The non-stream final response handling in agent_api
should preserve the last user_inputs payload when no message_end event occurs.
Update the final_ans selection logic in the message processing flow so
message_end still wins, but user_inputs is retained as a fallback for workflows
that pause before completion. Use the existing final_ans assignment path and the
ans.get("event") checks to locate the fix.
In `@web/src/pages/agent/explore/components/session-chat.tsx`:
- Around line 159-182: `MessageItem` is treating any truthy `item.data` as
custom children, but this map only supplies children for `hasUserFillUpInputs`,
so assistant messages with other `data` payloads can render blank instead of
markdown. Update the `session-chat.tsx` rendering around the
`DebugContent`/`MarkdownContent` branches so the default markdown path is used
when `inputList` is empty, or adjust `MessageItem` to only switch to children
for UserFillUp-specific data. Ensure the fallback still uses the existing
markdown content rendering for non-form assistant messages.
- Around line 55-58: The current `isWaiting` from `useAwaitComponentData` is too
broad because it treats any assistant message with `message.data` as a form wait
state, which can incorrectly disable the composer in `session-chat` and related
`disabled`/`sendDisabled`/`isUploading` bindings. Narrow the waiting condition
in `useAwaitComponentData` and the `session-chat` usage to only true UserFillUp
cases by checking `message.data.inputs` or whether
`buildInputList(lastMessage).length > 0`, and if needed keep a separate
in-flight flag for `sendFormMessage` instead of reusing this derived state.
---
Nitpick comments:
In `@api/apps/restful_apis/agent_api.py`:
- Line 559: The new completion-event branch in agent_api.py lacks observability
for the added user_inputs and workflow_finished flow. Update the event handling
around the existing message/message_end/user_inputs/workflow_finished check to
emit a clear log when these forwarded completion events are processed, using the
surrounding handler logic in the agent API path so explore-mode pauses and
finishes can be traced.
🪄 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: 059162e5-12c8-48ee-8250-f0acfa081054
📒 Files selected for processing (2)
api/apps/restful_apis/agent_api.pyweb/src/pages/agent/explore/components/session-chat.tsx
| const { buildInputList, handleOk, isWaiting } = useAwaitComponentData({ | ||
| derivedMessages, | ||
| sendFormMessage, | ||
| }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Narrow isWaiting to actual UserFillUp state.
useAwaitComponentData currently marks waiting when the last assistant message has any message.data, and this component now pipes that straight into disabled / sendDisabled / isUploading. That will lock the composer on assistant messages with non-form metadata too. Derive the flag from message.data.inputs / buildInputList(lastMessage).length > 0, or keep a separate submit-in-flight state for sendFormMessage.
Also applies to: 195-197
🤖 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 `@web/src/pages/agent/explore/components/session-chat.tsx` around lines 55 -
58, The current `isWaiting` from `useAwaitComponentData` is too broad because it
treats any assistant message with `message.data` as a form wait state, which can
incorrectly disable the composer in `session-chat` and related
`disabled`/`sendDisabled`/`isUploading` bindings. Narrow the waiting condition
in `useAwaitComponentData` and the `session-chat` usage to only true UserFillUp
cases by checking `message.data.inputs` or whether
`buildInputList(lastMessage).length > 0`, and if needed keep a separate
in-flight flag for `sendFormMessage` instead of reusing this derived state.
| {hasUserFillUpInputs && | ||
| derivedMessages.length - 1 === i && ( | ||
| <DebugContent | ||
| parameters={inputList} | ||
| message={message} | ||
| ok={handleOk(message)} | ||
| isNext={false} | ||
| btnText={t('common.submit')} | ||
| ></DebugContent> | ||
| )} | ||
| {hasUserFillUpInputs && | ||
| derivedMessages.length - 1 !== i && ( | ||
| <div> | ||
| <MarkdownContent | ||
| content={message?.data?.tips} | ||
| loading={false} | ||
| ></MarkdownContent> | ||
| <div> | ||
| {inputList.map((item) => ( | ||
| <div key={item.key}>{item.value}</div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| )} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Keep a markdown fallback for assistant messages that have data but no form inputs.
MessageItem switches to children whenever item.data is truthy. In this map, children are only produced for hasUserFillUpInputs, so assistant messages carrying other data fields render a blank bubble instead of their normal markdown content. Either render the default markdown path here when inputList is empty, or tighten MessageItem so it special-cases only UserFillUp payloads.
🤖 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 `@web/src/pages/agent/explore/components/session-chat.tsx` around lines 159 -
182, `MessageItem` is treating any truthy `item.data` as custom children, but
this map only supplies children for `hasUserFillUpInputs`, so assistant messages
with other `data` payloads can render blank instead of markdown. Update the
`session-chat.tsx` rendering around the `DebugContent`/`MarkdownContent`
branches so the default markdown path is used when `inputList` is empty, or
adjust `MessageItem` to only switch to children for UserFillUp-specific data.
Ensure the fallback still uses the existing markdown content rendering for
non-form assistant messages.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/src/components/next-message-item/index.tsx (1)
135-150: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
!!childrentreats empty child slots as present, so the markdown fallback can disappear.MessageItemcan receive only falsey conditional children fromSessionChat; in that caseitem.datastill takes the custom branch and renders a blank message instead ofMarkdownContent. Check for renderable children (for example,Children.toArray(children).length > 0) before bypassing the fallback.🤖 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 `@web/src/components/next-message-item/index.tsx` around lines 135 - 150, The custom-children check in MessageItem is too loose because `!!children` treats falsey or empty child slots as present, which can bypass the MarkdownContent fallback and render a blank message. Update the hasCustomChildren logic in next-message-item so it only takes the custom branch when children are actually renderable, using a real emptiness check like Children.toArray(children).length on the same render path used by SessionChat.
🤖 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.
Outside diff comments:
In `@web/src/components/next-message-item/index.tsx`:
- Around line 135-150: The custom-children check in MessageItem is too loose
because `!!children` treats falsey or empty child slots as present, which can
bypass the MarkdownContent fallback and render a blank message. Update the
hasCustomChildren logic in next-message-item so it only takes the custom branch
when children are actually renderable, using a real emptiness check like
Children.toArray(children).length on the same render path used by SessionChat.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4cef7e0e-5230-48c4-9ca4-a043507b6898
📒 Files selected for processing (3)
api/apps/restful_apis/agent_api.pyweb/src/components/next-message-item/index.tsxweb/src/pages/agent/hooks/use-chat-logic.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- api/apps/restful_apis/agent_api.py
…14589) ## Summary - **Backend**: `_iter_session_completion_events` in `agent_api.py` was filtering out `user_inputs` and `workflow_finished` SSE events, causing agents with UserFillUp components to silently fail in explore mode — the interactive form never appeared, while the same agent worked correctly in run (editor) mode. - **Frontend**: `SessionChat` component in explore mode was missing `DebugContent` children rendering inside `MessageItem`, so even if the backend forwarded the events, the form UI would not render. Added `DebugContent`, `MarkdownContent`, `useAwaitCompentData` hook, and input-disabling logic to match the run mode's `chat/box.tsx` behavior. ## What was changed ### Backend (`api/apps/restful_apis/agent_api.py`) - Line 266: Added `"user_inputs"` and `"workflow_finished"` to the allowed event filter in `_iter_session_completion_events` ### Frontend (`web/src/pages/agent/explore/components/session-chat.tsx`) - Added imports: `DebugContent`, `MarkdownContent`, `useAwaitCompentData`, `useParams` - Added `sendFormMessage` from `useSendSessionMessage()` hook - Added `useAwaitCompentData` hook for form state management - Added `DebugContent` as `MessageItem` children for the latest assistant message (renders UserFillUp form) - Added `MarkdownContent` + submitted values display for previous assistant messages - Updated `NextMessageInput` disabled states to respect `isWaitting` (form submission in progress) ## Test plan - [x] Agent with UserFillUp component (e.g., email draft with send/edit/cancel options) shows interactive form in **explore mode** - [x] Same agent continues to work correctly in **run (editor) mode** - [x] Form submission sends data back to the agent and workflow continues - [x] Input field is disabled while waiting for form submission - [ ] Agents without UserFillUp components are unaffected in explore mode 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Zhichang Yu <[email protected]>
Ports 4 L/M-effort PRs from .claude/plans/review-and-port-py-agent-changes.md Execution snapshot (all merged upstream) to the Go agent side. Group 2 - SSRF + cross-cutting - infiniflow#15426 Invoke SSRF consolidation: utility.AssertURLSafe gates the target URL and (optionally) the proxy URL BEFORE any HTTP request. utility.PinnedHTTPClient dials the validated public IP for the direct path (defeats DNS rebinding). No-redirects policy closes the 30x-bypass window. ALLOW_ANY_HOST env var added to utility.AssertURLSafe for test bypass (production: never set; tests: t.Setenv). 4 new tests cover loopback, metadata IP, loopback proxy, no-follow-redirect. Group 4 - API auth + interactive events - infiniflow#15238 Thinking logs: new GET /api/v1/agentbots/<shared_id>/logs/ <message_id> sibling. BetaAuthMiddleware now also looks up the APIToken directly and stashes DialogID in the gin context as agent_id, so the handler can build the Redis key without trusting the URL segment. New UserService.GetAPITokenByBeta + userTokenResolver interface method + stub update. 2 new tests cover agent_id-in-context and message_id-required paths. - infiniflow#14589 UserFillUp explore events: ChatbotSSEFrame gains an Event field (json:event,omitempty); WriteChatbotFrame includes it in the inner data envelope so the front-end can distinguish user_inputs / workflow_finished events from plain messages and render the UserFillUp form vs the assistant text. 3 new tests cover the user_inputs, workflow_finished, and message event types. - infiniflow#14890 Anonymous webhook opt-in: validateWebhookSecurity now rejects empty/nil security config (was fail-open); validateAuth rejects auth_type=none without allow_anonymous=true. New isTruthyAllowAnonymous helper mirrors python _is_truthy. Existing tests updated to use the explicit-opt-in default via makeWebhookCanvas. 3 new tests cover empty/nil config, auth_type=none without opt-in, and the various truthy forms of allow_anonymous. Total: 12 new tests across 3 modified test files. All touched package tests pass (1709 + 4 skipped). The 1 failing test (TestAgent_ReActExhaustsSteps) is the pre-existing flaky test that also fails on the baseline without my changes. Refs: .claude/plans/review-and-port-py-agent-changes.md Refs: infiniflow#15426 infiniflow#15238 infiniflow#14589 infiniflow#14890
Ports 4 L/M-effort PRs from .claude/plans/review-and-port-py-agent-changes.md Execution snapshot (all merged upstream) to the Go agent side. Group 2 - SSRF + cross-cutting - infiniflow#15426 Invoke SSRF consolidation: utility.AssertURLSafe gates the target URL and (optionally) the proxy URL BEFORE any HTTP request. utility.PinnedHTTPClient dials the validated public IP for the direct path (defeats DNS rebinding). No-redirects policy closes the 30x-bypass window. ALLOW_ANY_HOST env var added to utility.AssertURLSafe for test bypass (production: never set; tests: t.Setenv). 4 new tests cover loopback, metadata IP, loopback proxy, no-follow-redirect. Group 4 - API auth + interactive events - infiniflow#15238 Thinking logs: new GET /api/v1/agentbots/<shared_id>/logs/ <message_id> sibling. BetaAuthMiddleware now also looks up the APIToken directly and stashes DialogID in the gin context as agent_id, so the handler can build the Redis key without trusting the URL segment. New UserService.GetAPITokenByBeta + userTokenResolver interface method + stub update. 2 new tests cover agent_id-in-context and message_id-required paths. - infiniflow#14589 UserFillUp explore events: ChatbotSSEFrame gains an Event field (json:event,omitempty); WriteChatbotFrame includes it in the inner data envelope so the front-end can distinguish user_inputs / workflow_finished events from plain messages and render the UserFillUp form vs the assistant text. 3 new tests cover the user_inputs, workflow_finished, and message event types. - infiniflow#14890 Anonymous webhook opt-in: validateWebhookSecurity now rejects empty/nil security config (was fail-open); validateAuth rejects auth_type=none without allow_anonymous=true. New isTruthyAllowAnonymous helper mirrors python _is_truthy. Existing tests updated to use the explicit-opt-in default via makeWebhookCanvas. 3 new tests cover empty/nil config, auth_type=none without opt-in, and the various truthy forms of allow_anonymous. Total: 12 new tests across 3 modified test files. All touched package tests pass (1709 + 4 skipped). The 1 failing test (TestAgent_ReActExhaustsSteps) is the pre-existing flaky test that also fails on the baseline without my changes. Refs: .claude/plans/review-and-port-py-agent-changes.md Refs: infiniflow#15426 infiniflow#15238 infiniflow#14589 infiniflow#14890
Ports 4 L/M-effort PRs from .claude/plans/review-and-port-py-agent-changes.md Execution snapshot (all merged upstream) to the Go agent side. Group 2 - SSRF + cross-cutting - infiniflow#15426 Invoke SSRF consolidation: utility.AssertURLSafe gates the target URL and (optionally) the proxy URL BEFORE any HTTP request. utility.PinnedHTTPClient dials the validated public IP for the direct path (defeats DNS rebinding). No-redirects policy closes the 30x-bypass window. ALLOW_ANY_HOST env var added to utility.AssertURLSafe for test bypass (production: never set; tests: t.Setenv). 4 new tests cover loopback, metadata IP, loopback proxy, no-follow-redirect. Group 4 - API auth + interactive events - infiniflow#15238 Thinking logs: new GET /api/v1/agentbots/<shared_id>/logs/ <message_id> sibling. BetaAuthMiddleware now also looks up the APIToken directly and stashes DialogID in the gin context as agent_id, so the handler can build the Redis key without trusting the URL segment. New UserService.GetAPITokenByBeta + userTokenResolver interface method + stub update. 2 new tests cover agent_id-in-context and message_id-required paths. - infiniflow#14589 UserFillUp explore events: ChatbotSSEFrame gains an Event field (json:event,omitempty); WriteChatbotFrame includes it in the inner data envelope so the front-end can distinguish user_inputs / workflow_finished events from plain messages and render the UserFillUp form vs the assistant text. 3 new tests cover the user_inputs, workflow_finished, and message event types. - infiniflow#14890 Anonymous webhook opt-in: validateWebhookSecurity now rejects empty/nil security config (was fail-open); validateAuth rejects auth_type=none without allow_anonymous=true. New isTruthyAllowAnonymous helper mirrors python _is_truthy. Existing tests updated to use the explicit-opt-in default via makeWebhookCanvas. 3 new tests cover empty/nil config, auth_type=none without opt-in, and the various truthy forms of allow_anonymous. Total: 12 new tests across 3 modified test files. All touched package tests pass (1709 + 4 skipped). The 1 failing test (TestAgent_ReActExhaustsSteps) is the pre-existing flaky test that also fails on the baseline without my changes. Refs: .claude/plans/review-and-port-py-agent-changes.md Refs: infiniflow#15426 infiniflow#15238 infiniflow#14589 infiniflow#14890
Ports 4 L/M-effort PRs from .claude/plans/review-and-port-py-agent-changes.md Execution snapshot (all merged upstream) to the Go agent side. Group 2 - SSRF + cross-cutting - infiniflow#15426 Invoke SSRF consolidation: utility.AssertURLSafe gates the target URL and (optionally) the proxy URL BEFORE any HTTP request. utility.PinnedHTTPClient dials the validated public IP for the direct path (defeats DNS rebinding). No-redirects policy closes the 30x-bypass window. ALLOW_ANY_HOST env var added to utility.AssertURLSafe for test bypass (production: never set; tests: t.Setenv). 4 new tests cover loopback, metadata IP, loopback proxy, no-follow-redirect. Group 4 - API auth + interactive events - infiniflow#15238 Thinking logs: new GET /api/v1/agentbots/<shared_id>/logs/ <message_id> sibling. BetaAuthMiddleware now also looks up the APIToken directly and stashes DialogID in the gin context as agent_id, so the handler can build the Redis key without trusting the URL segment. New UserService.GetAPITokenByBeta + userTokenResolver interface method + stub update. 2 new tests cover agent_id-in-context and message_id-required paths. - infiniflow#14589 UserFillUp explore events: ChatbotSSEFrame gains an Event field (json:event,omitempty); WriteChatbotFrame includes it in the inner data envelope so the front-end can distinguish user_inputs / workflow_finished events from plain messages and render the UserFillUp form vs the assistant text. 3 new tests cover the user_inputs, workflow_finished, and message event types. - infiniflow#14890 Anonymous webhook opt-in: validateWebhookSecurity now rejects empty/nil security config (was fail-open); validateAuth rejects auth_type=none without allow_anonymous=true. New isTruthyAllowAnonymous helper mirrors python _is_truthy. Existing tests updated to use the explicit-opt-in default via makeWebhookCanvas. 3 new tests cover empty/nil config, auth_type=none without opt-in, and the various truthy forms of allow_anonymous. Total: 12 new tests across 3 modified test files. All touched package tests pass (1709 + 4 skipped). The 1 failing test (TestAgent_ReActExhaustsSteps) is the pre-existing flaky test that also fails on the baseline without my changes. Refs: .claude/plans/review-and-port-py-agent-changes.md Refs: infiniflow#15426 infiniflow#15238 infiniflow#14589 infiniflow#14890
) Mirrors 14 merged upstream PRs into the Go agent port. PRs ported: - #15609 ExeSQL SSRF guard + DNS pin - #15436 HTTP timeout on external API tools - #16363 be_output restore + DeepL error path - #15644 switch no longer matches empty condition - #15374 session_id bind to path agent_id (DAO idor guard) - #16169 sandbox artifact ownership gate - #15457 tenant ownership on agentbots - #15145 rerun agent document access check - #15446 thinking switch (component portion; provider policy lives in internal/llm) - #15426 Invoke URL/proxy SSRF + DNS pin + no-redirects - #15238 agentbot thinking-logs beta endpoint - #14589 UserFillUp SSE event propagation - #14890 anonymous webhook opt-in - #15068 PipelineChunker new component (text/file_ref/parser_id dispatch; file-format extraction is a follow-up) 40 files, +2355 / -58 lines. 33 new tests, all targeted package suites pass (1721 + 4 skipped); 1 pre-existing flaky test unrelated.
…sion/user + input/output to Langfuse for agent runs Rebuilt on current upstream/main after force-push; cherry-pick of the 7 PR-original commits collapsed into a single net diff to avoid conflicts with intervening commits pulled in by repeated merges of upstream/main. Original PR work (commits dropped during rebuild because their content already lives on upstream/main or was a merge of upstream/main): c7339ae Enhance LLMService with token usage reporting 0266cf0 Implement token usage tracking and Langfuse integration ab2b267 Include session_id in run_kwargs 8bf937c Implement token usage tracking in chat model c955988 Enhance token tracking with context variables and functions 3e88ed5 fix(agent): address CodeRabbit review on token usage tracking 74b8c8c fix(agent): address CodeRabbit follow-up review Forced-upstream duplicates dropped (already merged to main): 70546ea (infiniflow#16396), 5b09910 (infiniflow#16403), 5d7f0fd (infiniflow#16405), 730f33b (infiniflow#16407), a06343e (infiniflow#16408), f90be41 (infiniflow#16410), c4fe68e (infiniflow#16409), d4a0e71 (infiniflow#14773), ef42fd7 (infiniflow#15436), ab1015d (infiniflow#16363), db188cc (infiniflow#15446), 56ece68 (infiniflow#15609), 2589b6e (infiniflow#15644), 74c2944 (infiniflow#15374), 78832ff (infiniflow#14985), bf18b59 (infiniflow#15457), 6c87225 (infiniflow#14890), e16d1a0 (infiniflow#15426), 4712fcb (infiniflow#16169), 0536233 (infiniflow#14589), 08c807a (infiniflow#15145) Plus 18 'Merge branch main into main' commits dropped (polluted topology).
…sion/user + input/output to Langfuse for agent runs Rebuilt on current upstream/main after force-push; cherry-pick of the 7 PR-original commits collapsed into a single net diff to avoid conflicts with intervening commits pulled in by repeated merges of upstream/main. Original PR work (commits dropped during rebuild because their content already lives on upstream/main or was a merge of upstream/main): c7339ae Enhance LLMService with token usage reporting 0266cf0 Implement token usage tracking and Langfuse integration ab2b267 Include session_id in run_kwargs 8bf937c Implement token usage tracking in chat model c955988 Enhance token tracking with context variables and functions 3e88ed5 fix(agent): address CodeRabbit review on token usage tracking 74b8c8c fix(agent): address CodeRabbit follow-up review Forced-upstream duplicates dropped (already merged to main): 70546ea (infiniflow#16396), 5b09910 (infiniflow#16403), 5d7f0fd (infiniflow#16405), 730f33b (infiniflow#16407), a06343e (infiniflow#16408), f90be41 (infiniflow#16410), c4fe68e (infiniflow#16409), d4a0e71 (infiniflow#14773), ef42fd7 (infiniflow#15436), ab1015d (infiniflow#16363), db188cc (infiniflow#15446), 56ece68 (infiniflow#15609), 2589b6e (infiniflow#15644), 74c2944 (infiniflow#15374), 78832ff (infiniflow#14985), bf18b59 (infiniflow#15457), 6c87225 (infiniflow#14890), e16d1a0 (infiniflow#15426), 4712fcb (infiniflow#16169), 0536233 (infiniflow#14589), 08c807a (infiniflow#15145) Plus 18 'Merge branch main into main' commits dropped (polluted topology). Co-authored-by: yzc <[email protected]>
…iniflow#16455) Mirrors 14 merged upstream PRs into the Go agent port. PRs ported: - infiniflow#15609 ExeSQL SSRF guard + DNS pin - infiniflow#15436 HTTP timeout on external API tools - infiniflow#16363 be_output restore + DeepL error path - infiniflow#15644 switch no longer matches empty condition - infiniflow#15374 session_id bind to path agent_id (DAO idor guard) - infiniflow#16169 sandbox artifact ownership gate - infiniflow#15457 tenant ownership on agentbots - infiniflow#15145 rerun agent document access check - infiniflow#15446 thinking switch (component portion; provider policy lives in internal/llm) - infiniflow#15426 Invoke URL/proxy SSRF + DNS pin + no-redirects - infiniflow#15238 agentbot thinking-logs beta endpoint - infiniflow#14589 UserFillUp SSE event propagation - infiniflow#14890 anonymous webhook opt-in - infiniflow#15068 PipelineChunker new component (text/file_ref/parser_id dispatch; file-format extraction is a follow-up) 40 files, +2355 / -58 lines. 33 new tests, all targeted package suites pass (1721 + 4 skipped); 1 pre-existing flaky test unrelated.
Summary
_iter_session_completion_eventsinagent_api.pywas filtering outuser_inputsandworkflow_finishedSSE events, causing agents with UserFillUp components to silently fail in explore mode — the interactive form never appeared, while the same agent worked correctly in run (editor) mode.SessionChatcomponent in explore mode was missingDebugContentchildren rendering insideMessageItem, so even if the backend forwarded the events, the form UI would not render. AddedDebugContent,MarkdownContent,useAwaitCompentDatahook, and input-disabling logic to match the run mode'schat/box.tsxbehavior.What was changed
Backend (
api/apps/restful_apis/agent_api.py)"user_inputs"and"workflow_finished"to the allowed event filter in_iter_session_completion_eventsFrontend (
web/src/pages/agent/explore/components/session-chat.tsx)DebugContent,MarkdownContent,useAwaitCompentData,useParamssendFormMessagefromuseSendSessionMessage()hookuseAwaitCompentDatahook for form state managementDebugContentasMessageItemchildren for the latest assistant message (renders UserFillUp form)MarkdownContent+ submitted values display for previous assistant messagesNextMessageInputdisabled states to respectisWaitting(form submission in progress)Test plan
🤖 Generated with Claude Code