bobbai00 commented on code in PR #9496: URL: https://github.com/apache/texera/pull/9496#discussion_r4649375982
########## agent-service/src/agent/prompts.ts: ########## @@ -249,40 +250,21 @@ Result: - **Handle messy data files**: Load data files directly in a single operator. Real-world data files are often malformed — they may have wrong delimiters, missing or misplaced headers, metadata/comment rows, or multiple tables in one file. After loading, inspect the result. If column names look auto-generated (e.g., \`Unnamed: 0\`) or a data value appears as a header, adjust the loading parameters (e.g., \`header=\`, \`skiprows=\`, \`sep=\`) by modifying the data loading operator. - **Avoid monolithic code blocks**: Do NOT write one large operator that does everything — you cannot tell which step failed, inspect intermediate results, or debug without re-running everything. Instead, decompose into separate operators each doing ONE thing (e.g., filter → join → aggregate → filter → join → final filter). Each can be executed and verified independently. -## Available Operators +## Operators -You have the following operators available: +These are the operator types you can use. Before you add operators of types you have not used yet, read their properties with \`get_operator_schema\`, once for all of them. Review Comment: Thanks, fixed. The PR has two operator tools, `list_operator_types` and `get_operator_schema`, and `disabledTools` cannot switch either off (`isToolEnabled` in `texera-agent.ts`; the test is `the two operator tools cannot be switched off`). I also ran the case you describe with Claude Haiku 5.5: with the lookup off the request still finished, but 4 of 9 adds failed first and were retried from the schema in `addOperator`'s error. ########## 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: Yes. Users no longer choose which operator types an agent can use: the list of allowed types is removed, with its default, its setting and its toggle in the chat panel. The agent lists the types with `list_operator_types` and reads their properties with `get_operator_schema`. The PR is based on #9494, since the tools' results have to stay whole in the conversation. ########## 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: All three are in, adjusted to there being no list any more: - (a) `an agent with default settings lists the types, then looks up and adds any of them` adds `Split`, which was outside the 18. - (b) `stays within its budget, so no list of types or schemas grows back into it` holds the system prompt under 10 KB. It is 8.3 KB and takes no input, so it cannot grow with the types. - (c) With no list left to refuse by, `the lookup and the add tool refuse a type that does not exist` covers the refusal, and (a) covers a type being accepted. -- 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]
