fix(翻译):修复(工具与沙箱解耦,双通道自适应)
deploy-hxtesting / build-and-deploy (push) Successful in 1m15s

This commit is contained in:
runny committed 2026-11-30 21:09:02 +08:00
1 parent db8472bf28
commit c6088aeb4b
4 files changed
+334 -126

No files matched your search

+48 -39
View File
@@ -99,28 +99,32 @@ func knowledgeBaseScopesForPrompt(config *types.AgentConfig) ([]string, map[stri
// agentService implements agent-related business logic
type agentService struct {
browserSkill *browserskill.Manager
userRepo interfaces.UserRepository
graphRepo interfaces.RetrieveGraphRepository
cfg *config.Config
modelService interfaces.ModelService
mcpServiceService interfaces.MCPServiceService
mcpManager *mcp.MCPManager
eventBus *event.EventBus
db *gorm.DB
webSearchService interfaces.WebSearchService
knowledgeBaseService interfaces.KnowledgeBaseService
knowledgeService interfaces.KnowledgeService
fileService interfaces.FileService
chunkService interfaces.ChunkService
duckdb *sql.DB
wikiPageService interfaces.WikiPageService
tenantService interfaces.TenantService
messageService interfaces.MessageService
memoryService interfaces.MemoryService
storageResolver interfaces.StorageBackendResolver
toolApprovalGate approval.MCPApproval
customAgentService interfaces.CustomAgentService
browserSkill *browserskill.Manager
userRepo interfaces.UserRepository
graphRepo interfaces.RetrieveGraphRepository
cfg *config.Config
modelService interfaces.ModelService
mcpServiceService interfaces.MCPServiceService
mcpManager *mcp.MCPManager
eventBus *event.EventBus
db *gorm.DB
webSearchService interfaces.WebSearchService
knowledgeBaseService interfaces.KnowledgeBaseService
knowledgeService interfaces.KnowledgeService
fileService interfaces.FileService
chunkService interfaces.ChunkService
duckdb *sql.DB
wikiPageService interfaces.WikiPageService
tenantService interfaces.TenantService
messageService interfaces.MessageService
memoryService interfaces.MemoryService
storageResolver interfaces.StorageBackendResolver
toolApprovalGate approval.MCPApproval
customAgentService interfaces.CustomAgentService
// temporaryDocuments lets file-producing agent tools deliver outputs as
// session attachments when no workspace sandbox exists (see
// registerXlsxTranslateTool / tools.NewXlsxTranslateTool).
temporaryDocuments interfaces.TemporaryDocumentService
operationDispatcher operations.Dispatcher
collaboration *AgentCollaboration
sandboxMgr sandbox.Manager
@@ -178,10 +182,12 @@ func NewAgentService(
shellJobs *ShellJobService,
operationDispatcher *operations.HandlerDispatcher,
customAgentService interfaces.CustomAgentService,
temporaryDocuments interfaces.TemporaryDocumentService,
collaboration *AgentCollaboration,
) interfaces.AgentService {
svc := &agentService{
customAgentService: customAgentService,
temporaryDocuments: temporaryDocuments,
operationDispatcher: operationDispatcher,
browserSkill: browserSkill,
userRepo: userRepo,
@@ -651,10 +657,13 @@ func (s *agentService) registerSandboxFileTools(
}
// registerXlsxTranslateTool registers the SIP/SOP workbook translation tool
// for agents that allow it. The tool reads the uploaded workbook through the
// session sandbox and delivers the English deliverable through the artifact
// output directory, so it follows the same sandbox capability gate as the
// file primitives: no session workspace, no translation tool.
// for agents that allow it. Registration deliberately does NOT require a
// workspace sandbox: the tool reads the upload and delivers the English
// workbook through the session attachment service when no sandbox exists,
// and through the artifact output directory when one does. Gating on the
// sandbox hid the tool on deployments without a workspace while the agent
// prompt still instructed the model to call it, surfacing as
// "tool not found: xlsx_translate".
func (s *agentService) registerXlsxTranslateTool(
ctx context.Context,
toolRegistry *tools.ToolRegistry,
@@ -676,22 +685,22 @@ func (s *agentService) registerXlsxTranslateTool(
logger.Infof(ctx, "xlsx_translate withheld: session has no chat model to translate with")
return
}
if s.temporaryDocuments == nil {
logger.Infof(ctx, "xlsx_translate withheld: attachment delivery service unavailable")
return
}
var store sandbox.SessionFileStore
sandboxMgr, err := s.resolveWorkspaceSandbox(ctx, sessionID, config)
if err != nil {
logger.Warnf(ctx, "Failed to resolve sandbox for xlsx_translate: %v", err)
return
if err == nil && sandboxMgr != nil {
store = sessionSandboxFileStore(sandboxMgr)
}
if sandboxMgr == nil {
logger.Infof(ctx, "xlsx_translate withheld: session has no workspace sandbox to read attachments and deliver output")
return
// store doubles as the dir ensurer; both are nil without a sandbox.
toolRegistry.RegisterTool(tools.NewXlsxTranslateTool(store, store, s.temporaryDocuments, chatModel))
if store != nil {
logger.Infof(ctx, "Registered xlsx_translate tool for session: %s (sandbox delivery)", sessionID)
} else {
logger.Infof(ctx, "Registered xlsx_translate tool for session: %s (attachment delivery)", sessionID)
}
store := sessionSandboxFileStore(sandboxMgr)
if store == nil {
logger.Infof(ctx, "xlsx_translate withheld: sandbox backend does not advertise session filesystem capability")
return
}
toolRegistry.RegisterTool(tools.NewXlsxTranslateTool(store, store, chatModel))
logger.Infof(ctx, "Registered xlsx_translate tool for session: %s", sessionID)
}
// registerSkillFileTools registers write_skill_file / edit_skill_file for the