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

## 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:
<img width="669" height="456" alt="image"
src="https://github.com/user-attachments/assets/4fd86559-aafc-4027-91ae-6e666137ee1b"
/>
This commit is contained in:
Hz_
2026-07-06 13:29:10 +08:00
committed by GitHub
parent c9f064d5fd
commit c4166a91e0
4 changed files with 203 additions and 31 deletions

View File

@@ -32,6 +32,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"github.com/gin-gonic/gin"
@@ -211,6 +212,11 @@ func (h *AgentHandler) DebugComponent(c *gin.Context) {
// decorator for the debug endpoint.
debugState := canvas.NewCanvasState("debug-"+componentID, "debug-task")
debugState.Sys["tenant_id"] = user.ID
for key, value := range inputs {
if strings.HasPrefix(key, "sys.") && key != "sys.tenant_id" {
debugState.Sys[strings.TrimPrefix(key, "sys.")] = value
}
}
invokeCtx := runtime.WithState(c.Request.Context(), debugState)
outputs, err := comp.Invoke(invokeCtx, inputs)