Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

feat: check cycle error#164

Open
chao0kang wants to merge 1 commit into
devfrom
feature/fix-workflow-view-cycle
Open

feat: check cycle error#164
chao0kang wants to merge 1 commit into
devfrom
feature/fix-workflow-view-cycle

Conversation

@chao0kang
Copy link
Copy Markdown
Contributor

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 92.50000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ent/Coordinator/WorkflowView/WorkflowViewGAgent.cs 92.50% 2 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
...ent/Coordinator/WorkflowView/WorkflowViewGAgent.cs 78.47% <92.50%> (+5.39%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

chao0kang added a commit to aevatarAI/aevatar-station that referenced this pull request Sep 5, 2025
## Description

This PR migrates
[aevatarAI/aevatar-gagents#164](aevatarAI/aevatar-gagents#164)
to the aevatar-station repository.

### Original PR Details
- **Author**: chao0kang (chao.kang@aelf.io)
- **Title**: feat: check cycle error
- **Branch**: feature/fix-workflow-view-cycle

### Changes Made
This PR adds cycle detection to the WorkflowViewGAgent to prevent
circular dependencies in workflow graphs. The implementation includes:

1. **Cycle Detection Algorithm**: Implements Kahn's algorithm for
topological sorting to detect cycles in the workflow graph
2. **Self-Loop Detection**: Explicitly checks for and rejects
self-referencing nodes
3. **Error Handling**: Throws ArgumentException with clear error message
when cycles are detected

### Files Modified
-
`gagents/src/Aevatar.GAgents.GroupChat/GAgent/Coordinator/WorkflowView/WorkflowViewGAgent.cs`
- Added HasCycle method and cycle validation in PerformConfigAsync
-
`gagents/test/Aevatar.GAgents.GroupChat.Test/Tests/WorkFlowViewTest.cs`
- Added two unit tests to verify cycle detection works correctly

### Testing
- All existing tests pass ✅
- Added two new tests:
- `WorkflowViewTest_Should_Throw_When_SelfLoopExists` - Tests self-loop
detection
- `WorkflowViewTest_Should_Throw_When_CycleExists` - Tests general cycle
detection

### Migration Details
- Migrated using `git cherry-pick -X subtree=gagents f2c47e3c`
- All changes correctly placed in the `gagents/` subdirectory
- Build and tests completed successfully

Co-authored-by: chao0kang <chao.kang@aelf.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant