sshiv012 commented on code in PR #9496: URL: https://github.com/apache/texera/pull/9496#discussion_r4647353413
########## agent-service/src/agent/tools/operator-tools.ts: ########## @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// The operator lookup. The system prompt names each operator type the agent may use, one line +// each; the properties of a type are read through `get_operator_schema` when the agent needs them, +// rather than every allowed type's schema riding along on every call. + +import { tool } from "ai"; +import { z } from "zod"; +import type { WorkflowSystemMetadata } from "../util/workflow-system-metadata"; + +export const TOOL_NAME_GET_OPERATOR_SCHEMA = "get_operator_schema"; + +/** + * The operator types the agent may use: the allowed ones the metadata knows, or every type it + * knows when none are named. The prompt's list, the lookup and the add tool all go by this one list. + */ +export function usableOperatorTypes(metadataStore: WorkflowSystemMetadata, allowed: string[]): string[] { + const known = Object.keys(metadataStore.getAllOperatorTypes()); + return allowed.length === 0 ? known : allowed.filter(type => known.includes(type)); Review Comment: DEFAULT_AGENT_SETTINGS.allowedOperatorTypes in types/agent.ts still has the initial operators list, do you think all operator types would be exposed here? ########## agent-service/src/agent/texera-agent.ts: ########## @@ -199,8 +204,10 @@ export class TexeraAgent { } private createTools(): Record<string, any> { + // One list of operator types: what the prompt names and the lookup describes is what can be added. + const usableTypes = usableOperatorTypes(this.metadataStore, this.settings.allowedOperatorTypes); Review Comment: Related to my other comment, With the default 18 type allowlist it should be more restrictive now? Can we also add test cases (a) to ensure an agent created with default settings can look up and add an operator that isn’t in the current 18-type default. This pins down the “all operators by default” behavior once the default changes. (b) a size check on the system prompt with every type listed, so the token savings can’t quietly regress. (c) An agent with an allowlist refuses addOperator for a type outside it (and accepts one inside). Right now only the lookup tool’s refusal is tested. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
