Skip to content

feat(agent-service, frontend): let the agent find operator types itself - #9496

Open
bobbai00 wants to merge 5 commits into
apache:mainfrom
bobbai00:feat/agent-operator-lookup
Open

bobbai00 wants to merge 5 commits into
apache:mainfrom
bobbai00:feat/agent-operator-lookup

Conversation

@bobbai00

@bobbai00 bobbai00 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Users had to choose which operator types an agent could use. The agent only knew a list of allowed types, 18 by default, and any other type had to be switched on by hand in the chat panel. This PR removes that list: the agent finds operator types itself with two tools and decides which to use.

Before This PR
Operator types the agent knows Those allowed in the chat panel, 18 by default Every type, with nothing to select
Finding a type The allowed types' schemas, in the system prompt list_operator_types: every type and what it does
Reading a type's properties The same schemas get_operator_schema, for several types in one call
What the model sees for one request, before and with this PR

The allowedOperatorTypes setting and the Operators tab of the agent's settings dialog are removed, and disabledTools cannot switch the two tools off. The PR is based on #9494, which keeps each tool's result whole in the conversation. This is the first part of #9481; edit_workflow and execute_workflow follow.

Any related issues, documentation, discussions?

Based on #9494; isolated diff: bobbai00/texera@feat/agent-native-messages...feat/agent-operator-lookup

Part of #9481
Part of #9453

How was this PR tested?

  • bun test (379 pass), bun run typecheck and bun run format:check in agent-service; the test suite (7,411 pass), ESLint and Prettier in frontend.
  • Seven real-model scenarios with Claude Haiku 5.5, three runs each: 21 of 21 passed, against 15 of 21 on the base, which does not know Regex or Split.
  • The evaluation from test(agent-service): evaluate the agent on real prompts #9495 passed 9 of 18 on both. A run here took 4.0 model calls and 40,536 input tokens, against 2.4 and 30,642, since the agent asks for the list and the schemas.
  • The chat panel, driven with Playwright against a running Texera.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 5.5, Claude Fable 5.2

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @eugenegujing, @aglinxinyuan, @oliarmak-web
    You can notify them by mentioning @eugenegujing, @aglinxinyuan, @oliarmak-web in a comment.

@codecov-commenter

codecov-commenter commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.67%. Comparing base (a1b5aad) to head (620f257).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9496      +/-   ##
============================================
- Coverage     91.68%   91.67%   -0.02%     
  Complexity     5125     5125              
============================================
  Files          1305     1306       +1     
  Lines         58211    58124      -87     
  Branches       7594     7588       -6     
============================================
- Hits          53371    53284      -87     
  Misses         2933     2933              
  Partials       1907     1907              
Flag Coverage Δ *Carryforward flag
access-control-service 77.44% <ø> (ø) Carriedforward from bc92e98
agent-service 99.55% <100.00%> (-0.01%) ⬇️
amber 85.79% <ø> (ø) Carriedforward from bc92e98
computing-unit-managing-service 63.83% <ø> (ø) Carriedforward from bc92e98
config-service 87.50% <ø> (ø) Carriedforward from bc92e98
file-service 82.16% <ø> (ø) Carriedforward from bc92e98
frontend 96.43% <ø> (-0.01%) ⬇️
notebook-migration-service 83.77% <ø> (ø) Carriedforward from bc92e98
pyamber 98.32% <ø> (ø) Carriedforward from bc92e98
result-service 86.48% <ø> (ø) Carriedforward from bc92e98
workflow-compiling-service 80.90% <ø> (ø) Carriedforward from bc92e98

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bobbai00
bobbai00 force-pushed the feat/agent-operator-lookup branch from 576416c to 7fd7ae0 Compare November 19, 2026 08:38
*/
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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFAULT_AGENT_SETTINGS.allowedOperatorTypes in types/agent.ts still has the initial operators list, do you think all operator types would be exposed here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread agent-service/src/agent/texera-agent.ts Outdated

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Ma77Ball Ma77Ball left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

This PR swaps the per-type schema dump in the system prompt for a one-line-per-type list plus a get_operator_schema lookup. It also makes the prompt, the lookup and addOperator share one list from usableOperatorTypes. The design is sound: the prompt stays small and stable even with all operator types allowed, which unblocks widening the default allowlist. addOperator now rejects types outside the allowed list, the prompt no longer points at a nonexistent getOperatorSchema, and the tools are rebuilt on every settings change, so the three cannot drift apart. The one gap is that the lookup tool can be disabled while the prompt still requires it. Clean, no blocking issues.

Action items: Nothing blocking; the P2 below is worth fixing before or soon after merge.


Findings

1 total: 0 P0, 0 P1, 1 P2, 0 P3.

Non-blocking (P2)

  • Keep the prompt's lookup instruction in sync with disabledTools - agent-service/src/agent/prompts.ts:255 - see inline.

Verification

  • Checked that createTools() runs again inside updateSettings (texera-agent.ts:407), so changing allowedOperatorTypes updates the prompt, the lookup and addOperator together.
  • Checked the unknown-type paths: the lookup throws, and the existing tool-error handling (texera-agent.ts:609-618) records the throw as a failed tool result. addOperator returns an error that lists the usable types.
  • The new tests cover the shared list end to end (texera-agent.spec.ts:738) and the lookup's output shape. I did not run the test suite.

Comment thread agent-service/src/agent/prompts.ts Outdated
## 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The system in this design always calls get_operator_schema before adding operators, but the tool can be switched off through settings.disabledTools. getEnabledTools() (texera-agent.ts:251) drops it while rebuildSystemPrompt() ignores disabledTools. If a client sets it through the settings API (disabledTools on create or PATCH /:id/settings, server.ts:244), the model is told to call a tool it does not have. Since this PR removed the schemas from the prompt, it then has no way to see an operator's properties, and it either calls the missing tool or guesses at addOperator properties until validation fails.

Suggested fix (manual, two spots): either leave TOOL_NAME_GET_OPERATOR_SCHEMA out of the set of tools that can be disabled, or pass whether it is enabled into buildSystemPrompt. In the second case, fall back to the old inline compact schemas when it is off, and call rebuildSystemPrompt() when disabledTools changes. The first is simpler, since without the lookup the agent cannot build valid operators.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bobbai00
bobbai00 force-pushed the feat/agent-operator-lookup branch from 7fd7ae0 to e71a251 Compare November 21, 2026 00:35
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Nov 21, 2026
@bobbai00 bobbai00 changed the title feat(agent-service): look up operator schemas with a tool feat(agent-service, frontend): let the agent find operator types itself Nov 21, 2026
@bobbai00
bobbai00 force-pushed the feat/agent-operator-lookup branch from e71a251 to 0c069f5 Compare November 23, 2026 18:28
@bobbai00
bobbai00 requested a review from Ma77Ball November 23, 2026 18:44
bobbai00 and others added 5 commits November 23, 2026 22:56
Before every model call, the agent dropped the SDK's messages and wrote one
user message: a summary of the conversation followed by the current
dataflow. A past tool call appeared as its name, its summary and the first
line of its result.

Each step now keeps the model messages it added: the user's message, or the
assistant message with its tool calls and the tool results. The model reads
these along the path to HEAD, so a branch HEAD has left stays out of sight.
The current dataflow is one message at the end of every step's input,
written again each time and never kept. The loop runs as the SDK's
ToolLoopAgent, and the system prompt describes only the dataflow block.

A tool call the SDK did not run, because its response was cut off, is kept
with a failed result: the SDK refuses a conversation in which a call has no
result, so every later turn would fail.
After addOperator or modifyOperator the service executed the operator
itself, outside the tool call, and the result reached the model only
through the dataflow block. That block is not kept, so on a later turn the
agent found numbers in its own answers that no tool result showed, and told
the user they were unverified.

The two tools now execute the operator they changed and return the
execution's result after their own line. A failed or stopped execution
follows the change and does not turn it into a failure. The result is
still filed under the step that made the change.
Every model call ended with a dataflow block that the service rebuilt for
that call, so the last message changed on every call. A prompt cache
point on the last message, which LiteLLM's automatic caching places, was
never read back, and only the tool definitions and system prompt were
reused.

The block is gone: the model reads the SDK's own messages, so every call
begins with the previous call's input. It reads the workflow with two new
tools. getWorkflow lists each operator with its properties, schemas,
compilation error and whether its result is there, outdated or failed,
then the links. getOperatorResult returns an operator's latest result
without executing anything, or says that it is outdated. Each result now
records what it was computed from, so a change to the operator or to one
it reads from makes the result outdated. disabledTools cannot switch the
two tools off. The result formatter that only fed the block is removed.
getWorkflow and getOperatorResult become get_workflow and
get_operator_result. New tools are named in snake_case; the four
existing ones keep their names.
Users had to choose which operator types an agent could use: the agent only
knew a list of allowed types, 18 by default, and any other type had to be
switched on by hand in the chat panel.

The list is removed. `list_operator_types` names every operator type and what
it does, and `get_operator_schema` gives the properties of the types the agent
picks, several in one call, so the system prompt describes no operator type.
The `allowedOperatorTypes` setting, the `/:id/operator-types` route and the
Operators tab of the chat panel's settings dialog are gone, and `disabledTools`
cannot switch the two tools off.
@bobbai00
bobbai00 force-pushed the feat/agent-operator-lookup branch from 0c069f5 to 620f257 Compare November 24, 2026 07:02

@Ma77Ball Ma77Ball left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall there are no blocking issues and it LGTM!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-service feature frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants