test(agent-service): add unit test coverage for assembleContext#6354
Merged
Conversation
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.
Contributor
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
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.tscovering 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Meng Wang <mengw15@uci.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Add unit test coverage for
assembleContextinagent-service/src/agent/util/context-utils.ts— a pure function (type-only imports, no network) that groupsReActSteps by task, serializes completed vs ongoing tasks into markdown sections, appends a dataflow section, and returns[{ role: "user", content }]. Abun test.spec.tssits next to the source. No production-code changes.Any related issues, documentation, discussions?
Closes #6333.
How was this PR tested?
5 pass.
bun run typecheckandbun run format:checkare clean. The spec is pure — it buildsReActStep/WorkflowState/OperatorPredicatefixtures 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 Dataflowsection when the workflow has operators; and steps sharing amessageIdgrouped into one task.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])