Skip to content

Give the agent one workflow edit tool that takes a patch #9481

Open

Description

@bobbai00

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
get_operator_schema The schemas of the operator types it is given, several in one call
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:

{
  "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 Failed tool calls are marked as succeeded (isError is always false) #9120.
  • The agent executes only when the model calls execute_workflow.
  • The system prompt names each usable operator type in one line, and the prompt, get_operator_schema and edit_workflow use the same list of allowed operator types. (A find_operator tool in place of the list cost twice the model calls in feat(agent-service): look up operator schemas with a tool #9496's measurements.)

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

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions