Repository navigation
fix: The upgrade from v2 to v3 of the [Agent] caused abnormal skill display in the advanced AI conversation node references - #8214
Conversation
…isplay in the advanced AI conversation node references
| '调用大模型生成回答,可流式输出给用户,可挂载工具 / Skills / MCP / 智能体。面向用户的最终回答 is_result=true,中间加工步骤为 false;' + | ||
| '基于知识库回答时提示词同时引用检索结果 data 与用户问题,并要求仅依据已知信息作答;后一步加工时引用前一步的 answer', | ||
| params, | ||
| config, |
There was a problem hiding this comment.
user¿cómo puedo quResulta que est# Valid channels: analysis, commentary, final. Channel must be included for every message.
assistant
| }, | ||
| getToolById(toolId: string): Promise<ToolItem> { | ||
| if (!requestApi.getToolById) return Promise.resolve({} as ToolItem) | ||
| return withCache(`tool:${toolId}`, () => requestApi.getToolById!(toolId), force) |
There was a problem hiding this comment.
Overall, the diff is syntactically consistent and follows the existing store pattern. I do not see an immediate TypeScript syntax problem, but there are several correctness and maintainability risks.
1. High: cache keys can collide across scopes/workspaces
cacheMap and pendingMap are module-level, but the new cache keys do not include resourceScope or the resolved workspace:
tool-all:${JSON.stringify(query)}
tool-shared:${JSON.stringify(query)}
application-list:${JSON.stringify(query)}If two useWorkflowStore instances are created for different scopes/workspaces and produce the same query shape, they will share cached results incorrectly.
Example: getSharedToolList() for workspace and system-resource both produce:
{ tool_type_list: NODE_TOOL_TYPES }so both use the same cache key tool-shared:{"tool_type_list":[...]}.
Recommendation: include scope/workspace in every new cache key, e.g.:
function scopeCacheKey() {
return `${resourceScope}:${getResourceWorkspaceId?.() ?? ''}`
}
withCache(
`tool-shared:${scopeCacheKey()}:${JSON.stringify(query)}`,
...
)Apply the same idea to tool-all and application-list.
2. High: shared tools / applications may need workspace context
buildOwnToolQuery() correctly adds workspace_id for system-resource, but getSharedTools() and getApplicationList() do not.
If the backend scopes shared tools or published applications by the current workspace/resource workspace, those methods may return wrong or overly broad results for system-resource.
Recommendation: verify whether getAllSharedTool and getAllApplication require workspace_id for system-resource. If so, reuse the same scoped-query logic as buildOwnToolQuery().
3. Medium: comments say “return empty array” but implementation only checks API existence
For example:
/** AI 对话节点可挂载的共享工具;当前范围或版本不支持共享时返回空数组 */
getSharedToolList(): Promise<ToolItem[]> {
return getSharedTools(NODE_TOOL_TYPES, force)
}The code returns [] only when requestApi.getAllSharedTool is missing. If the current scope does not support sharing but the API method exists, it will still call the API.
Same concern applies to getApplicationList().
Recommendation: either add an explicit scope-support check, or update the comments so they match actual behavior.
4. Medium: unresolved workspace silently becomes “no tools”
In buildOwnToolQuery():
if (getResourceWorkspaceId && !workspaceId) return nullthen in getOwnTools():
if (!requestApi.getAllTool || !query) return Promise.resolve([])This makes “workspace not resolved yet” indistinguishable from “there are no tools”. The UI may show an empty list instead of waiting/loading.
Recommendation: consider returning a rejected promise or a distinct loading/unsupported state, or document this behavior and ensure callers retry after workspace resolution.
5. Medium: exported mutable array
export const NODE_TOOL_TYPES: ToolType[] = [...]Consumers can mutate this array, which would change query construction and cache keys globally.
Recommendation: use a readonly type and/or freeze it:
export const NODE_TOOL_TYPES: ReadonlyArray<ToolType> = Object.freeze([
TOOL_TYPE.CUSTOM,
TOOL_TYPE.WORKFLOW,
TOOL_TYPE.INTERNAL,
])Then update helper signatures to accept readonly ToolType[].
6. Low: hard-coded status string
publish_status: 'published'Prefer an enum/constant if one exists, e.g. APPLICATION_PUBLISH_STATUS.PUBLISHED, to avoid typos and improve type safety.
7. Low: verify the “shared cache” comment for applications
The comment says:
// 与 getAllApplication 共用缓存。but the cache key is:
application-list:${JSON.stringify(query)}Verify that this matches the existing getAllApplication cache key and query shape. If it does not, the comment is misleading and the cache is duplicated. If it does but the query differs, there is a stale/collision risk.
8. Minor optimization suggestions
- Extract a small helper for optional API calls to avoid repeated non-null assertions:
const api = requestApi.getAllTool
if (!api) return Promise.resolve([])
return withCache(..., () => api(query), force)- Avoid duplicating
withCachequery-building logic acrossgetOwnTools,getSharedTools, andgetApplicationList. - Replace string literals such as
'workspace'and'system-resource'with shared constants/enums if available. - Sort
toolTypesbefore using them in cache keys if callers can pass arrays in different orders. - Update any mocks/tests implementing
WorkflowStoreApi, because the new methods are required on that interface.
fix: The upgrade from v2 to v3 of the [Agent] caused abnormal skill display in the advanced AI conversation node references