xonecas.io
60255
Zn

Zoea-Nova / commit 8a7a993

Remove rewriteSessionError to preserve upstream API integrity

Deleted rewriteSessionError function and all usages. Upstream SpaceMolt
error messages now pass through unmodified, maintaining API contract.

xonecas2026-02-09 8a7a993142918bace570d342fab337690fc220dd parent 172b4b5

1 file changed

internal/mcp/proxy.go+3−39
@@ -230,18 +230,8 @@ func (p *Proxy) CallTool(ctx context.Context, caller CallerContext, name string,
230230
231231 result, err := p.callUpstreamWithRetry(ctx, name, args)
232232
233- if result != nil {
234- if !result.IsError && accountStore != nil {
235- p.interceptAuthTools(name, arguments, result, caller.MysisID)
236- }
237- if result.IsError {
238- // Rewrite error messages to guide myses toward correct behavior
239- for i := range result.Content {
240- if result.Content[i].Type == "text" {
241- result.Content[i].Text = p.rewriteSessionError(result.Content[i].Text)
242- }
243- }
244- }
233+ if result != nil && !result.IsError && accountStore != nil {
234+ p.interceptAuthTools(name, arguments, result, caller.MysisID)
245235 }
246236
247237 return result, err
@@ -249,7 +239,7 @@ func (p *Proxy) CallTool(ctx context.Context, caller CallerContext, name string,
249239
250240 errorMsg := fmt.Sprintf("tool not found: %s", name)
251241 return &ToolResult{
252- Content: []ContentBlock{{Type: "text", Text: p.rewriteSessionError(errorMsg)}},
242+ Content: []ContentBlock{{Type: "text", Text: errorMsg}},
253243 IsError: true,
254244 }, nil
255245 }
@@ -532,32 +522,6 @@ func findStringFieldAtPath(payload interface{}, path ...string) (string, bool) {
532522 return "", false
533523 }
534524
535-// rewriteSessionError improves session-related error messages to guide myses
536-// toward correct behavior instead of causing claim→login loops.
537-func (p *Proxy) rewriteSessionError(errorMsg string) string {
538- // Handle session_required errors
539- if strings.Contains(errorMsg, "session_required") {
540- // Original: "You must provide a session_id. Get one by calling login() or register() first."
541- // Problem: Tells mysis to login again even if they already have session_id
542- return strings.Replace(errorMsg,
543- "Get one by calling login() or register() first.",
544- "Check your recent tool results for session_id from login/register and use it as a parameter.",
545- 1)
546- }
547-
548- // Handle session_invalid errors
549- if strings.Contains(errorMsg, "session_invalid") {
550- // Original: "Call login() again to get a new session_id."
551- // This is actually correct - session truly expired
552- // But add clarity about when this happens
553- if strings.Contains(errorMsg, "Session not found or expired") {
554- return errorMsg + " This means your session truly expired (server restart, timeout, or duplicate login)."
555- }
556- }
557-
558- return errorMsg
559-}
560-
561525 // Initialize initializes the upstream connection if available.
562526 func (p *Proxy) Initialize(ctx context.Context) error {
563527 if p.upstream == nil {