MCPcopy Create free account
hub / github.com/astercloud/aster / GetResult

Method GetResult

server/handlers/tool_runtime.go:90–129  ·  view source on GitHub ↗

GetResult 导出工具执行结果

(c *gin.Context)

Source from the content-addressed store, hash-verified

88
89// GetResult 导出工具执行结果
90func (h *ToolRuntimeHandler) GetResult(c *gin.Context) {
91 agentID := c.Query("agent_id")
92 callID := c.Param("id")
93 format := c.DefaultQuery("format", "json")
94 if agentID == "" || callID == "" {
95 c.JSON(http.StatusBadRequest, gin.H{"error": "agent_id and call id are required"})
96 return
97 }
98
99 if snap := h.runtimeSnapshot(agentID, callID); snap != nil {
100 switch format {
101 case "json":
102 c.JSON(http.StatusOK, gin.H{"result": snap.Result, "error": snap.Error})
103 default:
104 c.String(http.StatusOK, "%v", snap.Result)
105 }
106 return
107 }
108
109 records, err := (*h.store).LoadToolCallRecords(c.Request.Context(), agentID)
110 if err != nil {
111 c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
112 return
113 }
114
115 for _, rec := range records {
116 if rec.ID != callID {
117 continue
118 }
119 switch format {
120 case "json":
121 c.JSON(http.StatusOK, gin.H{"result": rec.Result, "error": rec.Error})
122 default:
123 c.String(http.StatusOK, "%v", rec.Result)
124 }
125 return
126 }
127
128 c.JSON(http.StatusNotFound, gin.H{"error": "call not found"})
129}
130
131func (h *ToolRuntimeHandler) runtimeSnapshot(agentID, callID string) *types.ToolCallSnapshot {
132 if h.reg == nil {

Callers

nothing calls this directly

Calls 7

runtimeSnapshotMethod · 0.95
JSONMethod · 0.80
QueryMethod · 0.65
LoadToolCallRecordsMethod · 0.65
ContextMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected