Skip to content

refactor(agent-service): reorganize types and clients code with more test cases#5564

Open
bobbai00 wants to merge 4 commits into
apache:mainfrom
bobbai00:refactor/agent-service-codebase
Open

refactor(agent-service): reorganize types and clients code with more test cases#5564
bobbai00 wants to merge 4 commits into
apache:mainfrom
bobbai00:refactor/agent-service-codebase

Conversation

@bobbai00

@bobbai00 bobbai00 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

A refactor of agent-service/ for clarity and consistency, with no runtime behavior change:

  • Centralized type definitions under types/ (new types/metadata.ts, types/api.ts) and removed duplicates — LogicalPlan / PortSchema / InputPortInfo, and the identical AgentSettingsApi / UpdateAgentSettingsRequest.
  • Made api/ pure HTTP clients: extracted the execution client to api/execution-client.ts, moved JWT helpers to auth/jwt.ts and endpoint config to config/endpoints.ts, and renamed *-api.ts*-client.ts (backend-apioperator-metadata-client).
  • Clarified misleading *Config names: AgentDelegateConfigAgentDelegation (+ AgentDelegationDto), TexeraAgentConfigTexeraAgentOptions, ExecutionConfigExecutionRequestParams, getBackendConfiggetServiceEndpoints.
  • De-duplicated the table / IO-shape formatters into tools-utility.ts.
  • Reconciled types/ with the frontend wire contract: fixed CommentBox, added WorkflowSettings.executionMode, and corrected WorkflowFatalError.
  • Added unit tests covering the API clients, auth/JWT, agent lifecycle and generation, and the server delegate flow.

Any related issues, documentation, discussions?

Closes #5563

How was this PR tested?

Refactor with no behavior change, plus new unit tests. From agent-service/: bun install && bun test (132 pass, 0 fail), bun run typecheck (clean), bun run format:check (clean).

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

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

- Move all type/interface definitions under types/ (new types/metadata.ts,
  types/api.ts); drop duplicate LogicalPlan/PortSchema/InputPortInfo and the
  identical AgentSettingsApi/UpdateAgentSettingsRequest.
- Make api/ pure HTTP clients: extract the execution client
  (api/execution-client.ts), move JWT helpers to auth/jwt.ts and endpoint
  config to config/endpoints.ts, rename *-api.ts -> *-client.ts
  (backend-api -> operator-metadata-client).
- Rename misleading *Config types: AgentDelegateConfig -> AgentDelegation
  (+ AgentDelegationDto), TexeraAgentConfig -> TexeraAgentOptions,
  ExecutionConfig -> ExecutionRequestParams, getBackendConfig ->
  getServiceEndpoints.
- De-duplicate the table/IO-shape formatters into tools-utility.ts.
- Align CommentBox, WorkflowSettings.executionMode, and WorkflowFatalError
  with the frontend wire contract.

Refs apache#5563
@codecov-commenter

codecov-commenter commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.38%. Comparing base (75b4619) to head (f821f70).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5564      +/-   ##
============================================
+ Coverage     52.16%   55.38%   +3.21%     
  Complexity     2482     2482              
============================================
  Files          1067     1070       +3     
  Lines         41273    40970     -303     
  Branches       4437     4437              
============================================
+ Hits          21532    22693    +1161     
+ Misses        18479    17015    -1464     
  Partials       1262     1262              
Flag Coverage Δ *Carryforward flag
access-control-service 64.61% <ø> (ø) Carriedforward from 08f95bf
agent-service 75.89% <100.00%> (+42.12%) ⬆️
amber 53.23% <ø> (ø) Carriedforward from 08f95bf
computing-unit-managing-service 1.65% <ø> (ø) Carriedforward from 08f95bf
config-service 56.06% <ø> (ø) Carriedforward from 08f95bf
file-service 38.32% <ø> (ø) Carriedforward from 08f95bf
frontend 46.47% <ø> (ø) Carriedforward from 08f95bf
pyamber 90.69% <ø> (ø) Carriedforward from 08f95bf
python 90.83% <ø> (ø) Carriedforward from 08f95bf
workflow-compiling-service 58.69% <ø> (ø) Carriedforward from 08f95bf

*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.

Bob Bai added 3 commits June 7, 2026 23:44
Add unit tests (mocking fetch) for the client layer flagged by Codecov
on apache#5564, plus the auth and agent-lifecycle paths:
- execution-client, operator-metadata-client, workflow-client and
  compile-client (now ~100% line coverage)
- auth/jwt token decoding and validation
- TexeraAgent delegation, settings, and history accessors

Refs apache#5563
Extend coverage for the integration lines Codecov flagged on apache#5564:
- executeOperatorAndFormat: success, validation-error (no backend call),
  and backend-failure paths
- TexeraAgent.sendMessage: workflow refresh, post-step auto-execution via
  an addOperator tool call, and debounced auto-persist, driven by a stub
  LanguageModelV2 with mocked fetch
- server: delegated-agent creation (token masking) and graceful handling
  of a failed workflow load

Refs apache#5563
Export and exercise printStartupMessage, covering the three
getServiceEndpoints() log lines that were the last patch-coverage
gap on apache#5564.

Refs apache#5563
@bobbai00 bobbai00 changed the title refactor(agent-service): centralize types and isolate clients refactor(agent-service): reorganize types and clients code Jun 8, 2026
@bobbai00 bobbai00 changed the title refactor(agent-service): reorganize types and clients code refactor(agent-service): reorganize types and clients code with more test cases Jun 8, 2026
@bobbai00

bobbai00 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

cc @xuang7 I would like to include this in the release v1.2.

@bobbai00 bobbai00 requested a review from xuang7 June 8, 2026 19:38
@xuang7

xuang7 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Given that this is a broad refactor and does not change runtime behavior, I‘m leaning toward deferring it until after the v1.2 release to reduce release risk.

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.

Clean up agent-service code structure and reconcile its types with the frontend

3 participants