Skip to content

feat(agent-service): enable Texera Agent to do workflow editing and execution#4540

Merged
bobbai00 merged 37 commits into
apache:mainfrom
bobbai00:branch-2-prime-revised
Apr 28, 2026
Merged

feat(agent-service): enable Texera Agent to do workflow editing and execution#4540
bobbai00 merged 37 commits into
apache:mainfrom
bobbai00:branch-2-prime-revised

Conversation

@bobbai00

@bobbai00 bobbai00 commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

This PR adds the tools for the Texera Agent to do CRUD operations on workflow, and execute the workflow to see the execution result.

Any related issues, documentation, discussions?

Closes #4493

How was this PR tested?

Manually tested

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

No

bobbai00 and others added 29 commits April 24, 2026 16:21
Introduce a standalone Bun/TypeScript service (agent-service) that hosts
conversational agents backed by the Vercel AI SDK, plus the Angular panel
and services that drive it over HTTP and a per-agent WebSocket.

This slice contains the framework only: step tree with HEAD and checkout,
per-step context assembly from the live DAG (via the compile API),
auto-persist of workflow edits to the dashboard, and shared operator
metadata loaded at startup. The agent has no tools yet, so it can
converse about the workflow without editing or executing it.

Workflow editing/execution tools, the SyncExecutionResource endpoint, and
the single-node and k8s deployment configs ship in follow-up PRs.
Add Bun-native unit tests for the two pure-logic state modules
(WorkflowState, WorkflowResultState) covering operator and link CRUD,
sub-DAG walking, ancestor-path result lookup, and checkout semantics.

Add an agent-service job to the build workflow that runs on Ubuntu,
macOS, and Windows: install with bun, prettier check, tsc --noEmit,
and bun test. Run prettier --write across existing source so the new
format:check step is green.
Remove types/execution.ts, agent/workflow-result-state.ts (and its test),
the computingUnitId field, and the result-summary plumbing in server.ts.
The /operator-results route stays and returns an empty map so the frontend
keeps working; branch-2 (tools) populates it once executeOperator lands.

Refactor server.ts to expose a buildApp() factory and start()/import.meta
gate so tests can drive the routes via app.handle(new Request(...)) — the
standard Elysia testing pattern. Move .onError onto the agentsRouter
instance so thrown errors inside its handlers are caught (Elysia 1.x scopes
error handlers to the instance they are attached to). Replace DELETE's
throw with a direct set.status = 404 for predictability.

Add server.test.ts covering /health, agent create/list/get/delete, the
stop/clear/operator-results control routes, settings PATCH round-trip,
invalid JWT rejection, and missing-modelType validation.
Add **/.env.example, **/.prettierrc, and **/bun.lock to paths-ignore.
These are config and lockfile artifacts that do not carry license
headers, and skywalking-eyes flagged them in the agent-service tree.
Drop the step-id badge that rendered at the top-left of each chat message
and the highlight-affected-operators toggle that rendered at the top-right.
Together they backed a canvas overlay that drew a dashed region around all
operators touched by a user message and a per-operator step badge stack.

Removed plumbing:
 - agent.service: highlightedMessageIdSubject/$, setHighlightedMessage,
   getHighlightedMessageId, operatorStepsMapSubject/$, updateOperatorStepsMap,
   addStepRef, getOperatorStepRefs, getOperatorStepsMap, getOperatorsForMessage,
   extractOperatorIdsFromToolResult, extractOperatorIdsFromObject, tryParseJson
 - agent-types: OperatorStepRef interface
 - agent-chat: highlightedMessageId field, highlightedMessageId$ subscription,
   isMessageHighlighted, toggleMessageHighlight, the badge and toggle markup,
   .message-highlight-btn styles
 - workflow-editor: showStepBadges, stepBadges, messageRegionElement,
   highlightedMessageOperators, highlightedMessageId, currentOperatorStepsMap,
   handleStepBadges, updateStepBadgePositions, onStepBadgeClick,
   handleMessageRegion, updateMessageRegion, updateMessageRegionPath,
   the .step-badges-container/.step-badge/.message-region styles, and the
   step-badges template block
The service backed canvas diff highlighting for agent-applied actions
(showDiff/clearDiff/toggleDiff via the version-diff helpers in
WorkflowVersionService). Nothing renders agent actions on the canvas
anymore, so drop the service and remove its single injection in
WorkflowEditorComponent. The version-diff helpers it called remain;
they are still used by WorkflowVersionService for the workflow version
history feature.
Eight files in this branch had drift unrelated to the agent-service
framework. Restore each to main:
 - dashboard/component/admin/user: drop sortByAffiliation/sortByJoiningReason
   columns
 - dashboard/service/user/workflow-version: drop highlightOpVersionDiffSimple
   and highlightOpBoundaryDashed (only callers were the now-removed
   AgentActionService)
 - dashboard/type/dashboard-entry: revert coverImageUrl signature tweak
 - workspace/component/menu: restore Status toggle, Edit Description button,
   region toggle, and onClickOpenShareAccess revoke-redirect logic
 - workspace/component/property-editor/operator-property-edit-frame: drop
   the editingTitle wrapper and the orphan .agent-interaction-controls
   styles (no markup consumed them)
 - Delete bin/agent-service.dockerfile. The framework PR no longer
   ships a deploy artifact; the dockerfile belongs with the deploy PRs
   (single-node, k8s).
 - Restore bin/computing-unit-master.dockerfile (drop the LICENSE/NOTICE
   copy and application.ini removal — unrelated to agent-service).
 - Restore bin/litellm-config.yaml (drop the extra commented-out model
   entries; the proxy already accepts the upstream model list).
…t-fixtures.ts to match main

Both diffs were unrelated to the agent-service framework — drift left
behind on this branch from earlier work.
…e stubs

The Edit / Save / Cancel / Reset-to-default buttons in the System Prompt
modal called methods whose only effect was a "managed server-side"
notification — the prompt is built from operator metadata at agent init
and the local edit was never persisted. Same for the per-tool nz-switch,
the Enable-all and Disable-all buttons.

Drop the buttons + textarea from the template, the corresponding stub
methods (saveSystemPrompt, resetSystemPromptToDefault, startEditingSystemPrompt,
cancelEditingSystemPrompt, toggleToolEnabled, enableAllTools, disableAllTools,
getEnabledToolsCount), the supporting fields (isEditingSystemPrompt,
editingSystemPrompt), the unused `enabled: boolean` shape on availableTools,
and the now-orphan SCSS rules (.settings-prompt-actions, .settings-textarea,
.settings-info, .settings-option, .settings-tools-header and its nested
.settings-tools-count / .settings-tools-actions, .settings-tool-item nz-switch).

The System Prompt tab now shows the prompt read-only; the Tools tab shows
the tool list read-only with name and description.
# Conflicts:
#	frontend/src/app/app.module.ts
#	frontend/src/app/workspace/component/agent-panel/agent-chat/agent-chat.component.ts
#	frontend/src/app/workspace/component/agent-panel/agent-panel.component.ts
#	frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.spec.ts
#	frontend/src/app/workspace/component/agent/agent-panel/agent-panel.component.html
#	frontend/src/app/workspace/component/workspace.component.ts
…tion endpoint

Wire four tools onto TexeraAgent so the LLM can edit and run workflows:
addOperator, modifyOperator, and deleteOperator (validated against the
operator JSON schema registry), plus executeOperator, which compiles the
current sub-DAG and runs it via the Texera execution service.

Introduce /api/execution/:wid/:cuid/run on the JVM backend
(SyncExecutionResource) as a synchronous endpoint that returns sampled
output rows plus per-port shape metadata. Forward ENV_AUTH_JWT_SECRET to
spawned computing-unit pods so they validate the agent's JWT.

After each addOperator or modifyOperator, the service re-executes the
affected operator and caches the result on the current step, so the model
sees updated schemas and previews on its next step.

Restores workflow-result-state, types/execution, and the computingUnitId
plumbing that branch-1 dropped pending this branch (per the deletion
commit's note: "branch-2 (tools) populates it once executeOperator lands").

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ng-zorro 21 dropped the nz-tabset selector. The agent-panel template was
updated during the Angular 21 merge but this modal was missed, so clicking
the info button next to the model name rendered an empty modal.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bobbai00 bobbai00 requested a review from aglinxinyuan April 28, 2026 01:58
@bobbai00 bobbai00 self-assigned this Apr 28, 2026
@github-actions github-actions Bot added engine dependencies Pull requests that update a dependency file frontend Changes related to the frontend GUI ci changes related to CI service labels Apr 28, 2026

@aglinxinyuan aglinxinyuan 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.

Per discussion in PR #4495.

# Conflicts:
#	.github/workflows/github-action-build.yml
#	agent-service/src/agent/index.ts
#	agent-service/src/agent/texera-agent.ts
#	agent-service/src/agent/tools/index.ts
#	agent-service/src/api/execution-api.ts
#	agent-service/src/api/index.ts
#	agent-service/src/index.ts
#	agent-service/src/server.ts
#	agent-service/src/types/agent.ts
#	agent-service/src/types/index.ts
#	frontend/src/app/workspace/component/agent/agent-interaction/agent-interaction.component.html
#	frontend/src/app/workspace/component/agent/agent-interaction/agent-interaction.component.scss
#	frontend/src/app/workspace/component/agent/agent-interaction/agent-interaction.component.ts
#	frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.html
#	frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.scss
#	frontend/src/app/workspace/component/agent/agent-panel/agent-chat/agent-chat.component.ts
#	frontend/src/app/workspace/component/agent/agent-panel/react-step-detail-modal/react-step-detail-modal.component.html
#	frontend/src/app/workspace/component/agent/agent-panel/react-step-detail-modal/react-step-detail-modal.component.ts
#	frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.html
#	frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts
#	frontend/src/app/workspace/service/agent/agent.service.ts
#	frontend/src/app/workspace/service/copilot/copilot-prompts.ts
@bobbai00 bobbai00 force-pushed the branch-2-prime-revised branch from 59f3abb to 235704f Compare April 28, 2026 03:42
@github-actions github-actions Bot removed dependencies Pull requests that update a dependency file frontend Changes related to the frontend GUI ci changes related to CI labels Apr 28, 2026
@bobbai00 bobbai00 enabled auto-merge (squash) April 28, 2026 04:23
@bobbai00 bobbai00 merged commit 98ba87e into apache:main Apr 28, 2026
13 checks passed
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
…xecution (apache#4540)

<!--
Thanks for sending a pull request (PR)! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
[Contributing to
Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
  2. Ensure you have added or run the appropriate tests for your PR
  3. If the PR is work in progress, mark it a draft on GitHub.
  4. Please write your PR title to summarize what this PR proposes, we 
    are following Conventional Commits style for PR titles as well.
  5. Be sure to keep the PR description updated to reflect all changes.
-->

### What changes were proposed in this PR?
<!--
Please clarify what changes you are proposing. The purpose of this
section
is to outline the changes. Here are some tips for you:
  1. If you propose a new API, clarify the use case for a new API.
  2. If you fix a bug, you can clarify why it is a bug.
  3. If it is a refactoring, clarify what has been changed.
  3. It would be helpful to include a before-and-after comparison using 
     screenshots or GIFs.
  4. Please consider writing useful notes for better and faster reviews.
-->

This PR adds the tools for the Texera Agent to do CRUD operations on
workflow, and execute the workflow to see the execution result.

### Any related issues, documentation, discussions?
<!--
Please use this section to link other resources if not mentioned
already.
1. If this PR fixes an issue, please include `Fixes apache#1234`, `Resolves
apache#1234`
or `Closes apache#1234`. If it is only related, simply mention the issue
number.
  2. If there is design documentation, please add the link.
  3. If there is a discussion in the mailing list, please add the link.
-->
Closes apache#4493 

### How was this PR tested?
<!--
If tests were added, say they were added here. Or simply mention that if
the PR
is tested with existing test cases. Make sure to include/update test
cases that
check the changes thoroughly including negative and positive cases if
possible.
If it was tested in a way different from regular unit tests, please
clarify how
you tested step by step, ideally copy and paste-able, so that other
reviewers can
test and check, and descendants can verify in the future. If tests were
not added,
please describe why they were not added and/or why it was difficult to
add.
-->
Manually tested

### Was this PR authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this
PR,
please include the phrase: 'Generated-by: ' followed by the name of the
tool
and its version. If no, write 'No'. 
Please refer to the [ASF Generative Tooling
Guidance](https://www.apache.org/legal/generative-tooling.html) for
details.
-->

No

---------

Co-authored-by: Chen Li <chenli@gmail.com>
Co-authored-by: Xinyuan Lin <xinyual3@uci.edu>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable LLM Agent to edit & execute user's workflow

3 participants