Skip to content

fix(go-agent): align agent debug input form with Python - #16654

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/input-agent
Jul 6, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/input-agent

Conversation

@Harry-Hz-Zhang

Copy link
Copy Markdown
Contributor

Summary

  • derive Go Agent debug input forms from prompt variable references instead of Agent meta fields
  • seed sys.* debug params into CanvasState.Sys so single-component debug resolves prompt variables like Python
  • restore Agent test-run parity for form rendering and debug execution

Tests

  • go test ./internal/agent/component -run 'TestAgent_(GetInputForm_UsesPromptReferences|GetInputForm_DeduplicatesPromptReferences|Meta_DefaultsToEmpty|Reset_NoTools)$'
  • go test ./internal/handler -run 'Test(DebugComponent_SeedsSysInputsIntoCanvasState|DebugComponent_HappyPath_Begin|GetComponentInputForm_HappyPath)$'

AFTER:
image

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 6, 2026
@Harry-Hz-Zhang Harry-Hz-Zhang added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 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: ca51be45-9350-495a-8fd8-13869eb8a030

📥 Commits

Reviewing files that changed from the base of the PR and between c5bf0ae and 6933fee.

📒 Files selected for processing (2)
  • internal/handler/agent_component.go
  • internal/handler/agent_component_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/handler/agent_component.go

📝 Walkthrough

Walkthrough

AgentComponent.GetInputForm now derives fields from prompt variable references instead of a self meta entry, and DebugComponent copies sys. request inputs into debug canvas state while preserving sys.tenant_id.

Changes

Prompt-derived input form and sys.* debug seeding

Layer / File(s) Summary
Extract input form fields from prompt references
internal/agent/component/agent.go, internal/agent/component/agent_meta_test.go
GetInputForm builds fields from prompt-referenced variables via extractAgentPromptInputForm and sortedAgentPromptInputKeys instead of a self meta entry; tests verify prompt-derived keys, deduplication, and empty defaults.
Seed sys.* inputs into DebugComponent CanvasState
internal/handler/agent_component.go, internal/handler/agent_component_test.go
DebugComponent strips sys. prefixes from request inputs and writes them into debugState.Sys; tests verify seeded values reach component invocation and sys.tenant_id is not overwritten.

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

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant AgentHandler
  participant CanvasState
  participant sysEchoComponent
  Client->>AgentHandler: DebugComponent request with sys.query input
  AgentHandler->>AgentHandler: build debugState
  AgentHandler->>CanvasState: set Sys["query"] from sys.query
  AgentHandler->>CanvasState: keep Sys["tenant_id"] from canvas owner
  AgentHandler->>sysEchoComponent: Invoke(context with CanvasState)
  sysEchoComponent->>CanvasState: read Sys["query"] and Sys["tenant_id"]
  sysEchoComponent-->>AgentHandler: return output data
  AgentHandler-->>Client: JSON response
Loading

Poem

A rabbit peeks at prompts by moonlight,
Finds sys. keys and makes them right,
No self in sight, just clean new forms,
And debug paws keep tenant norms,
Hop-hop—inputs flow and tests feel bright. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed It clearly reflects the main change: aligning Go agent debug input form and sys input handling with Python.
Description check ✅ Passed It includes a concise summary, context, and test commands, which satisfies the repository template.
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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/handler/agent_component.go (1)

208-219: 🔒 Security & Privacy | 🔴 Critical | 🏗️ Heavy lift

Reserve tenant_id from sys.* passthrough DebugComponent seeds debugState.Sys["tenant_id"] from the authenticated canvas owner, but the later sys.* copy loop lets a request body overwrite it. resolveTenantLLMConfig reads that field and uses it to fetch tenant-scoped LLM credentials, so a debug request can steer the component to another tenant’s API key. Keep tenant_id server-derived, or reassign it after the loop and skip client-supplied sys.tenant_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 `@internal/handler/agent_component.go` around lines 208 - 219, DebugComponent
currently seeds debugState.Sys["tenant_id"] from the authenticated user, but the
later sys.* passthrough in agent_component.go can overwrite it from client
input. Update the DebugComponent path so tenant_id remains server-derived:
either skip copying any sys.tenant_id from inputs or reassign
debugState.Sys["tenant_id"] after the loop before resolveTenantLLMConfig is
used. Refer to DebugComponent, debugState.Sys, and resolveTenantLLMConfig when
making the change.
🤖 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/handler/agent_component_test.go`:
- Around line 215-272: Add a companion test in the same agent component test
area to cover the tenant override case for DebugComponent; the current
happy-path test with sysEchoComponent only verifies sys.query reaches
CanvasState. Extend the existing setup around AgentHandler.DebugComponent and
agentruntime.GetStateFromContext so it asserts a client-provided sys.tenant_id
is ignored and the canvas-owner-derived tenant id remains in state, using the
same fakeCanvasLoader and Probe component wiring.

---

Outside diff comments:
In `@internal/handler/agent_component.go`:
- Around line 208-219: DebugComponent currently seeds
debugState.Sys["tenant_id"] from the authenticated user, but the later sys.*
passthrough in agent_component.go can overwrite it from client input. Update the
DebugComponent path so tenant_id remains server-derived: either skip copying any
sys.tenant_id from inputs or reassign debugState.Sys["tenant_id"] after the loop
before resolveTenantLLMConfig is used. Refer to DebugComponent, debugState.Sys,
and resolveTenantLLMConfig when making the change.
🪄 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: 73861ee9-56b0-4df6-b24f-921ee568af4c

📥 Commits

Reviewing files that changed from the base of the PR and between 3d2f60c and c5bf0ae.

📒 Files selected for processing (4)
  • internal/agent/component/agent.go
  • internal/agent/component/agent_meta_test.go
  • internal/handler/agent_component.go
  • internal/handler/agent_component_test.go

@yuzhichang yuzhichang self-assigned this Jul 6, 2026
@yuzhichang

Copy link
Copy Markdown
Member

LGTM

@yuzhichang
yuzhichang merged commit c4166a9 into infiniflow:main Jul 6, 2026
3 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.

2 participants