Skip to content

refactor(agent-service): extract tool utilities and simplify server wiring#5754

Draft
bobbai00 wants to merge 3 commits into
apache:mainfrom
bobbai00:refactor/agent-service-tools-server
Draft

refactor(agent-service): extract tool utilities and simplify server wiring#5754
bobbai00 wants to merge 3 commits into
apache:mainfrom
bobbai00:refactor/agent-service-tools-server

Conversation

@bobbai00

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Final slice of the agent-service reorganization (no runtime behavior change):

  • Extract shared tool helpers into agent/tools/tools-utility.ts; slim result-formatting.ts and workflow-execution-tools.ts.
  • Tidy texera-agent.ts and agent/util/* (workflow-system-metadata, workflow-utils).
  • Simplify server.ts/index.ts wiring and startup-banner logging; switch the remaining getBackendConfig consumers to getServiceEndpoints() and remove the now-unused api/backend-api.ts.
  • Complete the type reshaping deferred from the earlier slices: agent.ts DTO renames (AgentDelegateConfigAgentDelegation, AgentSettingsApiAgentSettingsDto) and workflow.ts Comment/CommentBox plus the now-required WorkflowSettings.executionMode (updating workflow-state.ts).
  • Add tests: texera-agent.test.ts, tools/workflow-execution-tools.test.ts, and expanded server.test.ts/result-formatting.test.ts.

Stacked on #5753 (which is stacked on #5751). Until those merge, the "Files changed" tab here includes their commits — review the extract tool utilities and simplify server wiring commit for this PR's changes. Please merge after #5753.

Any related issues, documentation, discussions?

Closes #5750
Part of #5747

How was this PR tested?

bunx tsc --noEmit, bun test (134 pass / 0 fail), and prettier --check all pass in agent-service.

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

Generated-by: Claude Opus 4.8 (1M context)

bobbai00 added 3 commits June 16, 2026 22:28
…module

Foundation slice of the agent-service reorganization (no runtime behavior
change):

- Add src/types/api.ts (wire DTOs) and src/types/metadata.ts (operator
  metadata types extracted out of api/backend-api.ts); export both from the
  types barrel.
- Add src/config/endpoints.ts exposing getServiceEndpoints().
- Move src/api/auth-api.ts -> src/auth/jwt.ts (content unchanged) and add
  src/auth/jwt.test.ts; update auth import paths.
- Keep api/backend-api.ts transitional: it now imports/re-exports the metadata
  types from ../types/metadata and retains getBackendConfig/fetchOperatorMetadata,
  which the follow-up clients PR relocates.

The types/agent.ts and types/workflow.ts reshaping is deferred to the PR that
also updates server.ts/workflow-state.ts, since those renames are coupled.
Second slice of the agent-service reorganization (no runtime behavior change):

- Rename the per-service HTTP clients to *-client.ts: compile-api -> compile-client,
  workflow-api -> workflow-client, and split operator-metadata fetching into
  operator-metadata-client.ts; add a dedicated execution-client.ts for workflow
  execution calls. All clients now read base URLs via getServiceEndpoints().
- Rewire api/index.ts to the new client modules.
- Add unit tests for all four clients.
- Add the additive ExecutionRequestParams type (types/agent.ts) and ExecutionMode
  enum + optional WorkflowSettings.executionMode (types/workflow.ts) needed by the
  new client and its test; the follow-up server/state PR completes the
  workflow.ts reshaping and makes executionMode required.
- Trim api/backend-api.ts to just getBackendConfig (transitional); the remaining
  server/tools consumers switch to getServiceEndpoints in the follow-up PR.

Consumer changes are import-path-only; no logic was modified.
…iring

Final slice of the agent-service reorganization (no runtime behavior change):

- Extract shared tool helpers into agent/tools/tools-utility.ts and slim
  result-formatting.ts and workflow-execution-tools.ts accordingly.
- Tidy texera-agent.ts and agent/util/* (workflow-system-metadata, workflow-utils).
- Simplify server.ts / index.ts wiring and startup-banner logging; switch the
  remaining getBackendConfig consumers to getServiceEndpoints() and remove the
  now-unused api/backend-api.ts.
- Complete the types reshaping deferred from the earlier slices: agent.ts
  delegation/settings DTO renames (AgentDelegateConfig -> AgentDelegation,
  AgentSettingsApi -> AgentSettingsDto) and workflow.ts Comment/CommentBox plus
  the now-required WorkflowSettings.executionMode, updating workflow-state.ts.
- Add tests: texera-agent.test.ts, tools/workflow-execution-tools.test.ts,
  expanded server.test.ts and result-formatting.test.ts.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.14%. Comparing base (07724d5) to head (dac5089).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5754      +/-   ##
============================================
+ Coverage     53.04%   56.14%   +3.10%     
  Complexity     2654     2654              
============================================
  Files          1094     1097       +3     
  Lines         42295    41991     -304     
  Branches       4545     4545              
============================================
+ Hits          22434    23577    +1143     
+ Misses        18545    17098    -1447     
  Partials       1316     1316              
Flag Coverage Δ *Carryforward flag
access-control-service 70.44% <ø> (ø) Carriedforward from cc17f01
agent-service 75.95% <100.00%> (+41.59%) ⬆️
amber 53.34% <ø> (ø) Carriedforward from cc17f01
computing-unit-managing-service 1.65% <ø> (ø) Carriedforward from cc17f01
config-service 56.71% <ø> (ø) Carriedforward from cc17f01
file-service 57.06% <ø> (ø) Carriedforward from cc17f01
frontend 47.93% <ø> (ø) Carriedforward from cc17f01
pyamber 89.77% <ø> (ø) Carriedforward from cc17f01
python 90.73% <ø> (ø) Carriedforward from cc17f01
workflow-compiling-service 58.69% <ø> (ø) Carriedforward from cc17f01

*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 marked this pull request as draft June 17, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-service refactor Refactor the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(agent-service): redesign the sync-execution result and error model

2 participants