Skip to content

test(agent-service): add unit test coverage for assembleContext#6354

Merged
mengw15 merged 2 commits into
apache:mainfrom
mengw15:chore/6333-context-utils-test
Jul 12, 2026
Merged

test(agent-service): add unit test coverage for assembleContext#6354
mengw15 merged 2 commits into
apache:mainfrom
mengw15:chore/6333-context-utils-test

Conversation

@mengw15

@mengw15 mengw15 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Add unit test coverage for assembleContext in agent-service/src/agent/util/context-utils.ts — a pure function (type-only imports, no network) that groups ReActSteps by task, serializes completed vs ongoing tasks into markdown sections, appends a dataflow section, and returns [{ role: "user", content }]. A bun test .spec.ts sits next to the source. No production-code changes.

Any related issues, documentation, discussions?

Closes #6333.

How was this PR tested?

bun test src/agent/util/context-utils.spec.ts

5 pass. bun run typecheck and bun run format:check are clean. The spec is pure — it builds ReActStep / WorkflowState / OperatorPredicate fixtures in-process and covers: empty steps → a single user message with no task sections; a completed task under # Completed Tasks (## Task (completed) with the request + turns); an unfinished task under # Ongoing Task; a # Current Dataflow section when the workflow has operators; and steps sharing a messageId grouped into one task.

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

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

assembleContext (context-utils.ts) is a pure, type-only-import function
that groups ReActSteps by task, serializes completed vs ongoing tasks into
markdown, appends a dataflow section, and returns a single user message.
Cover the empty-steps, completed-task, ongoing-task, dataflow-section, and
messageId-grouping cases with a bun test .spec.ts next to the source.

Closes apache#6333.
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

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

  • No candidates found from git blame history.

@codecov-commenter

codecov-commenter commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.55%. Comparing base (0ed4816) to head (c988e39).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6354      +/-   ##
============================================
+ Coverage     61.12%   61.55%   +0.43%     
  Complexity     3381     3381              
============================================
  Files          1142     1142              
  Lines         45020    44988      -32     
  Branches       4948     4948              
============================================
+ Hits          27518    27693     +175     
+ Misses        15983    15776     -207     
  Partials       1519     1519              
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 972c66a
agent-service 50.48% <ø> (+5.88%) ⬆️
amber 66.58% <ø> (ø) Carriedforward from 972c66a
computing-unit-managing-service 9.97% <ø> (ø) Carriedforward from 972c66a
config-service 52.30% <ø> (ø) Carriedforward from 972c66a
file-service 63.97% <ø> (ø) Carriedforward from 972c66a
frontend 53.27% <ø> (ø) Carriedforward from 972c66a
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 972c66a
pyamber 91.18% <ø> (ø) Carriedforward from 972c66a
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 972c66a

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

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

LGTM!

Copilot AI 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.

Pull request overview

Adds Bun unit tests for assembleContext in the agent-service to improve confidence in how ReAct steps are grouped and rendered into the markdown “context” message passed to the LLM.

Changes:

  • Introduces context-utils.spec.ts covering empty-step behavior, completed vs ongoing task sections, and messageId grouping.
  • Adds coverage that the current dataflow section is appended when the workflow contains operators.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread agent-service/src/agent/util/context-utils.spec.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Meng Wang <mengw15@uci.edu>
@mengw15 mengw15 added this pull request to the merge queue Jul 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 12, 2026
@mengw15 mengw15 added this pull request to the merge queue Jul 12, 2026
Merged via the queue into apache:main with commit 20bc526 Jul 12, 2026
20 checks passed
@mengw15 mengw15 deleted the chore/6333-context-utils-test branch July 12, 2026 02:06
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.

add unit test coverage for agent-service assembleContext (context-utils.ts)

4 participants