Repository navigation
fix(go-agent): align agent debug input form with Python - #16654
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAgentComponent.GetInputForm now derives fields from prompt variable references instead of a ChangesPrompt-derived input form and sys.* debug seeding
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
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.
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 liftReserve
tenant_idfromsys.*passthroughDebugComponentseedsdebugState.Sys["tenant_id"]from the authenticated canvas owner, but the latersys.*copy loop lets a request body overwrite it.resolveTenantLLMConfigreads 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. Keeptenant_idserver-derived, or reassign it after the loop and skip client-suppliedsys.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
📒 Files selected for processing (4)
internal/agent/component/agent.gointernal/agent/component/agent_meta_test.gointernal/handler/agent_component.gointernal/handler/agent_component_test.go
|
LGTM |
Summary
sys.*debug params intoCanvasState.Sysso single-component debug resolves prompt variables like PythonTests
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:
