bobbai00 opened a new issue, #9481:
URL: https://github.com/apache/texera/issues/9481

   ### Task Summary
   
   Today the agent changes a workflow with three tools, `addOperator`, 
`modifyOperator` and `deleteOperator`, and each call changes one operator. A 
workflow of four operators takes at least four model calls, and a change that 
needs several operators at once, such as putting a filter between two connected 
operators, passes through half-done states. After every add or modify, the 
service also executes the operator by itself, outside the tool protocol 
(`texera-agent.ts:630`). The schemas of the allowed operator types are written 
into the system prompt (18.8 KB by default, 189.2 KB with all 168 types), while 
the add tool accepts every type and its description points at a 
`getOperatorSchema` tool that does not exist.
   
   I propose these tools instead:
   
   | Tool | What it does |
   | --- | --- |
   | `get_workflow` | The workflow as it stands: operators, links, and each 
operator's output schema and errors from the compiler |
   | `edit_workflow` | One patch to a workflow: any number of operators added, 
modified or deleted, with their links, applied whole or not at all |
   | `find_operator` | The operator types that match a query, one line each |
   | `get_operator_schema` | The schema of one operator type |
   | `execute_workflow` | Executes the workflow, or the part up to one 
operator, and returns each operator's state, row counts, errors and a sample |
   
   A patch is a list of changes. Each change takes the fields today's tools 
take (`operatorId`, `operatorType`, `properties`, `inputOperatorIds`, 
`summary`), plus `op`: `add`, `modify` or `delete`. For example, "which three 
product categories have the highest total sales?", asked of a workflow that 
already scans `orders.csv` as `op1`, is one call:
   
   ```json
   {
     "workflowId": 42,
     "changes": [
       { "op": "add", "operatorId": "op2", "operatorType": "Aggregate", 
"inputOperatorIds": { "0": ["op1"] },
         "properties": { "aggregations": [{ "aggFunction": "sum", "attribute": 
"amount", "result attribute": "total_sales" }], "groupByKeys": ["category"] },
         "summary": "Total sales per category" },
       { "op": "add", "operatorId": "op3", "operatorType": "Sort", 
"inputOperatorIds": { "0": ["op2"] },
         "properties": { "attributes": [{ "attribute": "total_sales", 
"sortPreference": "DESC" }] },
         "summary": "Sort by total sales" },
       { "op": "add", "operatorId": "op4", "operatorType": "Limit", 
"inputOperatorIds": { "0": ["op3"] },
         "properties": { "limit": 3 },
         "summary": "Keep top three" }
     ]
   }
   ```
   
   Today this takes three calls of `addOperator`, and each is followed by an 
execution the model did not ask for.
   
   - `modify` merges the given properties into the operator's, and its 
`inputOperatorIds` replace the operator's incoming links, as `modifyOperator` 
does today. `delete` removes the operator and its links.
   - The whole patch is checked before anything changes: operator types against 
the allowed list, properties against the schemas, and links against the ports. 
If one change fails, nothing is applied, and the error names that change and 
the reason.
   - Changes name operators by id, not by their place in a list, so a patch 
still applies when someone else changed the workflow in between.
   - A tool that fails throws, so the model reads a tool error and the chat 
shows the call as failed. This replaces the `[ERROR]` prefix behind #9120.
   - The agent executes only when the model calls `execute_workflow`.
   - `find_operator`, `get_operator_schema` and `edit_workflow` use the same 
list of allowed operator types.
   
   The tools stay in the agent service for now and edit the agent's copy of the 
workflow. #9464 then points them at the shared workflow, and #9457 serves them 
from the Texera MCP server with the same names and inputs, so the skills 
(#9456) and the evaluation (#9454) do not change. A patch also matches the 
PATCH that #9395 proposes for updating any resource, so this tool can later 
come from that contract.
   
   Done when the three operator tools and `executeOperator` are gone, no 
operator schema is in the system prompt, and #9454 reports the score and tokens 
before and after.
   
   ### Task Type
   
   - [x] Refactor / Cleanup
   - [ ] DevOps / Deployment / CI
   - [ ] Testing / QA
   - [ ] Documentation
   - [ ] Performance
   - [ ] Other
   


-- 
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]

Reply via email to